From db5a42289a21af0f2ea94ecccd56b4e34739f8d0 Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Fri, 21 Feb 2025 02:43:00 +0200 Subject: [PATCH] feat(userspace/libc): implement feof() and ferror() functions Signed-off-by: EnderIce2 --- Userspace/libc/include/stdio.h | 4 ++-- Userspace/libc/src/std/stdio.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Userspace/libc/include/stdio.h b/Userspace/libc/include/stdio.h index 3f155e2c..de19ab42 100644 --- a/Userspace/libc/include/stdio.h +++ b/Userspace/libc/include/stdio.h @@ -91,8 +91,8 @@ extern "C" int dprintf(int, const char *restrict, ...); int fclose(FILE *stream); FILE *fdopen(int, const char *); - int feof(FILE *); - int ferror(FILE *); + int feof(FILE *stream); + int ferror(FILE *stream); int fflush(FILE *stream); int fgetc(FILE *stream); int fgetpos(FILE *restrict, fpos_t *restrict); diff --git a/Userspace/libc/src/std/stdio.c b/Userspace/libc/src/std/stdio.c index 41293743..aeb77e3a 100644 --- a/Userspace/libc/src/std/stdio.c +++ b/Userspace/libc/src/std/stdio.c @@ -81,8 +81,20 @@ export int fclose(FILE *stream) } export FILE *fdopen(int, const char *); -export int feof(FILE *); -export int ferror(FILE *); + +export int feof(FILE *stream) +{ + if (!stream) + return 0; + return stream->eof; +} + +export int ferror(FILE *stream) +{ + if (!stream) + return 0; + return stream->error; +} export int fflush(FILE *stream) {