Contiki 2.6
|
00001 #include <stdio.h> 00002 #include <strformat.h> 00003 #include <string.h> 00004 00005 static StrFormatResult 00006 buffer_str(void *user_data, const char *data, unsigned int len) 00007 { 00008 memcpy(*(char**)user_data, data, len); 00009 (*(char**)user_data) += len; 00010 return STRFORMAT_OK; 00011 } 00012 00013 int 00014 sprintf(char *str, const char *format, ...) 00015 { 00016 StrFormatContext ctxt; 00017 int res; 00018 va_list ap; 00019 va_start(ap, format); 00020 ctxt.write_str = buffer_str; 00021 ctxt.user_data = &str; 00022 res = format_str_v(&ctxt, format, ap); 00023 *str = '\0'; 00024 va_end(ap); 00025 return res; 00026 }