diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 57 | ||||
-rw-r--r-- | src/module.c | 40 |
2 files changed, 70 insertions, 27 deletions
diff --git a/src/config.c b/src/config.c index eef4ee1..f5860d4 100644 --- a/src/config.c +++ b/src/config.c @@ -1004,7 +1004,7 @@ static struct grecs_keyword spool_kw[] = { NULL, offsetof(struct spool, archive), cb_archive, NULL, archive_kw }, { "notify-event", NULL, N_("Configure notification"), - grecs_type_section, GRECS_DFLT, + grecs_type_section, GRECS_MULT, NULL, offsetof(struct spool, notification), cb_notify_event, NULL, notify_event_kw }, { "check-script", NULL, N_("A /bin/sh script to verify the tarball"), @@ -1197,6 +1197,48 @@ cb_locking(enum grecs_callback_command cmd, grecs_node_t *node, } static int +cb_load_path(enum grecs_callback_command cmd, grecs_node_t *node, + void *varptr, void *cb_data) +{ + struct grecs_list **lpp = varptr, *lp; + grecs_locus_t *locus = &node->locus; + grecs_value_t *value = node->v.value; + + if (*lpp) + lp = *lpp; + else { + lp = _grecs_simple_list_create(1); + *lpp = lp; + } + switch (value->type) { + case GRECS_TYPE_STRING: + grecs_list_append(lp, grecs_strdup(value->v.string)); + break; + + case GRECS_TYPE_LIST: { + struct grecs_list_entry *ep; + + for (ep = value->v.list->head; ep; ep = ep->next) { + const grecs_value_t *vp = ep->data; + + if (vp->type != GRECS_TYPE_STRING) { + grecs_error(&vp->locus, 0, + _("list element must be a string")); + return 1; + } + grecs_list_append(lp, grecs_strdup(vp->v.string)); + } + break; + } + + case GRECS_TYPE_ARRAY: + grecs_error(locus, 0, _("too many arguments")); + return 1; + } + return 0; +} + +static int cb_upload_version(enum grecs_callback_command cmd, grecs_node_t *node, void *varptr, void *cb_data) { @@ -1240,19 +1282,16 @@ static struct grecs_keyword wydawca_kw[] = { { "module-prepend-load-path", N_("path"), N_("List of directories searched for modules prior to " "the default module directory"), - grecs_type_string, GRECS_LIST, - &module_prepend_load_path }, + grecs_type_string, GRECS_LIST|GRECS_AGGR, + &module_prepend_load_path, 0, cb_load_path }, { "module-load-path", N_("path"), N_("List of directories searched for database modules."), - grecs_type_string, GRECS_LIST, - &module_load_path }, + grecs_type_string, GRECS_LIST|GRECS_AGGR, + &module_load_path, 0, cb_load_path }, { "module", N_("name: string> <path: string"), N_("Load the specified module"), grecs_type_string, GRECS_MULT, NULL, 0, cb_module }, - { "module", N_("name: string> <path: string"), - N_("Load the specified module"), - grecs_type_string, GRECS_MULT, NULL, 0, cb_module }, { "module-init", N_("modname"), N_("Module-specific initialization data"), grecs_type_section, GRECS_INAC, NULL, 0, NULL, NULL, NULL }, @@ -1372,7 +1411,7 @@ void config_finish(struct grecs_node *tree) { struct grecs_node *p; - + if (grecs_tree_process(tree, wydawca_kw)) exit(EX_CONFIG); for (p = tree->down; p; p = p->next) { diff --git a/src/module.c b/src/module.c index c009971..33946ee 100644 --- a/src/module.c +++ b/src/module.c @@ -87,10 +87,10 @@ cb_module(enum grecs_callback_command cmd, grecs_node_t *node, }; static void * -resolve_sym(struct module *mod, const char *name) +resolve_sym(struct module *mod, const char *name, int mustbe) { void *sym = lt_dlsym(mod->handle, name); - if (!sym) { + if (!sym && mustbe) { grecs_error(&mod->locus, 0, _("module \"%s\" does not define symbol \"%s\""), mod->name, name); @@ -117,12 +117,12 @@ modload(struct module *mod, lt_dladvise advise) return 1; } mod->handle = handle; - mod->open = resolve_sym(mod, "open"); - mod->close = resolve_sym(mod, "close"); + mod->open = resolve_sym(mod, "wy_open", 0); + mod->close = resolve_sym(mod, "wy_close", 0); - mod->config = resolve_sym(mod, "config"); - mod->notify = resolve_sym(mod, "notify"); - mod->flush = resolve_sym(mod, "flush"); + mod->config = resolve_sym(mod, "wy_config", 1); + mod->notify = resolve_sym(mod, "wy_notify", 1); + mod->flush = resolve_sym(mod, "wy_flush", 0); if (mod->open) { if (mod->open(mod->modinit)) { @@ -137,25 +137,22 @@ modload(struct module *mod, lt_dladvise advise) } static int -spoolmodcfg(struct spool *spool, void *unused) +conf_notification_modules(struct notification *np) { - struct notification *np; - - for (np = spool->notification; np; np = np->next) { + for (; np; np = np->next) { if (np->modname) { struct module *mod = modlookup(np->modname); if (!mod) { - wy_log(LOG_ERR, "spool %s: no such module: %s", - spool->tag, np->modname); + wy_log(LOG_ERR, "%s: no such module", + np->modname); return 1; } - if (mod->config) { + if (!np->modcfg && mod->config) { np->modcfg = mod->config(np->modnode); if (!np->modcfg) { wy_log(LOG_ERR, - "spool %s: failed to configure " - "module \"%s\"", - spool->tag, np->modname); + "%s: failed to configure", + np->modname); return 1; } } @@ -164,6 +161,12 @@ spoolmodcfg(struct spool *spool, void *unused) return 0; } +static int +spoolmodcfg(struct spool *spool, void *unused) +{ + return conf_notification_modules(spool->notification); +} + void modules_load() { @@ -207,6 +210,7 @@ modules_load() _("some modules failed to configure, exiting")); exit(EX_UNAVAILABLE); } + conf_notification_modules(default_notification); } void @@ -290,7 +294,7 @@ module_help(const char *modname) lt_dladvise_destroy(&advise); - help = resolve_sym(&mod, "help"); + help = resolve_sym(&mod, "wy_help", 0); if (!help) wy_log(LOG_NOTICE, "no help for %s", modname); else |