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: fscanf_s function
12 * Author: lishunda
13 * Create: 2014-02-25
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.
27 *
28 * <INPUT PARAMETERS>
29 * stream Pointer to FILE structure.
30 * format Format control string, see Format Specifications.
31 * ... Optional arguments.
32 *
33 * <OUTPUT PARAMETERS>
34 * ... The convered 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
39 * not assigned. A return value of 0 indicates that no fields were assigned.
40 * return -1 if an error occurs.
41 */
fscanf_s(FILE * stream,const char * format,...)42 int fscanf_s(FILE *stream, const char *format, ...)
43 {
44 int ret; /* If initialization causes e838 */
45 va_list argList;
46
47 va_start(argList, format);
48 ret = vfscanf_s(stream, format, argList);
49 va_end(argList);
50 (void)argList; /* To clear e438 last value assigned not used , the compiler will optimize this code */
51
52 return ret;
53 }
54
55