vsprintf: Add scnprintf from kernel
Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
45885266f9
commit
647fba8ee3
|
@ -13,6 +13,7 @@ void serial_printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2
|
||||||
|
|
||||||
int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
||||||
int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
|
int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
|
||||||
|
int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
|
||||||
int vsprintf(char *buf, const char *fmt, va_list args);
|
int vsprintf(char *buf, const char *fmt, va_list args);
|
||||||
char *asprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
|
char *asprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
|
||||||
char *vasprintf(const char *fmt, va_list ap);
|
char *vasprintf(const char *fmt, va_list ap);
|
||||||
|
|
|
@ -595,6 +595,30 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(snprintf);
|
EXPORT_SYMBOL(snprintf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scnprintf - Format a string and place it in a buffer
|
||||||
|
* @buf: The buffer to place the result into
|
||||||
|
* @size: The size of the buffer, including the trailing null space
|
||||||
|
* @fmt: The format string to use
|
||||||
|
* @...: Arguments for the format string
|
||||||
|
*
|
||||||
|
* The return value is the number of characters written into @buf not including
|
||||||
|
* the trailing '\0'. If @size is == 0 the function returns 0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int scnprintf(char *buf, size_t size, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
i = vscnprintf(buf, size, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(scnprintf);
|
||||||
|
|
||||||
/* Simplified asprintf. */
|
/* Simplified asprintf. */
|
||||||
char *vasprintf(const char *fmt, va_list ap)
|
char *vasprintf(const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue