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