13d58139fSopenharmony_ci/* 23d58139fSopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. All rights reserved. 33d58139fSopenharmony_ci * Licensed under Mulan PSL v2. 43d58139fSopenharmony_ci * You can use this software according to the terms and conditions of the Mulan PSL v2. 53d58139fSopenharmony_ci * You may obtain a copy of Mulan PSL v2 at: 63d58139fSopenharmony_ci * http://license.coscl.org.cn/MulanPSL2 73d58139fSopenharmony_ci * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 83d58139fSopenharmony_ci * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 93d58139fSopenharmony_ci * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 103d58139fSopenharmony_ci * See the Mulan PSL v2 for more details. 113d58139fSopenharmony_ci * Description: Provides internal functions used by this library, such as memory 123d58139fSopenharmony_ci * copy and memory move. Besides, include some helper function for 133d58139fSopenharmony_ci * printf family API, such as SecVsnprintfImpl 143d58139fSopenharmony_ci * Create: 2014-02-25 153d58139fSopenharmony_ci */ 163d58139fSopenharmony_ci 173d58139fSopenharmony_ci/* Avoid duplicate header files,not include securecutil.h */ 183d58139fSopenharmony_ci#include "securecutil.h" 193d58139fSopenharmony_ci 203d58139fSopenharmony_ci#if defined(ANDROID) && !defined(SECUREC_CLOSE_ANDROID_HANDLE) && (SECUREC_HAVE_WCTOMB || SECUREC_HAVE_MBTOWC) 213d58139fSopenharmony_ci#include <wchar.h> 223d58139fSopenharmony_ci#if SECUREC_HAVE_WCTOMB 233d58139fSopenharmony_ci/* 243d58139fSopenharmony_ci * Convert wide characters to narrow multi-bytes 253d58139fSopenharmony_ci */ 263d58139fSopenharmony_ciint wctomb(char *s, wchar_t wc) 273d58139fSopenharmony_ci{ 283d58139fSopenharmony_ci return (int)wcrtomb(s, wc, NULL); 293d58139fSopenharmony_ci} 303d58139fSopenharmony_ci#endif 313d58139fSopenharmony_ci 323d58139fSopenharmony_ci#if SECUREC_HAVE_MBTOWC 333d58139fSopenharmony_ci/* 343d58139fSopenharmony_ci * Converting narrow multi-byte characters to wide characters 353d58139fSopenharmony_ci * mbrtowc returns -1 or -2 upon failure, unlike mbtowc, which only returns -1 363d58139fSopenharmony_ci * When the return value is less than zero, we treat it as a failure 373d58139fSopenharmony_ci */ 383d58139fSopenharmony_ciint mbtowc(wchar_t *pwc, const char *s, size_t n) 393d58139fSopenharmony_ci{ 403d58139fSopenharmony_ci return (int)mbrtowc(pwc, s, n, NULL); 413d58139fSopenharmony_ci} 423d58139fSopenharmony_ci#endif 433d58139fSopenharmony_ci#endif 443d58139fSopenharmony_ci 453d58139fSopenharmony_ci/* The V100R001C01 version num is 0x5 (High 8 bits) */ 463d58139fSopenharmony_ci#define SECUREC_C_VERSION 0x500U 473d58139fSopenharmony_ci#define SECUREC_SPC_VERSION 0x10U 483d58139fSopenharmony_ci#define SECUREC_VERSION_STR "1.1.16" 493d58139fSopenharmony_ci 503d58139fSopenharmony_ci/* 513d58139fSopenharmony_ci * Get version string and version number. 523d58139fSopenharmony_ci * The rules for version number are as follows: 533d58139fSopenharmony_ci * 1) SPC verNumber<->verStr like: 543d58139fSopenharmony_ci * 0x201<->C01 553d58139fSopenharmony_ci * 0x202<->C01SPC001 Redefine numbers after this version 563d58139fSopenharmony_ci * 0x502<->C01SPC002 573d58139fSopenharmony_ci * 0x503<->C01SPC003 583d58139fSopenharmony_ci * ... 593d58139fSopenharmony_ci * 0X50a<->SPC010 603d58139fSopenharmony_ci * 0X50b<->SPC011 613d58139fSopenharmony_ci * ... 623d58139fSopenharmony_ci * 0x700<->C02 633d58139fSopenharmony_ci * 0x701<->C01SPC001 643d58139fSopenharmony_ci * 0x702<->C02SPC002 653d58139fSopenharmony_ci * ... 663d58139fSopenharmony_ci * 2) CP verNumber<->verStr like: 673d58139fSopenharmony_ci * 0X601<->CP0001 683d58139fSopenharmony_ci * 0X602<->CP0002 693d58139fSopenharmony_ci * ... 703d58139fSopenharmony_ci */ 713d58139fSopenharmony_ciconst char *GetHwSecureCVersion(unsigned short *verNumber) 723d58139fSopenharmony_ci{ 733d58139fSopenharmony_ci if (verNumber != NULL) { 743d58139fSopenharmony_ci *verNumber = (unsigned short)(SECUREC_C_VERSION | SECUREC_SPC_VERSION); 753d58139fSopenharmony_ci } 763d58139fSopenharmony_ci return SECUREC_VERSION_STR; 773d58139fSopenharmony_ci} 783d58139fSopenharmony_ci#if SECUREC_EXPORT_KERNEL_SYMBOL 793d58139fSopenharmony_ciEXPORT_SYMBOL(GetHwSecureCVersion); 803d58139fSopenharmony_ci#endif 813d58139fSopenharmony_ci 82