hj.shao | 57aca4a | 2025-07-17 22:52:58 -0700 | [diff] [blame] | 1 | #include "gsw_log_interface.h" |
| 2 | |
| 3 | void *handle = NULL; |
| 4 | int log_initialized = 0; |
| 5 | mbtk_log gsw_fun_ptr_log; |
| 6 | int 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 | } |