2017-11-22 00:53:42 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-07-11 14:26:28 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <strformat.h>
|
|
|
|
#include <string.h>
|
2017-11-22 00:53:42 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-07-11 14:26:28 +00:00
|
|
|
static StrFormatResult
|
|
|
|
buffer_str(void *user_data, const char *data, unsigned int len)
|
|
|
|
{
|
|
|
|
memcpy(*(char**)user_data, data, len);
|
|
|
|
(*(char**)user_data) += len;
|
|
|
|
return STRFORMAT_OK;
|
|
|
|
}
|
2017-11-22 00:53:42 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-07-11 14:26:28 +00:00
|
|
|
int
|
|
|
|
sprintf(char *str, const char *format, ...)
|
|
|
|
{
|
|
|
|
StrFormatContext ctxt;
|
|
|
|
int res;
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
|
|
|
ctxt.write_str = buffer_str;
|
|
|
|
ctxt.user_data = &str;
|
|
|
|
res = format_str_v(&ctxt, format, ap);
|
|
|
|
*str = '\0';
|
|
|
|
va_end(ap);
|
|
|
|
return res;
|
|
|
|
}
|
2017-11-22 00:53:42 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|