diff options
Diffstat (limited to 'src/user/lib/std')
-rw-r--r-- | src/user/lib/std/stdio.c | 25 | ||||
-rw-r--r-- | src/user/lib/std/string.c | 2 |
2 files changed, 20 insertions, 7 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) { diff --git a/src/user/lib/std/string.c b/src/user/lib/std/string.c index 7cd8ede..21dbd03 100644 --- a/src/user/lib/std/string.c +++ b/src/user/lib/std/string.c @@ -6,7 +6,7 @@ int strlen(const char *str) { return i-1; } -char *strchr(const char *str, char c) { +char *strchr(const char *str, int c) { while (*str) { if (*str == c) return (char*)str; str++; |