module.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int loadModule (char *aptr, char *ebuf, size_t ebsiz)


Function Documentation

int loadModule char *  aptr,
char *  ebuf,
size_t  ebsiz
 

loadModule loads a shared object as a module for secwatch. the char ptr aptr is broken into an array of strings the first element of which is the name of the shared object.

Definition at line 42 of file module.c.

References count(), _moditem::entry, _moditem::modargs, modcnt, moddata, _moditem::modhand, _moditem::modname, mods, and split().

Referenced by readConfig().

00042                                                      {
00043      void *handle;
00044      modfn_t modfunc;
00045      char **argv, * modpath, *module, *error;
00046      int argc, mp;
00047      moditem_t x;
00048      
00049      if((argv = split(" ",aptr)) == NULL) 
00050           return -1;
00051      argc = count(argv);
00052      module = argv[0];
00053      if((handle = dlopen(module,RTLD_LAZY)) == NULL) {
00054           snprintf(ebuf,ebsiz,"module=%s, dlerror: %s",module,dlerror());
00055           return -1;
00056      }
00057      dlerror();
00058      *(void **)(&modfunc) = dlsym(handle,"secwmodinit");
00059      if((error = dlerror()) != NULL) {
00060           snprintf(ebuf,ebsiz,"module=%s, dlerror: %s",module,dlerror());
00061           return -1;
00062      }
00063      x.modname = module;
00064      x.modargs = argv;
00065      x.modhand = handle;
00066      x.entry = modfunc;
00067 
00068      mp = modcnt++;
00069      if((mods = realloc(mods,(sizeof(moditem_t *)*modcnt))) == NULL) {
00070           snprintf(ebuf,ebsiz,"Cannot load module %s: No space for module table",module);
00071           return -1;
00072      }
00073      if((mods[mp] = (moditem_t *) calloc(sizeof(moditem_t),1)) == NULL) {
00074           snprintf(ebuf,ebsiz,"Cannot load module %s: No space for module table entry",module);
00075           return -1;
00076      }
00077      *mods[mp] = x;
00078 
00079      modfunc(moddata,argc,argv);
00080      return 0;
00081 }

Here is the call graph for this function:


Generated on Tue Oct 31 10:17:37 2006 for secwatch by  doxygen 1.4.6