Kannel: Open Source WAP and SMS gateway  svn-r5262
gw-dlopen.c File Reference
#include "gw-config.h"
#include "gwlib.h"
#include <dlfcn.h>

Go to the source code of this file.

Functions

int gw_dlopen_get_symbol (const char *lib_path, const char *name, void **result)
 

Function Documentation

◆ gw_dlopen_get_symbol()

int gw_dlopen_get_symbol ( const char *  lib_path,
const char *  name,
void **  result 
)

Definition at line 70 of file gw-dlopen.c.

References debug(), and error().

Referenced by smsc_http_create().

71 {
72  void *dl_handle, *addr;
73  const char* err;
74 
75  *result = NULL;
76 
77  dl_handle = dlopen(lib_path, RTLD_NOW | RTLD_LOCAL);
78  err = dlerror();
79  if (NULL != err) {
80  error(0, "error opening shared library `%s': %s", (lib_path == NULL ? "" : lib_path), err);
81  return -1;
82  }
83 
84  debug("gw_dlopen", 0, "shared library `%s' opened", (lib_path == NULL ? "" : lib_path));
85 
86  addr = dlsym(dl_handle, name);
87  if (addr == NULL) {
88  error(0, "error find name in shared library `%s': %s", (lib_path == NULL ? "" : lib_path), dlerror());
89  dlclose(dl_handle);
90  return -1;
91  }
92  dlclose(dl_handle);
93 
94  *result = addr;
95 
96  return 0;
97 }
void error(int err, const char *fmt,...)
Definition: log.c:648
char * name
Definition: smsc_cimd2.c:212
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.