aboutsummaryrefslogtreecommitdiff
path: root/src/module.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-27 13:44:31 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-27 13:44:31 +0300
commit9dff021e31a300dcd5eda941d9e4992a6a8e465a (patch)
tree9ba56aa2ccbd7c24b1d1e8535c8e3eeef25f27cf /src/module.c
parente19cf8e1303700b5b2e4f3e525285f63a3c7b51f (diff)
downloadwydawca-9dff021e31a300dcd5eda941d9e4992a6a8e465a.tar.gz
wydawca-9dff021e31a300dcd5eda941d9e4992a6a8e465a.tar.bz2
Use BSD queue macros to implement queues and linked lists.
Diffstat (limited to 'src/module.c')
-rw-r--r--src/module.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/module.c b/src/module.c
index 22a9c6e..2b47ba0 100644
--- a/src/module.c
+++ b/src/module.c
@@ -17,17 +17,17 @@
#include "wydawca.h"
#include <ltdl.h>
-static struct module *mod_head, *mod_tail;
+static STAILQ_HEAD(,module) mod_head = STAILQ_HEAD_INITIALIZER(mod_head);
struct grecs_list *module_load_path, *module_prepend_load_path;
static struct module *
modlookup(const char *name)
{
struct module *p;
-
- for (p = mod_head; p; p = p->next)
+ STAILQ_FOREACH(p, &mod_head, link) {
if (strcmp(p->name, name) == 0)
- return p;;
+ return p;
+ }
return NULL;
}
@@ -53,11 +53,7 @@ modinstall(const char *name, const char *path, grecs_locus_t * loc)
p->locus.end.line = loc->end.line;
p->locus.end.col = loc->end.col;
- if (mod_tail)
- mod_tail->next = p;
- else
- mod_head = p;
- mod_tail = p;
+ STAILQ_INSERT_TAIL(&mod_head, p, link);
return p;
}
@@ -135,9 +131,10 @@ modload(struct module *mod, lt_dladvise advise)
}
static int
-conf_notification_modules(struct notification *np)
+conf_notification_modules(NOTIFYQ *nq)
{
- for (; np; np = np->next) {
+ struct notification *np;
+ NOTIFYQ_FOREACH(np, nq) {
if (np->modname) {
struct module *mod = modlookup(np->modname);
if (!mod) {
@@ -160,7 +157,7 @@ conf_notification_modules(struct notification *np)
static int
spoolmodcfg(struct spool *spool, void *unused)
{
- return conf_notification_modules(spool->notification);
+ return conf_notification_modules(&spool->notification_queue);
}
void
@@ -194,7 +191,7 @@ modules_load()
wy_log(LOG_ERR, "lt_dladvise_global: %s", lt_dlerror());
}
- for (mod = mod_head; mod; mod = mod->next) {
+ STAILQ_FOREACH(mod, &mod_head, link) {
if (modload(mod, advise))
exit(EX_UNAVAILABLE);
}
@@ -204,18 +201,19 @@ modules_load()
wy_log(LOG_CRIT, _("some modules failed to configure, exiting"));
exit(EX_UNAVAILABLE);
}
- conf_notification_modules(default_notification);
+ conf_notification_modules(&default_notification);
}
void
-modules_close()
+modules_close(void)
{
struct module *mod;
- for (mod = mod_head; mod; mod = mod->next) {
+ while ((mod = STAILQ_FIRST(&mod_head)) != NULL) {
if (mod->close)
mod->close();
lt_dlclose(mod->handle);
+ STAILQ_REMOVE_HEAD(&mod_head, link);
}
}

Return to:

Send suggestions and report system problems to the System administrator.