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

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

Added include files for global functions and variables.

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