diff --git a/demo/std/src/demo_std.c b/demo/std/src/demo_std.c index 3bb33f6..9020fc9 100644 --- a/demo/std/src/demo_std.c +++ b/demo/std/src/demo_std.c @@ -54,7 +54,7 @@ void STD_TestTask() Trace(1,"atox:%d",d); float e = atof("123.456"); - Trace(1,"atof:%d.%d",(int)(e),(int)(e*1000%1000)); + Trace(1,"atof:%d.%d",(int)(e),((int)(e*1000)%1000)); char* string = "-12345 stop here"; char* stopString = NULL; @@ -77,6 +77,12 @@ void STD_TestTask() item = bsearch(&key,num,10,sizeof(int),cmp); Trace(1,"item:%d",*item); + int read0,read1; + // sscanf("123 456","%d %d",&read0,&read1);//error!!! + sscanf("123","%d",&read0); + sscanf("456","%d",&read1); + Trace(1,"read0:%d, read1:%d",read0,read1); + OS_Sleep(3000); } diff --git a/include/sdk_init.h b/include/sdk_init.h index 0e539ca..67be8d8 100644 --- a/include/sdk_init.h +++ b/include/sdk_init.h @@ -208,6 +208,14 @@ typedef struct T_INTERFACE_VTBL_TAG //std int (*sscanf)(const char * buf, const char * fmt, ...); + long (*atol)(const char *s); + long long (*atoll)(const char *s); + int (*atox)(const char *s, int len); + double (*atof)(const char *s); + unsigned char* (*itoa)(int value, char *str, int radix); + char* (*gcvt)(double value, int ndigit, char *buf); + int (*rand) (void); + void (*srand)(unsigned int seed); //ssl SSL_Error_t (*SSL_Init)(SSL_Config_t* sslConfig); diff --git a/include/std_inc/stdio.h b/include/std_inc/stdio.h index 54b87ba..22b5ed9 100644 --- a/include/std_inc/stdio.h +++ b/include/std_inc/stdio.h @@ -8,10 +8,13 @@ extern "C" { #include "stddef.h" #include +#include "sdk_init.h" int sprintf(char * buf, const char *fmt, ...); int snprintf(char * buf, size_t len, const char *fmt, ...); -int sscanf(const char * buf, const char * fmt, ...); + +#define sscanf CSDK_FUNC(sscanf) + int vsprintf(char *buf, const char *fmt, va_list ap); int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap); int vsscanf (const char *fp, const char *fmt0, va_list ap); diff --git a/include/std_inc/stdlib.h b/include/std_inc/stdlib.h index e0a19da..3a1b3a9 100644 --- a/include/std_inc/stdlib.h +++ b/include/std_inc/stdlib.h @@ -7,16 +7,17 @@ extern "C" { #include "cs_types.h" #include "stddef.h" +#include "sdk_init.h" /* Standard atoi() function. Work as the libc one. */ int atoi(const char *s); -long atol(const char *s); -long long atoll(const char *s); -int atox(const char *s, int len); -double atof(const char *s); -unsigned char* itoa(int value, char *str, int radix); -char* gcvt(double value, int ndigit, char *buf); +#define atol CSDK_FUNC(atol) +#define atoll CSDK_FUNC(atoll) +#define atox CSDK_FUNC(atox) +#define atof CSDK_FUNC(atof) +#define itoa CSDK_FUNC(itoa) +#define gcvt CSDK_FUNC(gcvt) long strtol(const char *nptr, char **endptr, int base); unsigned long strtoul(const char *nptr, char **endptr, int base); @@ -24,9 +25,8 @@ unsigned long strtoul(const char *nptr, char **endptr, int base); /* Standard random functions, work as the libc ones. */ #define RAND_MAX 32767 -int rand (void); -void srand(unsigned int seed); - +#define rand CSDK_FUNC(rand) +#define srand CSDK_FUNC(srand) typedef INT STD_COMPAR_FUNC_T (const VOID*, const VOID*);