Last change
on this file since ca867c1 was 8973acd, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
No more warnings in libcio.
|
-
Property mode
set to
100644
|
File size:
862 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 |
|
---|
[b28a12e] | 8 | #include "ram.h"
|
---|
[e225e77] | 9 |
|
---|
[7258c6a] | 10 | int16_t getc(FILE *ptr)
|
---|
[f40a309] | 11 | {
|
---|
[7258c6a] | 12 | register int16_t len;
|
---|
[f40a309] | 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 |
|
---|
[8973acd] | 19 | ptr->_flags = (uint8_t)(ptr->_flags & ~_DIRTY); /* reset the dirty buffer bit */
|
---|
[f40a309] | 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 |
|
---|
[8973acd] | 26 | ptr->_flags = (uint8_t)(ptr->_flags | ((len EQ 0) ? _EOF : _IOERR));
|
---|
[f40a309] | 27 | return(EOF);
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | ptr->_bend = (ptr->_bp = ptr->_buff) + len;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | return(*ptr->_bp++ & 0xFF);
|
---|
| 34 | }
|
---|
[6262b5c] | 35 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.