2026-03-25 20:21:12 +00:00
|
|
|
#include "file.h"
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2026-04-01 18:51:13 +01:00
|
|
|
int __fgetc(struct __opaque_file *stream)
|
2026-03-25 20:21:12 +00:00
|
|
|
{
|
|
|
|
|
if (stream->f_flags & (FILE_EOF | FILE_ERR)) {
|
|
|
|
|
return EOF;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 18:51:13 +01:00
|
|
|
char c = 0;
|
|
|
|
|
int ret = __libc_file_read(stream, &c, 1);
|
|
|
|
|
if (ret < 1) {
|
2026-03-25 20:21:12 +00:00
|
|
|
return EOF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}
|
2026-04-01 18:51:13 +01:00
|
|
|
|
|
|
|
|
int fgetc(struct __opaque_file *stream)
|
|
|
|
|
{
|
|
|
|
|
__libc_file_lock(stream);
|
|
|
|
|
int ret = __fgetc(stream);
|
|
|
|
|
__libc_file_unlock(stream);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|