summaryrefslogtreecommitdiff
path: root/src/stdio/freopen.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-01-30 14:25:31 -0500
committerJakob Kaivo <jkk@ung.org>2024-01-30 14:25:31 -0500
commit000a7c045c98c30aac86db93f8c9c978e5ca8c59 (patch)
treef882b1258d0c9b32f8517a9557b86e6ebc8aa9bb /src/stdio/freopen.c
parentb25685d5dc26370ecae112f805b4141c4efdeea4 (diff)
update standards and safety checks
Diffstat (limited to 'src/stdio/freopen.c')
-rw-r--r--src/stdio/freopen.c19
1 files changed, 11 insertions, 8 deletions
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 <sys/types.h>
+//#include <sys/types.h>
#include <errno.h>
-#include <fcntl.h>
+//#include <fcntl.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+//#include <unistd.h>
#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