From: John Hodge Date: Fri, 17 Feb 2012 03:17:38 +0000 (+0800) Subject: Kernel - Added snprintf function X-Git-Tag: rel0.15~768 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ad3f36f339ddf52b38df05fbc307c3016ee1542c;p=tpg%2Facess2.git Kernel - Added snprintf function --- diff --git a/KernelLand/Kernel/include/acess.h b/KernelLand/Kernel/include/acess.h index 0121eb24..ea96031b 100644 --- a/KernelLand/Kernel/include/acess.h +++ b/KernelLand/Kernel/include/acess.h @@ -402,6 +402,7 @@ extern Uint32 SwapEndian32(Uint32 Val); * \{ */ extern int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args); +extern size_t snprintf(char *__s, size_t __n, const char *__format, ...); extern int sprintf(char *__s, const char *__format, ...); extern size_t strlen(const char *Str); extern char *strcpy(char *__dest, const char *__src); diff --git a/KernelLand/Kernel/lib.c b/KernelLand/Kernel/lib.c index 60cbd4c7..3c97ab78 100644 --- a/KernelLand/Kernel/lib.c +++ b/KernelLand/Kernel/lib.c @@ -17,8 +17,10 @@ const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 3 // === PROTOTYPES === #if 0 int atoi(const char *string); + int ParseInt(const char *string, int *Val); void itoa(char *buf, Uint64 num, int base, int minLength, char pad); int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args); +size_t snprintf(char *__s, size_t __n, const char *__format, ...); int sprintf(char *__s, const char *__format, ...); #endif int tolower(int c); @@ -408,6 +410,20 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) } #undef PUTCH +/** + */ +size_t snprintf(char *__s, size_t __n, const char *__format, ...) +{ + va_list args; + int ret; + + va_start(args, __format); + ret = vsnprintf(__s, __n, __format, args); + va_end(args); + + return ret; +} + /** */ int sprintf(char *__s, const char *__format, ...)