diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdline.opt | 7 | ||||
-rw-r--r-- | src/module.c | 41 | ||||
-rw-r--r-- | src/wydawca.c | 8 | ||||
-rw-r--r-- | src/wydawca.h | 1 |
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 exit(0); END +OPTION(module-help,,MODULE, + [<show help for MODULE>]) +BEGIN + module_help(optarg); + exit(0); +END + OPTIONS_END void 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) if (mod->flush) mod->flush(modcfg); } + +void +module_help(const char *modname) +{ + lt_dladvise advise = NULL; + struct module mod; + void (*help)(void); + + if (lt_dlinit()) { + wy_log(LOG_ERR, _("failed to initialize libtool")); + exit(EX_UNAVAILABLE); + } + + lt_dladdsearchdir(WYDAWCA_MODDIR); + + if (lt_dladvise_init(&advise)) + wy_log(LOG_ERR, "lt_dladvise_init: %s", lt_dlerror()); + else { + if (lt_dladvise_ext(&advise)) + wy_log(LOG_ERR, "lt_dladvise_ext: %s", lt_dlerror()); + if (lt_dladvise_global(&advise)) + wy_log(LOG_ERR, "lt_dladvise_global: %s", + lt_dlerror()); + } + + memset(&mod, 0, sizeof(mod)); + mod.path = modname; + + if (modload(&mod, advise)) + exit(EX_UNAVAILABLE); + + lt_dladvise_destroy(&advise); + + help = resolve_sym(&mod, "help"); + if (!help) + wy_log(LOG_NOTICE, "no help for %s", modname); + else + help(); + + lt_dlclose(mod.handle); +} 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) config_finish(tree); modules_load(); + if (lint_mode && wy_debug_level) { + grecs_print_node(tree, + GRECS_NODE_FLAG_DEFAULT| + (wy_debug_level > 1 ? + GRECS_NODE_FLAG_LOCUS : 0), + stdout); + fputc('\n', stdout); + } grecs_tree_free(tree); 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, void *varptr, void *cb_data); void modules_load(void); void modules_close(void); +void modules_help(void); int module_set_init(const char *name, grecs_node_t *node); |