summaryrefslogtreecommitdiff
path: root/accel-pptpd/triton/loader.c
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-09-03 18:58:53 +0400
committerKozlov Dmitry <dima@server>2010-09-03 18:58:53 +0400
commite8aa3a1457295f70f8ccc9cd7f2f9073f01a5e2e (patch)
tree17a99610798630e83fc1032c82ee51c404ce19fe /accel-pptpd/triton/loader.c
parenta22573e91dac7971aa4c9b1d874d6751e8502d16 (diff)
downloadaccel-ppp-e8aa3a1457295f70f8ccc9cd7f2f9073f01a5e2e.tar.gz
accel-ppp-e8aa3a1457295f70f8ccc9cd7f2f9073f01a5e2e.zip
project restructured
Diffstat (limited to 'accel-pptpd/triton/loader.c')
-rw-r--r--accel-pptpd/triton/loader.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/accel-pptpd/triton/loader.c b/accel-pptpd/triton/loader.c
index a390f0a9..24d1cbcb 100644
--- a/accel-pptpd/triton/loader.c
+++ b/accel-pptpd/triton/loader.c
@@ -2,7 +2,45 @@
#include <string.h>
#include <unistd.h>
#include <stdio.h>
-#include <pthread.h>
+#include <errno.h>
+#include <dlfcn.h>
#include "triton_p.h"
+int load_modules(const char *name)
+{
+ struct conf_sect_t *sect;
+ struct conf_option_t *opt;
+
+ sect = conf_get_section(name);
+ if (!sect) {
+ fprintf(stderr, "loader: section '%s' not found\n", name);
+ return -1;
+ }
+
+ char *cwd = getcwd(NULL,0);
+
+ list_for_each_entry(opt, &sect->items, entry) {
+ if (!strcmp(opt->name,"path") && opt->val) {
+ if (chdir(opt->val)) {
+ fprintf(stderr,"loader: chdir '%s': %s\n", opt->val, strerror(errno));
+ goto out_err;
+ }
+ continue;
+ }
+ if (!dlopen(opt->name, RTLD_NOW | RTLD_GLOBAL)) {
+ fprintf(stderr,"loader: failed to load module '%s': %s\n",opt->name, dlerror());
+ goto out_err;
+ }
+ }
+
+ chdir(cwd);
+ free(cwd);
+ return 0;
+
+out_err:
+ chdir(cwd);
+ free(cwd);
+ return -1;
+}
+