blob: ae51b01732a086118939167ac54e4775204af306 [file] [log] [blame]
hj.shao57aca4a2025-07-17 22:52:58 -07001#include "gsw_log_interface.h"
2
3void *handle = NULL;
4int log_initialized = 0;
5mbtk_log gsw_fun_ptr_log;
6int init_log_func(void)
7{
8 if (log_initialized)
9 return 0;
10
11 handle = dlopen("/lib/libmbtk_lib.so", RTLD_NOW);
12 if (!handle)
13 {
14 syslog(LOG_ERR, "Failed to load library: %s", dlerror());
15 return -1;
16 }
17
18 gsw_fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
19 if (!gsw_fun_ptr_log)
20 {
21 syslog(LOG_ERR, "Cannot load symbol 'mbtk_log': %s", dlerror());
22 dlclose(handle);
23 handle = NULL;
24 return -1;
25 }
26
27 log_initialized = 1;
28 return 0;
29}