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 fscanf_s function is equivalent to fscanf except that the c, s,
21 * and [ conversion specifiers apply to a pair of arguments (unless assignment suppression is indicated by a*)
22 * The fscanf function reads data from the current position of stream into
23 * the locations given by argument (if any). Each argument must be a pointer
24 * to a variable of a type that corresponds to a type specifier in format.
25 * format controls the interpretation of the input fields and has the same
26 * form and function as the format argument for scanf; see scanf for a
27 * description of format.
28 *
29 * <INPUT PARAMETERS>
30 * stream Pointer to FILE structure.
31 * format Format control string, see Format Specifications.
32 * ... Optional arguments.
33 *
34 * <OUTPUT PARAMETERS>
35 * ... The covered 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
40 * not assigned. A return value of 0 indicates that no fields were assigned.
41 * A return value of -1 indicates an error.
42 *******************************************************************************
43 */
fscanf_s(FILE * stream,const char * format,...)44 int fscanf_s(FILE *stream, const char *format, ...)
45 {
46 int ret; /* If initialization causes e838 */
47 va_list arglist;
48 va_start(arglist, format);
49 ret = vfscanf_s(stream, 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