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.

sscanf_s.c 2.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 sscanf_s function is equivalent to fscanf_s,
  20. * except that input is obtained from a string (specified by the argument buffer) rather than from a stream
  21. * The sscanf function reads data from buffer into the location given by each
  22. * argument. Every argument must be a pointer to a variable with a type that
  23. * corresponds to a type specifier in format. The format argument controls the
  24. * interpretation of the input fields and has the same form and function as
  25. * the format argument for the scanf function.
  26. * If copying takes place between 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
  39. * not assigned.
  40. * A return value of 0 indicates that no fields were assigned.
  41. * return -1 if an error occurs.
  42. */
  43. int sscanf_s(const char *buffer, const char *format, ...)
  44. {
  45. int ret; /* If initialization causes e838 */
  46. va_list argList;
  47. va_start(argList, format);
  48. ret = vsscanf_s(buffer, format, argList);
  49. va_end(argList);
  50. (void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
  51. return ret;
  52. }
  53. #if SECUREC_IN_KERNEL
  54. EXPORT_SYMBOL(sscanf_s);
  55. #endif