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