From 2efcd435b415defb893385b01c80947bacb97aec Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 11 Feb 2021 23:05:17 +0100 Subject: Added sprintf --- libc/print.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'libc/print.c') diff --git a/libc/print.c b/libc/print.c index a66692e..ffb1e69 100644 --- a/libc/print.c +++ b/libc/print.c @@ -81,6 +81,16 @@ int vsprintf(char *str, const char *format, va_list ap) return strlen(str); } +int sprintf(char *str, const char *format, ...) +{ + va_list ap; + va_start(ap, format); + int len = vsprintf(str, format, ap); + va_end(ap); + + return len; +} + #ifdef userspace #include @@ -88,6 +98,11 @@ int vsprintf(char *str, const char *format, va_list ap) #define PATH_LOG "/proc/self/io/log" #define PATH_ERR "/proc/self/io/err" +int vprintf(const char *format, va_list ap) +{ + return vfprintf(PATH_OUT, format, ap); +} + int vfprintf(const char *path, const char *format, va_list ap) { char buf[1024] = { 0 }; @@ -95,11 +110,6 @@ int vfprintf(const char *path, const char *format, va_list ap) return write(path, buf, 0, len); } -int vprintf(const char *format, va_list ap) -{ - return vfprintf(PATH_OUT, format, ap); -} - int fprintf(const char *path, const char *format, ...) { va_list ap; @@ -147,8 +157,8 @@ int print(const char *str) #else // The kernel prints everything into the serial console -#include +#include #define RED "\x1B[1;31m" #define GRN "\x1B[1;32m" #define YEL "\x1B[1;33m" -- cgit v1.2.3