1 /**
2 * Copyright 2020 Huawei Technologies Co., Ltd
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "securec.h"
18
19 /*
20 * <FUNCTION DESCRIPTION>
21 * The swscanf_s function is the wide-character equivalent of the sscanf_s function
22 * The swscanf_s function reads data from buffer into the location given by
23 * each argument. Every argument must be a pointer to a variable with a type
24 * that corresponds to a type specifier in format. The format argument controls
25 * the interpretation of the input fields and has the same form and function
26 * as the format argument for the scanf function. If copying takes place between
27 * strings that overlap, the behavior is undefined.
28 *
29 * <INPUT PARAMETERS>
30 * buffer Stored data.
31 * format Format control string, see Format Specifications.
32 * ... Optional arguments.
33 *
34 * <OUTPUT PARAMETERS>
35 * ... the converted value stored in user assigned address
36 *
37 * <RETURN VALUE>
38 * Each of these functions returns the number of fields successfully converted
39 * and assigned; The return value does not include fields that were read but not
40 * assigned.
41 * A return value of 0 indicates that no fields were assigned.
42 * return -1 if an error occurs.
43 */
swscanf_s(const wchar_t * buffer,const wchar_t * format,...)44 int swscanf_s(const wchar_t *buffer, const wchar_t *format, ...)
45 {
46 int ret; /* If initialization causes e838 */
47 va_list argList;
48
49 va_start(argList, format);
50 ret = vswscanf_s(buffer, format, argList);
51 va_end(argList);
52 (void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
53
54 return ret;
55 }
56
57
58