1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
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 *******************************************************************************
41 */
42
wscanf_s(const wchar_t * format,...)43 int wscanf_s(const wchar_t *format, ...)
44 {
45 int ret; /* If initialization causes e838 */
46 va_list arglist;
47
48 va_start(arglist, format);
49 ret = vwscanf_s(format, arglist);
50 va_end(arglist);
51 (void)arglist; /* to clear e438 last value assigned not used , the compiler will optimize this code */
52
53 return ret;
54 }
55
56