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
|
Rev | Line | |
---|
[f40a309] | 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 |
|
---|
[6262b5c] | 8 | #include "all.h"
|
---|
[f40a309] | 9 |
|
---|
[e225e77] | 10 | extern int16_t read(int16_t fd, int8_t *buff, uint16_t len);
|
---|
| 11 | extern void getbuff(FILE *ptr);
|
---|
| 12 |
|
---|
[7258c6a] | 13 | int16_t getc(FILE *ptr)
|
---|
[f40a309] | 14 | {
|
---|
[7258c6a] | 15 | register int16_t len;
|
---|
[f40a309] | 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 | }
|
---|
[6262b5c] | 38 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.