• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * <FUNCTION DESCRIPTION>
20  *    The  swscanf_s  function  is  the  wide-character  equivalent  of the sscanf_s function
21  *    The swscanf_s function reads data from buffer into the location given by
22  *    each argument. Every argument must be a pointer to a variable with a type
23  *    that corresponds to a type specifier in format. The format argument controls
24  *    the interpretation of the input fields and has the same form and function
25  *    as the format argument for the scanf function. If copying takes place between
26  *    strings that overlap, the behavior is undefined.
27  *
28  * <INPUT PARAMETERS>
29  *    buffer                 Stored data.
30  *    format                 Format control string, see Format Specifications.
31  *    ...                    Optional arguments.
32  *
33  * <OUTPUT PARAMETERS>
34  *    ...                    the converted value stored in user assigned address
35  *
36  * <RETURN VALUE>
37  *    Each of these functions returns the number of fields successfully converted
38  *    and assigned; The return value does not include fields that were read but not
39  *    assigned.
40  *    A return value of 0 indicates that no fields were assigned.
41  *    return -1 if an error occurs.
42  *******************************************************************************
43  */
44 #ifndef __MINGW32__
swscanf_s(const wchar_t * buffer,const wchar_t * format,...)45 int swscanf_s(const wchar_t *buffer, const wchar_t *format, ...)
46 {
47     int ret;                    /* If initialization causes  e838 */
48     va_list arglist;
49 
50     va_start(arglist, format);
51     ret = vswscanf_s(buffer, format, arglist);
52     va_end(arglist);
53     (void)arglist;              /* to clear e438 last value assigned not used , the compiler will optimize this code */
54 
55     return ret;
56 }
57 #endif
58 
59