• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2014-2018. All rights reserved.
3  * Description: The user of this secure c library should include this header file in you source code.
4  *              This header file declare all supported API prototype of the library,
5  *              such as memcpy_s, strcpy_s, wcscpy_s,strcat_s, strncat_s, sprintf_s, scanf_s, and so on.
6  * Author: lishunda
7  * Create: 2014-02-25
8  * Notes: Do not modify this file by yourself.
9  * History: 2018-09-27 zhaozhijian Code base quality improvement
10  */
11 
12 #ifndef __SECUREC_H__5D13A042_DC3F_4ED9_A8D1_882811274C27
13 #define __SECUREC_H__5D13A042_DC3F_4ED9_A8D1_882811274C27
14 
15 #include "securectype.h"
16 #ifndef SECUREC_HAVE_STDARG_H
17 #define SECUREC_HAVE_STDARG_H 1
18 #endif
19 
20 #if SECUREC_HAVE_STDARG_H
21 #include <stdarg.h>
22 #endif
23 
24 #ifndef SECUREC_HAVE_ERRNO_H
25 #if SECUREC_IN_KERNEL
26 #define SECUREC_HAVE_ERRNO_H 0
27 #else
28 #define SECUREC_HAVE_ERRNO_H 1
29 #endif
30 #endif
31 
32 /* EINVAL ERANGE may defined in errno.h */
33 #if SECUREC_HAVE_ERRNO_H
34 #include <errno.h>
35 #endif
36 
37 /* Define error code */
38 #if defined(SECUREC_NEED_ERRNO_TYPE) || !defined(__STDC_WANT_LIB_EXT1__) || \
39     (defined(__STDC_WANT_LIB_EXT1__) && (__STDC_WANT_LIB_EXT1__ == 0))
40 #ifndef SECUREC_DEFINED_ERRNO_TYPE
41 #define SECUREC_DEFINED_ERRNO_TYPE
42 /* Just check whether macrodefinition exists. */
43 #ifndef errno_t
44 typedef int errno_t;
45 #endif
46 #endif
47 #endif
48 
49 /* Success */
50 #ifndef EOK
51 #define EOK 0
52 #endif
53 
54 #ifndef EINVAL
55 /* The src buffer is not correct and destination buffer cant not be reset */
56 #define EINVAL 22
57 #endif
58 
59 #ifndef EINVAL_AND_RESET
60 /* Once the error is detected, the dest buffer must be reseted! */
61 #define EINVAL_AND_RESET (22 | 128)
62 #endif
63 
64 #ifndef ERANGE
65 /* The destination buffer is not long enough and destination buffer can not be reset */
66 #define ERANGE 34
67 #endif
68 
69 #ifndef ERANGE_AND_RESET
70 /* Once the error is detected, the dest buffer must be reseted! */
71 #define ERANGE_AND_RESET  (34 | 128)
72 #endif
73 
74 #ifndef EOVERLAP_AND_RESET
75 /* Once the buffer overlap is detected, the dest buffer must be reseted! */
76 #define EOVERLAP_AND_RESET (54 | 128)
77 #endif
78 
79 /* If you need export the function of this library in Win32 dll, use __declspec(dllexport) */
80 #ifndef SECUREC_API
81 #if defined(SECUREC_DLL_EXPORT)
82 #define SECUREC_API __declspec(dllexport)
83 #elif defined(SECUREC_DLL_IMPORT)
84 #define SECUREC_API __declspec(dllimport)
85 #else
86 /*
87  * Standardized function declaration. If a security function is declared in the your code,
88  * it may cause a compilation alarm,Please delete the security function you declared.
89  * Adding extern under windows will cause the system to have inline functions to expand,
90  * so do not add the extern in default
91  */
92 #if defined(_MSC_VER)
93 #define SECUREC_API
94 #else
95 #define SECUREC_API extern
96 #endif
97 #endif
98 #endif
99 
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103     /*
104      * Description: The GetHwSecureCVersion function get SecureC Version string and version number.
105      * Parameter: verNumber - to store version number
106      * Return:   version string
107      */
108     SECUREC_API const char *GetHwSecureCVersion(unsigned short *verNumber);
109 
110 #if SECUREC_ENABLE_MEMSET
111     /*
112      * Description: The memset_s function copies the value of c (converted to an unsigned char) into each of
113      * the first count characters of the object pointed to by dest.
114      * Parameter: dest - destination address
115      * Parameter: destMax - The maximum length of destination buffer
116      * Parameter: c - the value to be copied
117      * Parameter: count - copies count bytes of value to dest
118      * Return:    EOK if there was no runtime-constraint violation
119      */
120     SECUREC_API errno_t memset_s(void *dest, size_t destMax, int c, size_t count);
121 #endif
122 
123 #ifndef SECUREC_ONLY_DECLARE_MEMSET
124 #define SECUREC_ONLY_DECLARE_MEMSET     0
125 #endif
126 
127 #if SECUREC_ONLY_DECLARE_MEMSET == 0
128 
129 #if SECUREC_ENABLE_MEMMOVE
130     /*
131      * Description: The memmove_s function copies n characters from the object pointed to by src
132      * into the object pointed to by dest.
133      * Parameter: dest - destination  address
134      * Parameter: destMax - The maximum length of destination buffer
135      * Parameter: src - source address
136      * Parameter: count - copies count bytes from the src
137      * Return:    EOK if there was no runtime-constraint violation
138      */
139     SECUREC_API errno_t memmove_s(void *dest, size_t destMax, const void *src, size_t count);
140 #endif
141 
142 #if SECUREC_ENABLE_MEMCPY
143     /*
144      * Description: The memcpy_s function copies n characters from the object pointed to
145      * by src into the object pointed to by dest.
146      * Parameter: dest - destination  address
147      * Parameter: destMax - The maximum length of destination buffer
148      * Parameter: src - source address
149      * Parameter: count - copies count bytes from the  src
150      * Return:    EOK if there was no runtime-constraint violation
151      */
152     SECUREC_API errno_t memcpy_s(void *dest, size_t destMax, const void *src, size_t count);
153 #endif
154 
155 #if SECUREC_ENABLE_STRCPY
156     /*
157      * Description: The strcpy_s function copies the string pointed to by strSrc (including
158      * the terminating null character) into the array pointed to by strDest
159      * Parameter: strDest - destination  address
160      * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
161      * Parameter: strSrc - source address
162      * Return:    EOK if there was no runtime-constraint violation
163      */
164     SECUREC_API errno_t strcpy_s(char *strDest, size_t destMax, const char *strSrc);
165 #endif
166 
167 #if SECUREC_ENABLE_STRNCPY
168     /*
169      * Description: The strncpy_s function copies not more than n successive characters (not including
170      * the terminating null character) from the array pointed to by strSrc to the array pointed to by strDest.
171      * Parameter: strDest - destination  address
172      * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
173      * Parameter: strSrc - source  address
174      * Parameter: count - copies count  characters from the  src
175      * Return:    EOK if there was no runtime-constraint violation
176      */
177     SECUREC_API errno_t strncpy_s(char *strDest, size_t destMax, const char *strSrc, size_t count);
178 #endif
179 
180 #if SECUREC_ENABLE_STRCAT
181     /*
182      * Description: The strcat_s function appends a copy of the string pointed to by strSrc (including
183      * the terminating null character) to the end of the string pointed to by strDest.
184      * Parameter: strDest - destination  address
185      * Parameter: destMax - The maximum length of destination buffer(including the terminating null wide character)
186      * Parameter: strSrc - source  address
187      * Return:    EOK if there was no runtime-constraint violation
188      */
189     SECUREC_API errno_t strcat_s(char *strDest, size_t destMax, const char *strSrc);
190 #endif
191 
192 #if SECUREC_ENABLE_STRNCAT
193     /*
194      * Description: The strncat_s function appends not more than n successive  characters (not including
195      * the terminating null  character)
196      * from the array pointed to by strSrc to the end of the  string pointed to by strDest.
197      * Parameter: strDest - destination  address
198      * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
199      * Parameter: strSrc - source  address
200      * Parameter: count - copies count  characters from the  src
201      * Return:    EOK if there was no runtime-constraint violation
202      */
203     SECUREC_API errno_t strncat_s(char *strDest, size_t destMax, const char *strSrc, size_t count);
204 #endif
205 
206 #if SECUREC_ENABLE_VSPRINTF
207     /*
208      * Description:  The vsprintf_s function is equivalent to the vsprintf function except for the parameter destMax
209      * and the explicit runtime-constraints violation
210      * Parameter: strDest -  produce output according to a format ,write to the character string strDest.
211      * Parameter: destMax - The maximum length of destination buffer(including the terminating null wide characte)
212      * Parameter: format - fromat string
213      * Parameter: argList - instead of  a variable  number of arguments
214      * Return:    the number of characters printed(not including the terminating null byte '\0'),
215      * If an error occurred Return: -1.
216      */
217     SECUREC_API int vsprintf_s(char *strDest, size_t destMax, const char *format,
218                                va_list argList) SECUREC_ATTRIBUTE(3, 0);
219 #endif
220 
221 #if SECUREC_ENABLE_SPRINTF
222     /*
223      * Description:  The sprintf_s function is equivalent to the sprintf function except for the parameter destMax
224      * and the explicit runtime-constraints violation
225      * Parameter: strDest -  produce output according to a format ,write to the character string strDest.
226      * Parameter: destMax - The maximum length of destination buffer(including the terminating null byte '\0')
227      * Parameter: format - fromat string
228      * Return:    the number of characters printed(not including the terminating null byte '\0'),
229      * If an error occurred Return: -1.
230      */
231     SECUREC_API int sprintf_s(char *strDest, size_t destMax, const char *format, ...) SECUREC_ATTRIBUTE(3, 4);
232 #endif
233 
234 #if SECUREC_ENABLE_VSNPRINTF
235     /*
236      * Description:  The vsnprintf_s function is equivalent to the vsnprintf function except for
237      * the parameter destMax/count and the explicit runtime-constraints violation
238      * Parameter: strDest -  produce output according to a format ,write to the character string strDest.
239      * Parameter: destMax - The maximum length of destination buffer(including the terminating null  byte '\0')
240      * Parameter: count - do not write more than count bytes to strDest(not including the terminating null  byte '\0')
241      * Parameter: format - fromat string
242      * Parameter: argList - instead of  a variable  number of arguments
243      * Return:    the number of characters printed(not including the terminating null byte '\0'),
244      * If an error occurred Return: -1.Pay special attention to returning -1 when truncation occurs
245      */
246     SECUREC_API int vsnprintf_s(char *strDest, size_t destMax, size_t count, const char *format,
247                                 va_list argList) SECUREC_ATTRIBUTE(4, 0);
248 #endif
249 
250 #if SECUREC_ENABLE_SNPRINTF
251     /*
252      * Description:  The snprintf_s function is equivalent to the snprintf function except for
253      * the parameter destMax/count and the explicit runtime-constraints violation
254      * Parameter: strDest - produce output according to a format ,write to the character string strDest.
255      * Parameter: destMax - The maximum length of destination buffer(including the terminating null  byte '\0')
256      * Parameter: count - do not write more than count bytes to strDest(not including the terminating null  byte '\0')
257      * Parameter: format - fromat string
258      * Return:    the number of characters printed(not including the terminating null byte '\0'),
259      * If an error occurred Return: -1.Pay special attention to returning -1 when truncation occurs
260      */
261     SECUREC_API int snprintf_s(char *strDest, size_t destMax, size_t count, const char *format,
262                                ...) SECUREC_ATTRIBUTE(4, 5);
263 #endif
264 
265 #if SECUREC_SNPRINTF_TRUNCATED
266     /*
267      * Description:  The vsnprintf_truncated_s function is equivalent to the vsnprintf_s function except
268      * no count parameter and return value
269      * Parameter: strDest -  produce output according to a format ,write to the character string strDest
270      * Parameter: destMax - The maximum length of destination buffer(including the terminating null  byte '\0')
271      * Parameter: format - fromat string
272      * Parameter: argList - instead of  a variable  number of arguments
273      * Return:    the number of characters printed(not including the terminating null byte '\0'),
274      * If an error occurred Return: -1.Pay special attention to returning destMax - 1 when truncation occurs
275      */
276     SECUREC_API int vsnprintf_truncated_s(char *strDest, size_t destMax, const char *format,
277                                           va_list argList) SECUREC_ATTRIBUTE(3, 0);
278 
279     /*
280      * Description:  The snprintf_truncated_s function is equivalent to the snprintf_2 function except
281      * no count parameter and return value
282      * Parameter: strDest -  produce output according to a format ,write to the character string strDest.
283      * Parameter: destMax - The maximum length of destination buffer(including the terminating null  byte '\0')
284      * Parameter: format - fromat string
285      * Return:    the number of characters printed(not including the terminating null byte '\0'),
286      * If an error occurred Return: -1.Pay special attention to returning destMax - 1 when truncation occurs
287      */
288     SECUREC_API int snprintf_truncated_s(char *strDest, size_t destMax,
289                                          const char *format, ...) SECUREC_ATTRIBUTE(3, 4);
290 #endif
291 
292 #if SECUREC_ENABLE_SCANF
293     /*
294      * Description:  The scanf_s function is equivalent to fscanf_s with the argument stdin
295      * interposed before the arguments to scanf_s
296      * Parameter: format - fromat string
297      * Return:   the number of input items assigned, If an error occurred Return: -1.
298      */
299     SECUREC_API int scanf_s(const char *format, ...);
300 #endif
301 
302 #if SECUREC_ENABLE_VSCANF
303     /*
304      * Description: The vscanf_s function is equivalent to scanf_s, with the variable argument list replaced by argList
305      * Parameter: format - fromat string
306      * Parameter: argList - instead of  a variable  number of arguments
307      * Return:    the number of input items assigned, If an error occurred Return: -1.
308      */
309     SECUREC_API int vscanf_s(const char *format, va_list argList);
310 #endif
311 
312 #if SECUREC_ENABLE_SSCANF
313     /*
314      * Description:  The sscanf_s function is equivalent to fscanf_s, except that input is obtained from a
315      * string (specified by the argument buffer) rather than from a stream
316      * Parameter: buffer -  read character from  buffer
317      * Parameter: format - fromat string
318      * Return:    the number of input items assigned, If an error occurred Return: -1.
319      */
320     SECUREC_API int sscanf_s(const char *buffer, const char *format, ...);
321 #endif
322 
323 #if SECUREC_ENABLE_VSSCANF
324     /*
325      * Description:  The vsscanf_s function is equivalent to sscanf_s, with the variable argument list
326      * replaced by argList
327      * Parameter: buffer -  read character from  buffer
328      * Parameter: format - fromat string
329      * Parameter: argList - instead of  a variable  number of arguments
330      * Return:    the number of input items assigned, If an error occurred Return: -1.
331      */
332     SECUREC_API int vsscanf_s(const char *buffer, const char *format, va_list argList);
333 #endif
334 
335 #if SECUREC_ENABLE_FSCANF
336     /*
337      * Description:  The fscanf_s function is equivalent to fscanf except that the c, s, and [ conversion specifiers
338      * apply to a pair of arguments (unless assignment suppression is indicated by a*)
339      * Parameter: stream - stdio file stream
340      * Parameter: format - fromat string
341      * Return:    the number of input items assigned, If an error occurred Return: -1.
342      */
343     SECUREC_API int fscanf_s(FILE *stream, const char *format, ...);
344 #endif
345 
346 #if SECUREC_ENABLE_VFSCANF
347     /*
348      * Description:  The vfscanf_s function is equivalent to fscanf_s, with the variable argument list
349      * replaced by argList
350      * Parameter: stream - stdio file stream
351      * Parameter: format - fromat string
352      * Parameter: argList - instead of  a variable  number of arguments
353      * Return:    the number of input items assigned, If an error occurred Return: -1.
354      */
355     SECUREC_API int vfscanf_s(FILE *stream, const char *format, va_list argList);
356 #endif
357 
358 #if SECUREC_ENABLE_STRTOK
359     /*
360      * Description:  The strtok_s function parses a string into a sequence of strToken,
361      * replace all characters in strToken string that match to strDelimit set with 0.
362      * On the first call to strtok_s the string to be parsed should be specified in strToken.
363      * In each subsequent call that should parse the same string, strToken should be NULL
364      * Parameter: strToken - the string to be delimited
365      * Parameter: strDelimit - specifies a set of characters that delimit the tokens in the parsed string
366      * Parameter: context - is a pointer to a char * variable that is used internally by strtok_s function
367      * Return:  On the first call returns the address of the first non \0 character, otherwise NULL is returned.
368      * In subsequent calls, the strtoken is set to NULL, and the context set is the same as the previous call,
369      * return NULL if the *context string length is equal 0, otherwise return *context.
370      */
371     SECUREC_API char *strtok_s(char *strToken, const char *strDelimit, char **context);
372 #endif
373 
374 #if SECUREC_ENABLE_GETS && SECUREC_IN_KERNEL == 0
375     /*
376      * Description: The gets_s function reads at most one less than the number of characters specified
377      * by destMax from the stream pointed to by stdin, into the array pointed to by buffer
378      * Parameter: buffer - destination  address
379      * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
380      * Return:    buffer if there was no runtime-constraint violation,If an error occurred Return: NULL.
381      */
382     SECUREC_API char *gets_s(char *buffer, size_t destMax);
383 #endif
384 
385 
386 #if SECUREC_ENABLE_WCHAR_FUNC
387 #if SECUREC_ENABLE_MEMCPY
388     /*
389      * Description: The wmemcpy_s function copies n successive wide characters from the object pointed to
390      * by src into the object pointed to by dest.
391      * Parameter: dest - destination  address
392      * Parameter: destMax - The maximum length of destination buffer
393      * Parameter: src - source  address
394      * Parameter: count - copies count wide characters from the  src
395      * Return:    EOK if there was no runtime-constraint violation
396      */
397     SECUREC_API errno_t wmemcpy_s(wchar_t *dest, size_t destMax, const wchar_t *src, size_t count);
398 #endif
399 
400 #if SECUREC_ENABLE_MEMMOVE
401     /*
402      * Description: The wmemmove_s function copies n successive wide characters from the object
403      * pointed to by src into the object pointed to by dest.
404      * Parameter: dest - destination  address
405      * Parameter: destMax - The maximum length of destination buffer
406      * Parameter: src - source  address
407      * Parameter: count - copies count wide characters from the  src
408      * Return:    EOK if there was no runtime-constraint violation
409      */
410     SECUREC_API errno_t wmemmove_s(wchar_t *dest, size_t destMax, const wchar_t *src, size_t count);
411 #endif
412 
413 #if SECUREC_ENABLE_STRCPY
414     /*
415      * Description: The wcscpy_s function copies the wide string pointed to by strSrc (including theterminating
416      * null wide character) into the array pointed to by strDest
417      * Parameter: strDest - destination  address
418      * Parameter: destMax - The maximum length of destination buffer
419      * Parameter: strSrc - source  address
420      * Return:    EOK if there was no runtime-constraint violation
421      */
422     SECUREC_API errno_t wcscpy_s(wchar_t *strDest, size_t destMax, const wchar_t *strSrc);
423 #endif
424 
425 #if SECUREC_ENABLE_STRNCPY
426     /*
427      * Description: The wcsncpy_s function copies not more than n successive wide characters (not including the
428      * terminating null wide character) from the array pointed to by strSrc to the array pointed to by strDest
429      * Parameter: strDest - destination  address
430      * Parameter: destMax - The maximum length of destination buffer(including the terminating wide character)
431      * Parameter: strSrc - source  address
432      * Parameter: count - copies count wide characters from the  src
433      * Return:    EOK if there was no runtime-constraint violation
434      */
435     SECUREC_API errno_t wcsncpy_s(wchar_t *strDest, size_t destMax, const wchar_t *strSrc, size_t count);
436 #endif
437 
438 #if SECUREC_ENABLE_STRCAT
439     /*
440      * Description: The wcscat_s function appends a copy of the wide string pointed to by strSrc (including the
441      * terminating null wide character) to the end of the wide string pointed to by strDest
442      * Parameter: strDest - destination  address
443      * Parameter: destMax - The maximum length of destination buffer(including the terminating wide character)
444      * Parameter: strSrc - source  address
445      * Return:    EOK if there was no runtime-constraint violation
446      */
447     SECUREC_API errno_t wcscat_s(wchar_t *strDest, size_t destMax, const wchar_t *strSrc);
448 #endif
449 
450 #if SECUREC_ENABLE_STRNCAT
451     /*
452      * Description: The wcsncat_s function appends not more than n successive wide characters (not including the
453      * terminating null wide character) from the array pointed to by strSrc to the end of the wide string pointed to
454      * by strDest.
455      * Parameter: strDest - destination  address
456      * Parameter: destMax - The maximum length of destination buffer(including the terminating wide character)
457      * Parameter: strSrc - source  address
458      * Parameter: count - copies count wide characters from the  src
459      * Return:    EOK if there was no runtime-constraint violation
460      */
461     SECUREC_API errno_t wcsncat_s(wchar_t *strDest, size_t destMax, const wchar_t *strSrc, size_t count);
462 #endif
463 
464 #if SECUREC_ENABLE_STRTOK
465     /*
466      * Description:  The  wcstok_s  function  is  the  wide-character  equivalent  of the strtok_s function
467      * Parameter: strToken - the string to be delimited
468      * Parameter: strDelimit - specifies a set of characters that delimit the tokens in the parsed string
469      * Parameter: context - is a pointer to a char * variable that is used internally by strtok_s function
470      * Return:    a pointer to the first character of a token, or a null pointer if there is no token
471      * or there is a runtime-constraint violation.
472      */
473     SECUREC_API wchar_t *wcstok_s(wchar_t *strToken, const wchar_t *strDelimit, wchar_t **context);
474 #endif
475 
476 #if SECUREC_ENABLE_VSPRINTF
477     /*
478      * Description:  The  vswprintf_s  function  is  the  wide-character  equivalent  of the vsprintf_s function
479      * Parameter: strDest -  produce output according to a format ,write to the character string strDest
480      * Parameter: destMax - The maximum length of destination buffer(including the terminating null )
481      * Parameter: format - fromat string
482      * Parameter: argList - instead of  a variable  number of arguments
483      * Return:    the number of characters printed(not including the terminating null wide characte),
484      * If an error occurred Return: -1.
485      */
486     SECUREC_API int vswprintf_s(wchar_t *strDest, size_t destMax, const wchar_t *format, va_list argList);
487 #endif
488 
489 #if SECUREC_ENABLE_SPRINTF
490 
491     /*
492      * Description:  The  swprintf_s  function  is  the  wide-character  equivalent  of the sprintf_s function
493      * Parameter: strDest -  produce output according to a format ,write to the character string strDest
494      * Parameter: destMax - The maximum length of destination buffer(including the terminating null )
495      * Parameter: format - fromat string
496      * Return:    the number of characters printed(not including the terminating null wide characte),
497      * If an error occurred Return: -1.
498      */
499     SECUREC_API int swprintf_s(wchar_t *strDest, size_t destMax, const wchar_t *format, ...);
500 #endif
501 
502 #if SECUREC_ENABLE_FSCANF
503     /*
504      * Description:  The  fwscanf_s  function  is  the  wide-character  equivalent  of the fscanf_s function
505      * Parameter: stream - stdio file stream
506      * Parameter: format - fromat string
507      * Return:    the number of input items assigned, If an error occurred Return: -1.
508      */
509     SECUREC_API int fwscanf_s(FILE *stream, const wchar_t *format, ...);
510 #endif
511 
512 #if SECUREC_ENABLE_VFSCANF
513     /*
514      * Description:  The  vfwscanf_s  function  is  the  wide-character  equivalent  of the vfscanf_s function
515      * Parameter: stream - stdio file stream
516      * Parameter: format - fromat string
517      * Parameter: argList - instead of  a variable  number of arguments
518      * Return:    the number of input items assigned, If an error occurred Return: -1.
519      */
520     SECUREC_API int vfwscanf_s(FILE *stream, const wchar_t *format, va_list argList);
521 #endif
522 
523 #if SECUREC_ENABLE_SCANF
524     /*
525      * Description:  The  wscanf_s  function  is  the  wide-character  equivalent  of the scanf_s function
526      * Parameter: format - fromat string
527      * Return:    the number of input items assigned, If an error occurred Return: -1.
528      */
529     SECUREC_API int wscanf_s(const wchar_t *format, ...);
530 #endif
531 
532 #if SECUREC_ENABLE_VSCANF
533     /*
534      * Description:  The  vwscanf_s  function  is  the  wide-character  equivalent  of the vscanf_s function
535      * Parameter: format - fromat string
536      * Parameter: argList - instead of  a variable  number of arguments
537      * Return:    the number of input items assigned, If an error occurred Return: -1.
538      */
539     SECUREC_API int vwscanf_s(const wchar_t *format, va_list argList);
540 #endif
541 
542 #if SECUREC_ENABLE_SSCANF
543     /*
544      * Description:  The  swscanf_s  function  is  the  wide-character  equivalent  of the sscanf_s function
545      * Parameter: buffer -  read character from  buffer
546      * Parameter: format - fromat string
547      * Return:    the number of input items assigned, If an error occurred Return: -1.
548      */
549     SECUREC_API int swscanf_s(const wchar_t *buffer, const wchar_t *format, ...);
550 #endif
551 
552 #if SECUREC_ENABLE_VSSCANF
553     /*
554      * Description:  The  vswscanf_s  function  is  the  wide-character  equivalent  of the vsscanf_s function
555      * Parameter: buffer -  read character from  buffer
556      * Parameter: format - fromat string
557      * Parameter: argList - instead of  a variable  number of arguments
558      * Return:    the number of input items assigned, If an error occurred Return: -1.
559      */
560     SECUREC_API int vswscanf_s(const wchar_t *buffer, const wchar_t *format, va_list argList);
561 #endif
562 #endif /* SECUREC_ENABLE_WCHAR_FUNC */
563 #endif
564 
565     /* Those functions are used by macro ,must declare hare , also for  without function declaration warning */
566     extern errno_t strncpy_error(char *strDest, size_t destMax, const char *strSrc, size_t count);
567     extern errno_t strcpy_error(char *strDest, size_t destMax, const char *strSrc);
568 
569 #if SECUREC_WITH_PERFORMANCE_ADDONS
570     /* Those functions are used by macro */
571     extern errno_t memset_sOptAsm(void *dest, size_t destMax, int c, size_t count);
572     extern errno_t memset_sOptTc(void *dest, size_t destMax, int c, size_t count);
573     extern errno_t memcpy_sOptAsm(void *dest, size_t destMax, const void *src, size_t count);
574     extern errno_t memcpy_sOptTc(void *dest, size_t destMax, const void *src, size_t count);
575 
576 /* The strcpy_sp is a macro, not a function in performance optimization mode. */
577 #define strcpy_sp(dest, destMax, src)  ((__builtin_constant_p((destMax)) && \
578     __builtin_constant_p((src))) ?  \
579     SECUREC_STRCPY_SM((dest), (destMax), (src)) : \
580     strcpy_s((dest), (destMax), (src)))
581 
582 /* The strncpy_sp is a macro, not a function in performance optimization mode. */
583 #define strncpy_sp(dest, destMax, src, count)  ((__builtin_constant_p((count)) && \
584     __builtin_constant_p((destMax)) && \
585     __builtin_constant_p((src))) ?  \
586     SECUREC_STRNCPY_SM((dest), (destMax), (src), (count)) : \
587     strncpy_s((dest), (destMax), (src), (count)))
588 
589 /* The strcat_sp is a macro, not a function in performance optimization mode. */
590 #define strcat_sp(dest, destMax, src) ((__builtin_constant_p((destMax)) && \
591     __builtin_constant_p((src))) ?  \
592     SECUREC_STRCAT_SM((dest), (destMax), (src)) : \
593     strcat_s((dest), (destMax), (src)))
594 
595 /* The strncat_sp is a macro, not a function in performance optimization mode. */
596 #define strncat_sp(dest, destMax, src, count) ((__builtin_constant_p((count)) &&  \
597     __builtin_constant_p((destMax)) && \
598     __builtin_constant_p((src))) ?  \
599     SECUREC_STRNCAT_SM((dest), (destMax), (src), (count)) : \
600     strncat_s((dest), (destMax), (src), (count)))
601 
602 /* The memcpy_sp is a macro, not a function in performance optimization mode. */
603 #define memcpy_sp(dest, destMax, src, count)  (__builtin_constant_p((count)) ? \
604     (SECUREC_MEMCPY_SM((dest), (destMax), (src), (count))) : \
605     (__builtin_constant_p((destMax)) ? \
606     (((size_t)(destMax) > 0 && \
607     (((unsigned long long)(destMax) & (unsigned long long)(-2)) < SECUREC_MEM_MAX_LEN)) ? \
608     memcpy_sOptTc((dest), (destMax), (src), (count)) : ERANGE) : \
609     memcpy_sOptAsm((dest), (destMax), (src), (count))))
610 
611 /* The memset_sp is a macro, not a function in performance optimization mode. */
612 #define memset_sp(dest, destMax, c, count)  (__builtin_constant_p((count)) ? \
613     (SECUREC_MEMSET_SM((dest), (destMax), (c), (count))) : \
614     (__builtin_constant_p((destMax)) ? \
615     (((((unsigned long long)(destMax) & (unsigned long long)(-2)) < SECUREC_MEM_MAX_LEN)) ? \
616     memset_sOptTc((dest), (destMax), (c), (count)) : ERANGE) : \
617     memset_sOptAsm((dest), (destMax), (c), (count))))
618 #else
619 #define strcpy_sp   strcpy_s
620 #define strncpy_sp  strncpy_s
621 #define strcat_sp   strcat_s
622 #define strncat_sp  strncat_s
623 #define memcpy_sp   memcpy_s
624 #define memset_sp   memset_s
625 #endif
626 
627 #ifdef __cplusplus
628 }
629 #endif /* __cplusplus */
630 #endif /* __SECUREC_H__5D13A042_DC3F_4ED9_A8D1_882811274C27 */
631 
632