1 /* 2 * Copyright (C) 2022 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 #ifndef MOCK_NATIVE_INCLUDE_SECURE_SECUREC_H 17 #define MOCK_NATIVE_INCLUDE_SECURE_SECUREC_H 18 19 /* success */ 20 #ifndef EOK 21 #define EOK (0) 22 #endif 23 24 #if SECUREC_SUPPORT_FORMAT_WARNING && !defined(SECUREC_PCLINT) 25 #define SECUREC_ATTRIBUTE(x, y) __attribute__((format(printf, (x), (y)))) 26 #else 27 #define SECUREC_ATTRIBUTE(x, y) 28 #endif 29 30 /* if you need export the function of this library in Win32 dll, use __declspec(dllexport) */ 31 #ifdef SECUREC_IS_DLL_LIBRARY 32 #ifdef SECUREC_DLL_EXPORT 33 #define SECUREC_API __declspec(dllexport) 34 #else 35 #define SECUREC_API __declspec(dllimport) 36 #endif 37 #else 38 /* Standardized function declaration . If a security function is declared in the your code, 39 * it may cause a compilation alarm,Please delete the security function you declared 40 */ 41 #define SECUREC_API extern 42 #endif 43 44 #ifndef errno_t 45 typedef int errno_t; 46 #endif 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 /** 52 * @param dest - destination address 53 * @param destMax -The maximum length of destination buffer 54 * @param c - the value to be copied 55 * @param count -copies first count characters of dest 56 * @return EOK if there was no runtime-constraint violation 57 */ 58 errno_t memset_s(void *dest, size_t destMax, int c, size_t count); 59 60 /** 61 * @param dest - destination address 62 * @param destMax -The maximum length of destination buffer 63 * @param src -source address 64 * @param count -copies count characters from the src 65 * @return EOK if there was no runtime-constraint violation 66 */ 67 errno_t memcpy_s(void *dest, size_t destMax, const void *src, size_t count); 68 69 /** 70 * @param strDest - produce output according to a format ,write to the character string strDest 71 * @param destMax - The maximum length of destination buffer(including the terminating null byte ('\0')) 72 * @param format - format string 73 */ 74 SECUREC_API int sprintf_s(char *strDest, size_t destMax, const char *format, ...) SECUREC_ATTRIBUTE(3, 4); 75 76 #ifdef __cplusplus 77 } 78 #endif /* __cplusplus */ 79 80 #endif // MOCK_NATIVE_INCLUDE_SECURE_SECUREC_H 81