RTS API Documentation  1.10.11
Typedefs | Functions | Variables
switch_dso.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void * switch_dso_lib_t
 
typedef void * switch_dso_data_t
 

Functions

void switch_dso_destroy (switch_dso_lib_t *lib)
 
switch_dso_lib_t switch_dso_open (const char *path, int global, char **err)
 
switch_dso_func_t switch_dso_func_sym (switch_dso_lib_t lib, const char *sym, char **err)
 
void * switch_dso_data_sym (switch_dso_lib_t lib, const char *sym, char **err)
 

Variables

SWITCH_BEGIN_EXTERN_C typedef int(* switch_dso_func_t )(void)
 

Typedef Documentation

◆ switch_dso_data_t

typedef void* switch_dso_data_t

Definition at line 33 of file switch_dso.h.

◆ switch_dso_lib_t

typedef void* switch_dso_lib_t

Definition at line 30 of file switch_dso.h.

Function Documentation

◆ switch_dso_data_sym()

void* switch_dso_data_sym ( switch_dso_lib_t  lib,
const char *  sym,
char **  err 
)

Definition at line 132 of file switch_dso.c.

Referenced by switch_loadable_module_load_file().

133 {
134  void *addr = dlsym(lib, sym);
135  if (!addr) {
136  char *err_str = NULL;
137  dlerror();
138 
139  if (!(addr = dlsym(lib, sym))) {
140  err_str = (char *)dlerror();
141  }
142 
143  if (err_str) {
144  *err = strdup(err_str);
145  }
146  }
147  return addr;
148 }

◆ switch_dso_destroy()

void switch_dso_destroy ( switch_dso_lib_t lib)

Definition at line 91 of file switch_dso.c.

Referenced by do_shutdown(), and switch_loadable_module_load_file().

92 {
93  if (lib && *lib) {
94 #ifndef HAVE_FAKE_DLCLOSE
95  dlclose(*lib);
96 #endif
97  *lib = NULL;
98  }
99 }

◆ switch_dso_func_sym()

switch_dso_func_t switch_dso_func_sym ( switch_dso_lib_t  lib,
const char *  sym,
char **  err 
)

Definition at line 123 of file switch_dso.c.

References switch_dso_func_t.

124 {
125  void *func = dlsym(lib, sym);
126  if (!func) {
127  *err = strdup(dlerror());
128  }
129  return (switch_dso_func_t) (intptr_t) func;
130 }
SWITCH_BEGIN_EXTERN_C typedef int(* switch_dso_func_t)(void)
Definition: switch_dso.h:26

◆ switch_dso_open()

switch_dso_lib_t switch_dso_open ( const char *  path,
int  global,
char **  err 
)

Definition at line 101 of file switch_dso.c.

Referenced by switch_loadable_module_load_file().

102 {
103  void *lib;
104 
105  if (global) {
106  lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
107  } else {
108  lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);
109  }
110 
111  if (lib == NULL) {
112  const char *dlerr = dlerror();
113  /* Work around broken uclibc returning NULL on both dlopen() and dlerror() */
114  if (dlerr) {
115  *err = strdup(dlerr);
116  } else {
117  *err = strdup("Unknown error");
118  }
119  }
120  return lib;
121 }
const char *const const char *const path

Variable Documentation

◆ switch_dso_func_t

SWITCH_BEGIN_EXTERN_C typedef int(* switch_dso_func_t) (void)

Definition at line 26 of file switch_dso.h.

Referenced by switch_dso_func_sym().