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 int(*) switch_dso_func_t (void)
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)


Typedef Documentation

typedef void* switch_dso_data_t

Definition at line 31 of file switch_dso.h.

typedef int(*) switch_dso_func_t(void)

Definition at line 24 of file switch_dso.h.

typedef void* switch_dso_lib_t

Definition at line 28 of file switch_dso.h.


Function Documentation

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

Definition at line 126 of file switch_dso.c.

Referenced by switch_loadable_module_load_file().

00127 {
00128         void *addr = dlsym(lib, sym);
00129         if (!addr) {
00130                 char *err_str = NULL;
00131                 dlerror();
00132 
00133                 if (!(addr = dlsym(lib, sym))) {
00134                         err_str = (char *)dlerror();
00135                 }
00136 
00137                 if (err_str) {
00138                         *err = strdup(err_str);
00139                 }
00140         }
00141         return addr;
00142 }

void switch_dso_destroy ( switch_dso_lib_t lib  ) 

Definition at line 87 of file switch_dso.c.

Referenced by do_shutdown(), and switch_loadable_module_load_file().

00088 {
00089         if (lib && *lib) {
00090                 dlclose(*lib);
00091                 *lib = NULL;
00092         }
00093 }

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

Definition at line 117 of file switch_dso.c.

00118 {
00119         void *func = dlsym(lib, sym);
00120         if (!func) {
00121                 *err = strdup(dlerror());
00122         }
00123         return (switch_dso_func_t) (intptr_t) func;
00124 }

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

Definition at line 95 of file switch_dso.c.

Referenced by switch_loadable_module_load_file().

00096 {
00097         void *lib;
00098 
00099         if (global) {
00100                 lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
00101         } else {
00102                 lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);
00103         }
00104 
00105         if (lib == NULL) {
00106                 const char *dlerr = dlerror();
00107                 /* Work around broken uclibc returning NULL on both dlopen() and dlerror() */
00108                 if (dlerr) {
00109                         *err = strdup(dlerr);
00110                 } else {
00111                         *err = strdup("Unknown error");
00112                 }
00113         }
00114         return lib;
00115 }


Generated on Sun May 20 04:00:10 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7