Last change
on this file since ea9a162 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
|
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 |
|
---|
10 | int16_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 = (uint8_t)(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 = (uint8_t)(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.