aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 16:48:45 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 16:54:19 +0200
commit0c2f9cd46d7defc7df7112848c5eb817bd4564df (patch)
tree05bcf057ee64b3e9f9e066ac182d46b8a7f4a126 /src
parent407bde189a8cd0009e9e3cad8d8ba80d45833979 (diff)
downloadwydawca-0c2f9cd46d7defc7df7112848c5eb817bd4564df.tar.gz
wydawca-0c2f9cd46d7defc7df7112848c5eb817bd4564df.tar.bz2
New informative options.
* modules/mailutils/mod_mailutils.c (wy_help): Implement module help. * src/wydawca.c (main): Using -t and -d options together produces a print out of the configuration parse tree. Additional -d option includes source file locations. * src/module.c (module_help): New function. * src/module.h (module_help): New proto.
Diffstat (limited to 'src')
-rw-r--r--src/cmdline.opt7
-rw-r--r--src/module.c41
-rw-r--r--src/wydawca.c8
-rw-r--r--src/wydawca.h1
4 files changed, 57 insertions, 0 deletions
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 039dc6b..5862d87 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -201,6 +201,13 @@ BEGIN
201 exit(0); 201 exit(0);
202END 202END
203 203
204OPTION(module-help,,MODULE,
205 [<show help for MODULE>])
206BEGIN
207 module_help(optarg);
208 exit(0);
209END
210
204OPTIONS_END 211OPTIONS_END
205 212
206void 213void
diff --git a/src/module.c b/src/module.c
index 212b740..c009971 100644
--- a/src/module.c
+++ b/src/module.c
@@ -257,3 +257,44 @@ module_flush(const char *name, void *modcfg)
257 if (mod->flush) 257 if (mod->flush)
258 mod->flush(modcfg); 258 mod->flush(modcfg);
259} 259}
260
261void
262module_help(const char *modname)
263{
264 lt_dladvise advise = NULL;
265 struct module mod;
266 void (*help)(void);
267
268 if (lt_dlinit()) {
269 wy_log(LOG_ERR, _("failed to initialize libtool"));
270 exit(EX_UNAVAILABLE);
271 }
272
273 lt_dladdsearchdir(WYDAWCA_MODDIR);
274
275 if (lt_dladvise_init(&advise))
276 wy_log(LOG_ERR, "lt_dladvise_init: %s", lt_dlerror());
277 else {
278 if (lt_dladvise_ext(&advise))
279 wy_log(LOG_ERR, "lt_dladvise_ext: %s", lt_dlerror());
280 if (lt_dladvise_global(&advise))
281 wy_log(LOG_ERR, "lt_dladvise_global: %s",
282 lt_dlerror());
283 }
284
285 memset(&mod, 0, sizeof(mod));
286 mod.path = modname;
287
288 if (modload(&mod, advise))
289 exit(EX_UNAVAILABLE);
290
291 lt_dladvise_destroy(&advise);
292
293 help = resolve_sym(&mod, "help");
294 if (!help)
295 wy_log(LOG_NOTICE, "no help for %s", modname);
296 else
297 help();
298
299 lt_dlclose(mod.handle);
300}
diff --git a/src/wydawca.c b/src/wydawca.c
index 3561994..2f7332d 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -368,6 +368,14 @@ main(int argc, char **argv)
368 368
369 config_finish(tree); 369 config_finish(tree);
370 modules_load(); 370 modules_load();
371 if (lint_mode && wy_debug_level) {
372 grecs_print_node(tree,
373 GRECS_NODE_FLAG_DEFAULT|
374 (wy_debug_level > 1 ?
375 GRECS_NODE_FLAG_LOCUS : 0),
376 stdout);
377 fputc('\n', stdout);
378 }
371 grecs_tree_free(tree); 379 grecs_tree_free(tree);
372 380
373 if (lint_mode) 381 if (lint_mode)
diff --git a/src/wydawca.h b/src/wydawca.h
index 55929ee..2336851 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -312,6 +312,7 @@ int cb_module(enum grecs_callback_command cmd, grecs_node_t *node,
312 void *varptr, void *cb_data); 312 void *varptr, void *cb_data);
313void modules_load(void); 313void modules_load(void);
314void modules_close(void); 314void modules_close(void);
315void modules_help(void);
315 316
316int module_set_init(const char *name, grecs_node_t *node); 317int module_set_init(const char *name, grecs_node_t *node);
317 318

Return to:

Send suggestions and report system problems to the System administrator.