• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. 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: swprintf_s  function
12  * Create: 2014-02-25
13  */
14 
15 #include "securec.h"
16 
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  */
swprintf_s(wchar_t * strDest,size_t destMax,const wchar_t * format,...)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 
41     va_start(argList, format);
42     ret = vswprintf_s(strDest, destMax, format, argList);
43     va_end(argList);
44     (void)argList;              /* To clear e438 last value assigned not used , the compiler will optimize this code */
45 
46     return ret;
47 }
48 
49