source: buchla-68k/libcio/getc.c@ e225e77

Last change on this file since e225e77 was e225e77, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added missing includes and declarations.

  • Property mode set to 100644
File size: 931 bytes
Line 
1/*
2 ============================================================================
3 getc.c -- get a character from a stream file
4 Version 3 -- 1987-09-22 -- D.N. Lynx Crowe
5 ============================================================================
6*/
7
8#include "stdio.h"
9#include "stddefs.h"
10
11extern int16_t read(int16_t fd, int8_t *buff, uint16_t len);
12extern void getbuff(FILE *ptr);
13
14int16_t getc(FILE *ptr)
15{
16 register int16_t len;
17
18 if (ptr->_bp >= ptr->_bend) { /* see if the buffer is empty */
19
20 if (ptr->_flags & _EOF) /* check EOF status */
21 return(EOF);
22
23 ptr->_flags &= ~_DIRTY; /* reset the dirty buffer bit */
24
25 if (ptr->_buff EQ NULL) /* get a buffer if none exists */
26 getbuff(ptr);
27
28 if ((len = read(ptr->_unit, ptr->_buff, ptr->_buflen)) LE 0) {
29
30 ptr->_flags |= ((len EQ 0) ? _EOF : _IOERR);
31 return(EOF);
32 }
33
34 ptr->_bend = (ptr->_bp = ptr->_buff) + len;
35 }
36
37 return(*ptr->_bp++ & 0xFF);
38}
Note: See TracBrowser for help on using the repository browser.