Files
rosetta/lib/libc/io/stdio/fgetc.c
T

28 lines
414 B
C

#include "file.h"
#include <errno.h>
#include <stdio.h>
int __fgetc(struct __opaque_file *stream)
{
if (stream->f_flags & (FILE_EOF | FILE_ERR)) {
return EOF;
}
char c = 0;
int ret = __libc_file_read(stream, &c, 1);
if (ret < 1) {
return EOF;
}
return c;
}
int fgetc(struct __opaque_file *stream)
{
__libc_file_lock(stream);
int ret = __fgetc(stream);
__libc_file_unlock(stream);
return ret;
}