RDK Documentation (Open Sourced RDK Components)
rdk_safeclib.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 #ifndef RDK_SAFECLIB_H_
20 #define RDK_SAFECLIB_H_
21 
22 #ifndef SAFEC_DUMMY_API
23 #include "safe_str_lib.h"
24 #include "safe_mem_lib.h"
25 #endif
26 
27 #define RDK_SAFECLIB_ERR(rc) printf("safeclib error at %s %s:%d rc = %d", __FILE__, __FUNCTION__, __LINE__, rc)
28 
29 #define ERR_CHK(rc) \
30  if(rc !=EOK) { \
31  RDK_SAFECLIB_ERR(rc); \
32  }
33 
34 #ifdef SAFEC_DUMMY_API
35 typedef int errno_t;
36 #define EOK 0
37 
38 #define strcpy_s(dst,max,src) EOK; \
39  strcpy(dst,src);
40 #define strncpy_s(dst,max,src,len) EOK; \
41  strncpy(dst,src,len);
42 #define memset_s(dst,max_1,c,max) EOK; \
43  memset(dst,c,max);
44 
45 errno_t strcmp_s(const char *,int,const char *,int *);
46 #endif
47 
48 #endif /* RDK_SAFECLIB_H_ */
49