summaryrefslogtreecommitdiff
path: root/src/libc64/sprintf.c
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2024-09-08 23:11:41 +0200
committerGitHub <noreply@github.com>2024-09-08 17:11:41 -0400
commitc7ec814d7897456ecdf1772e395a13f048b5133d (patch)
treeb9324efea542b5f7402563925195b8797fc063be /src/libc64/sprintf.c
parenta903f8b8bcc32d8f6c0a76ce5eeead271c297772 (diff)
[headers 9] Add src/libc64/ and new "z64" rand.h (#2164)
* rand.h -> libc64/qrand.h * Add rand.h with z64 rand wrappers * yeet comment * code/rand.c -> libc64/qrand.c * fixup * move libc64 source to src/libc64/ * fix * bss * update file splits disasm metadata
Diffstat (limited to 'src/libc64/sprintf.c')
-rw-r--r--src/libc64/sprintf.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/libc64/sprintf.c b/src/libc64/sprintf.c
new file mode 100644
index 000000000..d4af36356
--- /dev/null
+++ b/src/libc64/sprintf.c
@@ -0,0 +1,37 @@
+#include "stdarg.h"
+#include "stdio.h"
+#include "string.h"
+#include "ultra64/xstdio.h"
+
+#if PLATFORM_N64
+// Generated by CVS "$Id$" keyword
+char sSprintfFileInfo[] = "$Id: sprintf.c,v 1.5 1997/03/19 02:28:53 hayakawa Exp $";
+#endif
+
+void* proutSprintf(void* dst, const char* fmt, size_t size) {
+ return (char*)memcpy(dst, fmt, size) + size;
+}
+
+int vsprintf(char* dst, const char* fmt, va_list args) {
+ int ret = _Printf(proutSprintf, dst, fmt, args);
+
+ if (ret > -1) {
+ dst[ret] = '\0';
+ }
+ return ret;
+}
+
+int sprintf(char* dst, const char* fmt, ...) {
+ int ret;
+ va_list args;
+ va_start(args, fmt);
+
+ ret = _Printf(proutSprintf, dst, fmt, args);
+ if (ret > -1) {
+ dst[ret] = '\0';
+ }
+
+ va_end(args);
+
+ return ret;
+}