* more re-work
[mascara-docs.git] / i386 / junos / ucla / src / lab4 / kern / printf.c
blob3b9e7d8eed3053df26d3f53eee9e2cafce955987
1 // Simple implementation of cprintf console output for the kernel,
2 // based on printfmt() and the kernel console's cputchar().
4 #include <inc/types.h>
5 #include <inc/stdio.h>
6 #include <inc/stdarg.h>
9 static void
10 putch(int ch, void *ptr)
12 int *cnt = (int *) ptr;
13 cputchar(ch);
14 *cnt++;
17 int
18 vcprintf(const char *fmt, va_list ap)
20 int cnt = 0;
22 vprintfmt(&putch, &cnt, fmt, ap);
23 return cnt;
26 int
27 cprintf(const char *fmt, ...)
29 va_list ap;
30 int cnt;
32 va_start(ap, fmt);
33 cnt = vcprintf(fmt, ap);
34 va_end(ap);
36 return cnt;