aboutsummaryrefslogtreecommitdiff
path: root/lib/stdio/vfprintf.c
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-12-10 20:56:57 +0200
committeraqua <aqua@iserlohn-fortress.net>2022-12-11 11:32:51 +0200
commit9b2a78fa52249ab481493550490aa5f37872dcf6 (patch)
tree127031268b9b42b0fbdae3d87684d9c045983677 /lib/stdio/vfprintf.c
parentRename CCFLAGS to CFLAGS (diff)
downloadkernel-9b2a78fa52249ab481493550490aa5f37872dcf6.tar.xz
Rewrite drivers/uart and drivers/vga in cpp
Diffstat (limited to 'lib/stdio/vfprintf.c')
-rw-r--r--lib/stdio/vfprintf.c54
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/stdio/vfprintf.c b/lib/stdio/vfprintf.c
deleted file mode 100644
index d24e43e..0000000
--- a/lib/stdio/vfprintf.c
+++ /dev/null
@@ -1,54 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-static char buffer[3 * sizeof(int) + 2];
-
-int
-vfprintf(FILE *restrict stream, const char *restrict format, va_list params)
-{
- int written = 0;
-
- int s = 0;
- int l = 0;
- for (int i = 0; format[i] != '\0'; ++i) {
- if (format[i] == '%') {
- written += stream->puts(stream, &format[s], l);
- s = i + 2;
- ++i;
-
- switch (format[i]) {
- case 's': {
- const char *arg = va_arg(params, const char *);
- written += stream->puts(stream, arg, -1);
- } break;
- case 'c': {
- const int arg = va_arg(params, int);
- stream->putc(stream, arg);
- ++written;
- } break;
- case 'd': {
- const char *arg = itoa(buffer, va_arg(params, int), 10);
- written += stream->puts(stream, arg, -1);
- } break;
- case 'u': {
- const char *arg = utoa(buffer, va_arg(params, unsigned int), 10);
- written += stream->puts(stream, arg, -1);
- } break;
- case 'x': {
- const char *arg = utoa(buffer, va_arg(params, unsigned int), 16);
- written += stream->puts(stream, arg, -1);
- } break;
- }
-
- l = 0;
- }
-
- else
- ++l;
- }
-
- if (l > 0) { written += stream->puts(stream, &format[s], l); }
-
- stream->flush(stream);
- return written;
-}