• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2014-2020. 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  * Author: lishunda
13  * Create: 2014-02-25
14  */
15 
16 #include "securec.h"
17 
18 /*
19  * <FUNCTION DESCRIPTION>
20  *   The  swprintf_s  function  is  the  wide-character  equivalent  of the sprintf_s function
21  *
22  * <INPUT PARAMETERS>
23  *    strDest                   Storage location for the output.
24  *    destMax                   Maximum number of characters to store.
25  *    format                    Format-control string.
26  *    ...                        Optional arguments
27  *
28  * <OUTPUT PARAMETERS>
29  *    strDest                    is updated
30  *
31  * <RETURN VALUE>
32  *    return  the number of wide characters stored in strDest, not  counting the terminating null wide character.
33  *    return -1  if an error occurred.
34  *
35  * If there is a runtime-constraint violation, strDest[0] will be set to the '\0' when strDest and destMax valid
36  */
swprintf_s(wchar_t * strDest,size_t destMax,const wchar_t * format,...)37 int swprintf_s(wchar_t *strDest, size_t destMax, const wchar_t *format, ...)
38 {
39     int ret;                    /* If initialization causes  e838 */
40     va_list argList;
41 
42     va_start(argList, format);
43     ret = vswprintf_s(strDest, destMax, format, argList);
44     va_end(argList);
45     (void)argList;              /* To clear e438 last value assigned not used , the compiler will optimize this code */
46 
47     return ret;
48 }
49 
50