From 169771330199883d60f874a02978ea140f7c190a Mon Sep 17 00:00:00 2001 From: g1n Date: Sun, 24 Jul 2022 13:25:26 +0300 Subject: [PATCH] Changed to use open, close, read and write functions from libc instead of directly using them from liblinux (might make porting process easier) --- src/stdio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/stdio.c b/src/stdio.c index 6ea6444..a98718a 100644 --- a/src/stdio.c +++ b/src/stdio.c @@ -1,5 +1,7 @@ #include #include +#include +#include #define O_RDWR 2 // FIXME #define O_RDONLY 0 @@ -36,7 +38,7 @@ FILE* fopen(const char *restrict pathname, const char *restrict mode) { // FIXME default: return (FILE*)EINVAL; } - int fd = sys_open(pathname, oflag); + int fd = open(pathname, oflag); if (fd == -1) return NULL; FILE *temp = malloc(sizeof(pathname) + sizeof(fd)); @@ -46,12 +48,12 @@ FILE* fopen(const char *restrict pathname, const char *restrict mode) { // FIXME } int fclose(FILE *stream) { - return sys_close(stream->fd); + return close(stream->fd); } int fgetc(FILE *stream) { char buf = '\0'; - sys_read(stream->fd, (void*)&buf, 1); + read(stream->fd, (void*)&buf, 1); return (buf == '\0') ? (unsigned int)-1 : (unsigned int)buf; } @@ -68,7 +70,7 @@ char *fgets(char *restrict s, int n, FILE *restrict stream) { } int fputc(int c, FILE *stream) { - return (sys_write(stream->fd, &c, 1) == -1 ) ? -1 : c; + return (write(stream->fd, &c, 1) == -1 ) ? -1 : c; } int fputs(const char *restrict s, FILE *restrict stream) { @@ -85,7 +87,7 @@ int rename(const char *old, const char *new) { } int putchar(int c) { - sys_write(stdout->fd, &c, 1); + write(stdout->fd, &c, 1); return (unsigned char)c; }