1 #pragma once 2 3 #include <lk/compiler.h> 4 #include <stdarg.h> 5 #include <stddef.h> 6 7 __BEGIN_CDECLS 8 9 /* 10 * scnprintf/vscnprintf is like snprintf/vsnprintf, but returns the number of 11 * characters actually written to the buffer rather than the number it would 12 * write if given arbitrary space. 13 */ 14 15 /** 16 * scnprintf() 17 * @buf - output buffer 18 * @size - amount of space available in the output buffer 19 * @fmt - printf-style format string 20 * @... - arguments to format in the format string 21 * 22 * scnprintf() is like snprintf(), but returns the amount of space it used in 23 * the buffer rather than how large the formatted string would be. 24 * 25 * Specifically, scnprintf will use printf semantics to expand @fmt with @..., 26 * writing the first @size characters to the buffer. 27 * 28 * Return: The number of characters written to the buffer. 29 */ 30 __attribute__((__format__ (__printf__, 3, 4))) /* */ 31 int scnprintf(char* buf, size_t size, const char* fmt, ...); 32 33 /** 34 * vscnprintf() 35 * @buf - output buffer 36 * @size - amount of space available in the output buffer 37 * @fmt - printf-style format string 38 * @args - arguments to format in the format string 39 * 40 * vscnprintf() is like vsnprintf(), but returns the amount of space it used in 41 * the buffer rather than how large the formatted string would be. 42 * 43 * Specifically, vscnprintf will use printf semantics to expand @fmt with 44 * @args, writing the first @size characters to the buffer. 45 * 46 * Return: The number of characters written to the buffer. 47 */ 48 __attribute__((__format__ (__printf__, 3, 0))) /* */ 49 int vscnprintf(char* buf, size_t size, const char* fmt, va_list args); 50 51 __END_CDECLS 52