]> pd.if.org Git - pdclib/blob - functions/stdio/fgetc.c
b5a32572158fd89dc2875d65dfca75407073d231
[pdclib] / functions / stdio / fgetc.c
1 /* $Id$ */
2
3 /* fgetc( FILE * )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10
11 #include <_PDCLIB_glue.h>
12
13 #ifndef REGTEST
14
15 int fgetc( struct _PDCLIB_file_t * stream )
16 {
17     if ( _PDCLIB_prepread( stream ) == EOF )
18     {
19         return EOF;
20     }
21     if ( stream->ungetidx > 0 )
22     {
23         return (unsigned char)stream->ungetbuf[ --(stream->ungetidx) ];
24     }
25     return (unsigned char)stream->buffer[stream->bufidx++];
26 }
27
28 #endif
29
30 #ifdef TEST
31 #include <_PDCLIB_test.h>
32
33 int main( void )
34 {
35     /* Testing covered by ftell.c */
36     return TEST_RESULTS;
37 }
38
39 #endif