contiki/cpu/at91sam7s/dbg-io/dbg-sprintf.c
ksb 792eae91c6 rtimer implementation (not well tested)
sprintf that use strformat, so there's no need to pull in the newlib
implementation.
Build system improvements.
2007-08-21 09:03:55 +00:00

27 lines
516 B
C

#include <stdio.h>
#include <strformat.h>
#include <string.h>
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;
}
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;
}