summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-12 14:48:45 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-03-12 14:54:19 (GMT)
commit0c2f9cd46d7defc7df7112848c5eb817bd4564df (patch) (side-by-side diff)
tree05bcf057ee64b3e9f9e066ac182d46b8a7f4a126
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 (more/less context) (ignore whitespace changes)
-rw-r--r--modules/mailutils/mod_mailutils.c40
-rw-r--r--src/cmdline.opt7
-rw-r--r--src/module.c41
-rw-r--r--src/wydawca.c8
-rw-r--r--src/wydawca.h1
5 files changed, 91 insertions, 6 deletions
diff --git a/modules/mailutils/mod_mailutils.c b/modules/mailutils/mod_mailutils.c
index a3d903c..ae437ff 100644
--- a/modules/mailutils/mod_mailutils.c
+++ b/modules/mailutils/mod_mailutils.c
@@ -483,12 +483,6 @@ static struct grecs_keyword mail_kw[] = {
{ NULL }
};
-void
-wy_help(void)
-{
- /* FIXME */
-}
-
int
wy_open(grecs_node_t *node)
{
@@ -822,3 +816,37 @@ wy_notify(void *data, int ev, wy_triplet_t trp)
else if (ev == wy_ev_statistics)
mail_stats(evt);
}
+
+void
+wy_help(void)
+{
+ static char *docstring = "\n\
+Mod_mailutils sends notifications about various Wydawca events\n\
+via electronic mail.\n";
+
+ static struct grecs_keyword init_top[] = {
+ { "module-init", "'mailutils",
+ "module initialization",
+ grecs_type_section, GRECS_INAC, NULL, 0, NULL, NULL,
+ mail_kw },
+ { NULL }
+ };
+
+ static struct grecs_keyword config_top[] = {
+ { "module-config", NULL,
+ "module configuration",
+ grecs_type_section, GRECS_INAC, NULL, 0, NULL, NULL,
+ notify_event_kw },
+ { NULL }
+ };
+
+ puts(docstring);
+ printf("Configuration statements:\n\n");
+ grecs_print_statement_array(init_top, 1, 0, stdout);
+
+ printf("\n\n# Usage in notify-event statement:\n");
+ printf("notify-event {\n ...");
+ grecs_print_statement_array(config_top, 1, 1, stdout);
+ printf("}\n");
+}
+
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);

Return to:

Send suggestions and report system problems to the System administrator.