summaryrefslogtreecommitdiff
path: root/src/user/lib/stdio
diff options
context:
space:
mode:
authordzwdz2022-08-29 13:57:47 +0200
committerdzwdz2022-08-29 13:58:02 +0200
commit4ae57a7fb13e68c5e6f1c1246a867555dbd986db (patch)
tree3bee7f7eee21e9f2ed3b9f07dd1671a1c230cf66 /src/user/lib/stdio
parentedb7fc07bf93e4a1883cccf45ad7a4b2cbf390d9 (diff)
user/lua: implement the bare minimum for it to link and "run"
Diffstat (limited to 'src/user/lib/stdio')
-rw-r--r--src/user/lib/stdio/file.c16
-rw-r--r--src/user/lib/stdio/misc.c21
2 files changed, 36 insertions, 1 deletions
diff --git a/src/user/lib/stdio/file.c b/src/user/lib/stdio/file.c
index 63b004d..8c0fc57 100644
--- a/src/user/lib/stdio/file.c
+++ b/src/user/lib/stdio/file.c
@@ -1,11 +1,12 @@
#include "file.h"
-#include <camellia/syscalls.h>
#include <camellia/flags.h>
+#include <camellia/syscalls.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <user/lib/panic.h>
static FILE _stdin_null = { .fd = STDIN_FILENO };
static FILE _stdout_null = { .fd = STDOUT_FILENO };
@@ -124,6 +125,13 @@ int pclose(FILE *f) {
return -1;
}
+// TODO tmpfile()
+FILE *tmpfile(void) {
+ errno = ENOSYS;
+ return NULL;
+}
+
+
int fextflags(FILE *f, int extflags) {
int old = f->extflags;
f->extflags = extflags;
@@ -227,6 +235,12 @@ int fputc(int c, FILE *f) {
}
int putc(int c, FILE *f) { return fputc(c, f); }
+// TODO ungetc
+int ungetc(int c, FILE *f) {
+ (void)c; (void)f;
+ __libc_panic("unimplemented");
+}
+
int fseek(FILE *f, long offset, int whence) {
return fseeko(f, offset, whence);
}
diff --git a/src/user/lib/stdio/misc.c b/src/user/lib/stdio/misc.c
index 8f872ec..d74c197 100644
--- a/src/user/lib/stdio/misc.c
+++ b/src/user/lib/stdio/misc.c
@@ -1,5 +1,7 @@
#include <errno.h>
#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
void perror(const char *s) {
if (s) fprintf(stderr, "%s: ", s);
@@ -23,3 +25,22 @@ off_t lseek(int fd, off_t off, int whence) {
errno = ENOSYS;
return -1;
}
+
+int remove(const char *path) {
+ return unlink(path);
+}
+
+// TODO! VFSOP_MOVE
+int rename(const char *old, const char *new) {
+ (void)old; (void)new;
+ errno = ENOSYS;
+ return -1;
+}
+
+// TODO tmpnam
+char *tmpnam(char *s) {
+ static char buf[L_tmpnam];
+ if (!s) s = buf;
+ strcpy(s, "/tmp/tmpnam");
+ return s;
+}