• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
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  *******************************************************************************
37  */
38 #ifndef __MINGW32__
swprintf_s(wchar_t * strDest,size_t destMax,const wchar_t * format,...)39 int swprintf_s(wchar_t *strDest, size_t destMax, const wchar_t *format, ...)
40 {
41     int ret;                    /* If initialization causes  e838 */
42     va_list arglist;
43 
44     va_start(arglist, format);
45     ret = vswprintf_s(strDest, destMax, format, arglist);
46     va_end(arglist);
47     (void)arglist;              /* to clear e438 last value assigned not used , the compiler will optimize this code */
48 
49     return ret;
50 }
51 #endif
52 
53