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

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

Use standard integer types.

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