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

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

Zero redundant declarations.

  • Property mode set to 100644
File size: 815 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 "ram.h"
9
10int16_t getc(FILE *ptr)
11{
12 register int16_t len;
13
14 if (ptr->_bp >= ptr->_bend) { /* see if the buffer is empty */
15
16 if (ptr->_flags & _EOF) /* check EOF status */
17 return(EOF);
18
19 ptr->_flags &= ~_DIRTY; /* reset the dirty buffer bit */
20
21 if (ptr->_buff EQ NULL) /* get a buffer if none exists */
22 getbuff(ptr);
23
24 if ((len = read(ptr->_unit, ptr->_buff, ptr->_buflen)) LE 0) {
25
26 ptr->_flags |= ((len EQ 0) ? _EOF : _IOERR);
27 return(EOF);
28 }
29
30 ptr->_bend = (ptr->_bp = ptr->_buff) + len;
31 }
32
33 return(*ptr->_bp++ & 0xFF);
34}
35
Note: See TracBrowser for help on using the repository browser.