You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fscanf_s.c 2.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #include "securec.h"
  17. /*
  18. * <FUNCTION DESCRIPTION>
  19. * The fscanf_s function is equivalent to fscanf except that the c, s,
  20. * and [ conversion specifiers apply to a pair of arguments (unless assignment suppression is indicated by a*)
  21. * The fscanf function reads data from the current position of stream into
  22. * the locations given by argument (if any). Each argument must be a pointer
  23. * to a variable of a type that corresponds to a type specifier in format.
  24. * format controls the interpretation of the input fields and has the same
  25. * form and function as the format argument for scanf.
  26. *
  27. * <INPUT PARAMETERS>
  28. * stream Pointer to FILE structure.
  29. * format Format control string, see Format Specifications.
  30. * ... Optional arguments.
  31. *
  32. * <OUTPUT PARAMETERS>
  33. * ... The convered value stored in user assigned address
  34. *
  35. * <RETURN VALUE>
  36. * Each of these functions returns the number of fields successfully converted
  37. * and assigned; the return value does not include fields that were read but
  38. * not assigned. A return value of 0 indicates that no fields were assigned.
  39. * return -1 if an error occurs.
  40. */
  41. int fscanf_s(FILE *stream, const char *format, ...)
  42. {
  43. int ret; /* If initialization causes e838 */
  44. va_list argList;
  45. va_start(argList, format);
  46. ret = vfscanf_s(stream, format, argList);
  47. va_end(argList);
  48. (void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
  49. return ret;
  50. }