39 lib = LoadLibraryEx(path, NULL, 0);
42 LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
46 DWORD error = GetLastError();
55 FARPROC func = GetProcAddress(lib, sym);
57 DWORD error = GetLastError();
65 FARPROC addr = GetProcAddress(lib, sym);
67 DWORD error = GetLastError();
70 return (
void *) (intptr_t) addr;
100 lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
102 lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);
106 const char *dlerr = dlerror();
109 *err = strdup(dlerr);
111 *err = strdup(
"Unknown error");
119 void *func = dlsym(lib, sym);
121 *err = strdup(dlerror());
128 void *addr = dlsym(lib, sym);
130 char *err_str = NULL;
133 if (!(addr = dlsym(lib, sym))) {
134 err_str = (
char *)dlerror();
138 *err = strdup(err_str);
switch_dso_lib_t switch_dso_open(const char *path, int global, char **err)
void switch_dso_destroy(switch_dso_lib_t *lib)
switch_dso_func_t switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err)
SWITCH_BEGIN_EXTERN_C typedef int(* switch_dso_func_t)(void)
void * switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err)
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)