ksnprint.c (337B)
1 #include <stdarg.h> 2 #include <stddef.h> 3 4 #include <libk.h> 5 6 #include "stream.h" 7 8 int 9 ksnprint(char *str, size_t len, const char *fmt, ...) 10 { 11 va_list ap; 12 Stream stream; 13 14 stream.base = str; 15 stream.len = len; 16 stream.cnt = 0; 17 18 va_start(ap, fmt); 19 doprnt(&stream, fmt, ap); 20 va_end(ap); 21 22 str[stream.cnt] = '\0'; 23 24 return stream.cnt; 25 }