• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef SAL_DLIMPL_H
17 #define SAL_DLIMPL_H
18 
19 #include "hitls_build.h"
20 #ifdef HITLS_BSL_SAL_DL
21 
22 #include <stdint.h>
23 #include "bsl_sal.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 typedef struct {
30     BslSalLoadLib pfLoadLib;
31     BslSalUnLoadLib pfUnLoadLib;
32     BslSalGetFunc pfGetFunc;
33 } BSL_SAL_DlCallback;
34 
35 int32_t SAL_DlCallback_Ctrl(BSL_SAL_CB_FUNC_TYPE type, void *funcCb);
36 
37 #ifdef HITLS_BSL_SAL_LINUX
38 /**
39  * @brief Load a dynamic library
40  * @param fileName Name of the library file to load
41  * @param handle Pointer to store the handle of the loaded library
42  * @return 0 on success, non-zero error code on failure
43  */
44 int32_t SAL_LoadLib(const char *fileName, void **handle);
45 
46 /**
47  * @brief Unload a previously loaded dynamic library
48  * @param handle Handle of the library to unload
49  * @return 0 on success, non-zero error code on failure
50  */
51 int32_t SAL_UnLoadLib(void *handle);
52 
53 /**
54  * @brief Get a function pointer from a loaded library
55  * @param handle Handle of the loaded library
56  * @param funcName Name of the function to retrieve
57  * @param func Pointer to store the function pointer
58  * @return 0 on success, non-zero error code on failure
59  */
60 int32_t SAL_GetFunc(void *handle, const char *funcName, void **func);
61 #endif
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif /* HITLS_BSL_SAL_DL */
68 #endif // SAL_DLIMPL_H
69