aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/stdio.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/libc/stdio.c')
-rw-r--r--sys/libc/stdio.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/sys/libc/stdio.c b/sys/libc/stdio.c
deleted file mode 100644
index 8bbbe9a..0000000
--- a/sys/libc/stdio.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <u.h>
-#include <libc.h>
-
-int
-printf(byte* fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
-
- int nw, rem, peek, len;
- byte *str, c;
-
- while (*fmt) {
- rem = INT_MAX - nw;
-
- if (fmt[0] != '%' || fmt[1] == '%') {
- if (fmt[0] == '%') fmt++;
-
- for (peek = 1; fmt[peek] && fmt[peek] != '%'; peek++) {
- ;
- }
- if (rem < peek) return -1;
- // TODO: Print here.
- fmt += peek;
- nw += peek;
- continue;
- }
-
- str = fmt++;
-
- switch (*fmt++) {
- case 'c':
- c = va_arg(args, int);
- if (rem < 0) return -1;
- // TODO: Print here
- nw++;
- break;
-
- case 's':
- str = va_arg(args, byte*);
- len = strlen(str);
- if (rem < len) return -1;
- // TODO: Print here
- nw += len;
- break;
- default:
- fmt = str;
- len = strlen(fmt);
- if (rem < len) return -1;
- // TODO: Print here
- nw += len;
- fmt += len;
- break;
- }
- }
-
- va_end(args);
- return nw;
-}