初始提交
This commit is contained in:
42
mfgtool/io_lib/src/iot_sprintf.c
Normal file
42
mfgtool/io_lib/src/iot_sprintf.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
|
||||
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||||
|
||||
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||||
be copied by any method or incorporated into another program without
|
||||
the express written consent of Aerospace C.Power. This Information or any portion
|
||||
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||||
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||||
liability for its use in any way and conveys no license or title under
|
||||
any patent or copyright and makes no representation or warranty that this
|
||||
Information is free from patent or copyright infringement.
|
||||
|
||||
****************************************************************************/
|
||||
/* os shim includes */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "strformat.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 iot_sprintf(char *str, const char *format, ...)
|
||||
{
|
||||
str_format_context 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;
|
||||
}
|
||||
Reference in New Issue
Block a user