+++ /dev/null
-#include <stdlib.h>
-#include <string.h>
-#include <dlfcn.h>
-
-static int nmod = 0;
-static smtpsink_module **modlist = 0;
-
-/* modulespec is a string formatted as:
-
- "/path/to/module,options"
-
- parsing of "options" is module dependent
-*/
-void
-module_init(char *modulespec)
-{
- char modpath[1024];
- char *file, *t;
- smtpsink_module *mod;
- void *dlmod;
-
- t = strchr(modulespec, ',');
- if (!t) file = modulespec;
- else {
- if (t-modulespec - 1 > sizeof(modpath))
- errx(1, "module path too long: %s\n", modulespec);
- strncpy(modpath, modulespec, t - modulespec);
- file = modpath;
- }
-
- dlmod = dlopen(file, RTLD_NOW);
- if (!dlmod)
- errx(1, "could not load %s: %s\n", file, dlerror());
-
- mod = (void *)dlsym(dlmod, "smtpsink_module");
- if (!mod)
- errx(1, "module %s invalid: %s\n", file, dlerror());
-
- mod->module_init();
-
- modlist = realloc(modlist, nmod + 1);
- if (!modlist)
- errx(1, "out of memory\n");
-
- modlist[nmod++] = mod;
-}
-