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: wscanf_s function
12 * Create: 2014-02-25
13 */
14
15 #include "securec.h"
16
17 /*
18 * <NAME>
19 * <FUNCTION DESCRIPTION>
20 * The wscanf_s function is the wide-character equivalent of the scanf_s function
21 * The wscanf_s function reads data from the standard input stream stdin and
22 * writes the data into the location that's given by argument. Each argument
23 * must be a pointer to a variable of a type that corresponds to a type specifier
24 * in format. If copying occurs between strings that overlap, the behavior is
25 * undefined.
26 *
27 * <INPUT PARAMETERS>
28 * format Format control string.
29 * ... Optional arguments.
30 *
31 * <OUTPUT PARAMETERS>
32 * ... the converted value stored in user assigned address
33 *
34 * <RETURN VALUE>
35 * Returns the number of fields successfully converted and assigned;
36 * the return value does not include fields that were read but not assigned.
37 * A return value of 0 indicates that no fields were assigned.
38 * return -1 if an error occurs.
39 */
wscanf_s(const wchar_t * format,...)40 int wscanf_s(const wchar_t *format, ...)
41 {
42 int ret; /* If initialization causes e838 */
43 va_list argList;
44
45 va_start(argList, format);
46 ret = vwscanf_s(format, argList);
47 va_end(argList);
48 (void)argList; /* To clear e438 last value assigned not used , the compiler will optimize this code */
49
50 return ret;
51 }
52
53