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.

swscanf_s.c 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 swscanf_s function is the wide-character equivalent of the sscanf_s function
  20. * The swscanf_s function reads data from buffer into the location given by
  21. * each argument. Every argument must be a pointer to a variable with a type
  22. * that corresponds to a type specifier in format. The format argument controls
  23. * the interpretation of the input fields and has the same form and function
  24. * as the format argument for the scanf function. If copying takes place between
  25. * strings that overlap, the behavior is undefined.
  26. *
  27. * <INPUT PARAMETERS>
  28. * buffer Stored data.
  29. * format Format control string, see Format Specifications.
  30. * ... Optional arguments.
  31. *
  32. * <OUTPUT PARAMETERS>
  33. * ... the converted 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 not
  38. * assigned.
  39. * A return value of 0 indicates that no fields were assigned.
  40. * return -1 if an error occurs.
  41. */
  42. int swscanf_s(const wchar_t *buffer, const wchar_t *format, ...)
  43. {
  44. int ret; /* If initialization causes e838 */
  45. va_list argList;
  46. va_start(argList, format);
  47. ret = vswscanf_s(buffer, format, argList);
  48. va_end(argList);
  49. (void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
  50. return ret;
  51. }