21 #ifndef SAFEC_DUMMY_API
22 #include "safe_str_lib.h"
23 #include "safe_mem_lib.h"
27 #define STRCPY_S_NOCLOBBER(dst,dmax,src) ((src) ? (strlen(src) < dmax ? strcpy_s(dst,dmax,src) : ESNOSPC):ESNULLP)
28 #define MEMCPY_S_NOCLOBBER(dst,dmax,src,len) ((src) ? (len <= dmax ? memcpy_s(dst,dmax,src,len) : ESNOSPC):ESNULLP)
34 #define RDK_SAFECLIB_ERR(rc) fprintf(stderr, "safeclib error at rc - %d %s:%s %d",rc, __FILE__, __FUNCTION__, __LINE__)
38 RDK_SAFECLIB_ERR(rc); \
41 #ifdef SAFEC_DUMMY_API
48 #define strcpy_s(dst,max,src) (src)?((max > strlen(src))?EOK:ESLEMAX):ESNULLP; \
49 if((src) && (max > strlen(src))) strcpy(dst,src);
51 #define strncpy_s(dst,max,src,len) (src)?((len <= max)?EOK:ESLEMAX):ESNULLP; \
52 if(src && (len <= max)) strncpy(dst,src,len);
54 #define memset_s(dst,max_1,c,max) EOK; \
57 #define strcat_s(dst,max,src) (src)?((max > strlen(src))?EOK:ESLEMAX):ESNULLP; \
58 if((src) && (max > strlen(src))) strcat(dst,src);
60 #define strncat_s(dst,max,src,len) (src)?((len <= max)?EOK:ESLEMAX):ESNULLP; \
61 if(src && (len <= max)) strncat(dst,src,len);
63 #define memcpy_s(dst,max,src,len) (src)?((len <= max)?EOK:ESLEMAX):ESNULLP; \
64 if(src && (len <= max)) memcpy(dst,src,len);
66 #define STRCPY_S_NOCLOBBER(dst,max,src) (src)?((max > strlen(src))?EOK:ESLEMAX):ESNULLP; \
67 if(src && (strlen(src) < max)) strcpy(dst, src);
69 #define MEMCPY_S_NOCLOBBER(dst,max,src,len) (src) ? ((len <= max)?EOK:ESLEMAX):ESNULLP; \
70 if(src && (len <= max)) memcpy(dst, src, len);
72 #define strtok_s(dest, dmax, delim, ptr) strtok_r(dest, delim, ptr)
74 #define sprintf_s( dst, max, fmt, ...) EOK; \
75 sprintf( dst, fmt, ##__VA_ARGS__ );
77 static inline int strcmp_s(
const char *dst,
int dmax,
const char *src,
int *r) {
78 if((src == NULL) || (dst == NULL) || (dmax == 0))
81 *r = strcmp(dst, src);
85 static inline int strcasecmp_s(
const char *dst,
int dmax,
const char *src,
int *r) {
86 if((src == NULL) || (dst == NULL) || (dmax == 0))
89 *r = strcasecmp(dst, src);