From 000a7c045c98c30aac86db93f8c9c978e5ca8c59 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 30 Jan 2024 14:25:31 -0500 Subject: update standards and safety checks --- src/stdio/freopen.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/stdio/freopen.c') diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index cee31692..b39fda4c 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -1,16 +1,14 @@ -#if 0 - #ifndef _POSIX_SOURCE #define _POSIX_SOURCE #define POSIX_FORCED #endif -#include +//#include #include -#include +//#include #include #include -#include +//#include #include "_stdio.h" #ifdef POSIX_FORCED @@ -18,6 +16,12 @@ #include "_syscall.h" #define open(_p, _f, _m) __scall3(open, _p, _f, _m) #define isatty(_fd) ioctl(_fd, TCFLSH, 0) +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_CREAT 0100 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_RDWR 02 #endif /** reopen a file stream with a new file **/ @@ -53,6 +57,8 @@ FILE * freopen(const char * restrict filename, const char * restrict mode, FILE size_t i; int fd = -1; + SIGNAL_SAFE(0); + for (i = 0; i < sizeof(modemap) / sizeof(modemap[0]); i++) { if (!strcmp(modemap[i].smode, mode)) { openmode = modemap[i].omode; @@ -108,6 +114,3 @@ The error and end-of-file indicators are cleared. /* STDC(1) */ - - -#endif -- cgit v1.2.1