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.

swprintf_s.c 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 swprintf_s function is the wide-character equivalent of the sprintf_s function
  20. *
  21. * <INPUT PARAMETERS>
  22. * strDest Storage location for the output.
  23. * destMax Maximum number of characters to store.
  24. * format Format-control string.
  25. * ... Optional arguments
  26. *
  27. * <OUTPUT PARAMETERS>
  28. * strDest is updated
  29. *
  30. * <RETURN VALUE>
  31. * return the number of wide characters stored in strDest, not counting the terminating null wide character.
  32. * return -1 if an error occurred.
  33. *
  34. * If there is a runtime-constraint violation, strDest[0] will be set to the '\0' when strDest and destMax valid
  35. */
  36. int swprintf_s(wchar_t *strDest, size_t destMax, const wchar_t *format, ...)
  37. {
  38. int ret; /* If initialization causes e838 */
  39. va_list argList;
  40. va_start(argList, format);
  41. ret = vswprintf_s(strDest, destMax, format, argList);
  42. va_end(argList);
  43. (void)argList; /* to clear e438 last value assigned not used , the compiler will optimize this code */
  44. return ret;
  45. }