• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 /* Avoid duplicate header files,not include securecutil.h */
18 #include "securecutil.h"
19 
20 
21 #if defined(ANDROID) && (SECUREC_HAVE_WCTOMB || SECUREC_HAVE_MBTOWC)
22 #include <wchar.h>
23 #if SECUREC_HAVE_WCTOMB
24 /*
25  * Convert wide characters to narrow multi-bytes
26  */
27 int wctomb(char *s, wchar_t wc)
28 {
29     return wcrtomb(s, wc, NULL);
30 }
31 #endif
32 
33 #if SECUREC_HAVE_MBTOWC
34 /*
35  * Converting narrow multi-byte characters to wide characters
36  */
37 int mbtowc(wchar_t *pwc, const char *s, size_t n)
38 {
39     return mbrtowc(pwc, s, n, NULL);
40 }
41 #endif
42 #endif
43 
44 /* high Num << 8 | num of SPC Ver */
45 #define SECUREC_C_VERSION     (0x5 << 8)
46 #define SECUREC_SPC_VERSION   7
47 #define SECUREC_VERSION_STR   "Huawei Secure C V100R001C01SPC007B002"
48 
49 /* SPC verNumber<->verStr like:
50  * 0X201<->C01
51  * 0X202<->SPC001   Redefine numbers after this version
52  * 0X502<->SPC002
53  * 0X503<->SPC003
54  * ...
55  * 0X50a<->SPC010
56  * 0X50b<->SPC011
57  * ...
58  */
59 /* CP  verNumber<->verStr like:
60  * 0X601<->CP0001
61  * 0X602<->CP0002
62  * ...
63  */
64 const char *GetHwSecureCVersion(unsigned short *verNumber)
65 {
66     if (verNumber != NULL) {
67         *verNumber = (unsigned short)(SECUREC_C_VERSION | SECUREC_SPC_VERSION);
68     }
69     return SECUREC_VERSION_STR;
70 }
71 #if SECUREC_IN_KERNEL
72 EXPORT_SYMBOL(GetHwSecureCVersion);
73 #endif
74 
75