diff options
| author | Prakxo <87568477+Prakxo@users.noreply.github.com> | 2023-08-17 00:39:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-16 16:39:17 -0700 |
| commit | 1bebc761b638ad061778667e4bab4ec92fe81aa7 (patch) | |
| tree | 48fd9c72be87a1d6f7ebb780c2a0829d8c883006 /src/boot/libc64/sprintf.c | |
| parent | 043f0a3b259eee6bce038b76615e4ae5d3c8f1f0 (diff) | |
sprintf OK (#57)
* sprintf OK
* format
* refactor
Diffstat (limited to 'src/boot/libc64/sprintf.c')
| -rw-r--r-- | src/boot/libc64/sprintf.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/boot/libc64/sprintf.c b/src/boot/libc64/sprintf.c new file mode 100644 index 0000000..6b05ce9 --- /dev/null +++ b/src/boot/libc64/sprintf.c @@ -0,0 +1,30 @@ +#include "libc64/sprintf.h" +#include "lib/ultralib/include/ido/memory.h" +#include "lib/ultralib/src/libc/xstdio.h" + +void* proutPrintf(void* dst, const char* fmt, size_t size) { + return (void*)((u8*)memcpy(dst, fmt, size) + size); +} + +int vsprintf(char* dst, char* fmt, va_list args) { + s32 ret = _Printf((outfun*)proutPrintf, dst, fmt, args); + + if (ret >= 0) { + dst[ret] = '\0'; + } + return ret; +} +int sprintf(char* s, const char* fmt, ...) { + s32 ret; + va_list args; + va_start(args, fmt); + + ret = _Printf((outfun*)proutPrintf, s, fmt, args); + if (ret >= 0) { + s[ret] = '\0'; + } + + va_end(args); + + return ret; +} |
