summaryrefslogtreecommitdiff
path: root/src/user/lib/std/stdio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib/std/stdio.c')
-rw-r--r--src/user/lib/std/stdio.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/user/lib/std/stdio.c b/src/user/lib/std/stdio.c
index 2bce2e3..1628a78 100644
--- a/src/user/lib/std/stdio.c
+++ b/src/user/lib/std/stdio.c
@@ -2,6 +2,24 @@
#include <stdio.h>
#include <tce/syscall.h>
+FILE term = 0;
+void print(char *s) { fprint(term, s); }
+void printf(char *format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ vsfprintf(term, format, ap);
+ va_end(ap);
+}
+char* readln() { return freadln(term); }
+
+void fprintf(FILE f, char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ vsfprintf(f, format, ap);
+ va_end(ap);
+}
+
+
void fprint(FILE f, char *s) {
write(f, 0, strlen(s), s);
}
@@ -54,10 +72,7 @@ void fprint_hex(FILE f, unsigned v) {
fprint(f, s);
}
-void fprintf(FILE f, char* format, ...) {
- va_list ap;
- va_start(ap, format);
-
+void vsfprintf(FILE f, char *format, va_list ap) {
char* start = format;
while (*format) {
@@ -78,8 +93,6 @@ void fprintf(FILE f, char* format, ...) {
}
}
if (start != format) write(f, 0, format - start, start);
-
- va_end(ap);
}
char* freadln(FILE f) {