Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/waterbox/libc/functions/stdio/fgetc.c
2 views
1
/* fgetc( FILE * )
2
3
This file is part of the Public Domain C Library (PDCLib).
4
Permission is granted to use, modify, and / or redistribute at will.
5
*/
6
7
#include <stdio.h>
8
9
#ifndef REGTEST
10
#include "_PDCLIB_io.h"
11
12
int _PDCLIB_fgetc_unlocked( FILE * stream )
13
{
14
if ( _PDCLIB_prepread( stream ) == EOF )
15
{
16
return EOF;
17
}
18
19
char c;
20
21
size_t n = _PDCLIB_getchars( &c, 1, EOF, stream );
22
23
return n == 0 ? EOF : (unsigned char) c;
24
}
25
26
int fgetc( FILE * stream )
27
{
28
_PDCLIB_flockfile( stream );
29
int c = _PDCLIB_fgetc_unlocked( stream );
30
_PDCLIB_funlockfile( stream );
31
return c;
32
}
33
34
#endif
35
36
#ifdef TEST
37
#include "_PDCLIB_test.h"
38
39
int main( void )
40
{
41
/* Testing covered by ftell.c */
42
return TEST_RESULTS;
43
}
44
45
#endif
46
47