Mercurial > irccd
changeset 1068:69602b51c6df
misc: remove usage of BSD sys/queue.h (hook)
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 12 Jul 2021 21:07:23 +0200 |
parents | f8fc0d12853d |
children | 827431b41132 |
files | irccd/jsapi-hook.c irccd/peer.c lib/irccd/hook.h lib/irccd/irccd.c lib/irccd/irccd.h |
diffstat | 5 files changed, 18 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/irccd/jsapi-hook.c Mon Jul 12 21:03:26 2021 +0200 +++ b/irccd/jsapi-hook.c Mon Jul 12 21:07:23 2021 +0200 @@ -18,6 +18,8 @@ #include <assert.h> +#include <utlist.h> + #include <irccd/hook.h> #include <irccd/irccd.h> @@ -45,7 +47,7 @@ duk_push_array(ctx); - LIST_FOREACH(h, &irc.hooks, link) { + LL_FOREACH(irc.hooks, h) { duk_push_object(ctx); duk_push_string(ctx, h->name); duk_put_prop_string(ctx, -2, "name");
--- a/irccd/peer.c Mon Jul 12 21:03:26 2021 +0200 +++ b/irccd/peer.c Mon Jul 12 21:07:23 2021 +0200 @@ -17,6 +17,7 @@ */ #include <sys/socket.h> +#include <assert.h> #include <ctype.h> #include <errno.h> #include <poll.h> @@ -26,7 +27,7 @@ #include <string.h> #include <unistd.h> -#include <assert.h> +#include <utlist.h> #include <irccd/conn.h> #include <irccd/irccd.h> @@ -216,10 +217,10 @@ fprintf(fp, "OK "); - LIST_FOREACH(h, &irc.hooks, link) { + LL_FOREACH(irc.hooks, h) { fprintf(fp, "%s", h->name); - if (LIST_NEXT(h, link)) + if (h->next) fputc(' ', fp); }
--- a/lib/irccd/hook.h Mon Jul 12 21:03:26 2021 +0200 +++ b/lib/irccd/hook.h Mon Jul 12 21:07:23 2021 +0200 @@ -19,7 +19,6 @@ #ifndef IRCCD_HOOK_H #define IRCCD_HOOK_H -#include <sys/queue.h> #include <limits.h> #include "limits.h" @@ -33,11 +32,9 @@ struct irc_hook { char name[IRC_ID_LEN]; char path[PATH_MAX]; - LIST_ENTRY(irc_hook) link; + struct irc_hook *next; }; -LIST_HEAD(irc_hook_list, irc_hook); - struct irc_hook * irc_hook_new(const char *, const char *);
--- a/lib/irccd/irccd.c Mon Jul 12 21:03:26 2021 +0200 +++ b/lib/irccd/irccd.c Mon Jul 12 21:07:23 2021 +0200 @@ -27,6 +27,8 @@ #include <string.h> #include <unistd.h> +#include <utlist.h> + #include "config.h" #include "event.h" #include "irccd.h" @@ -144,7 +146,7 @@ struct irc_plugin *p, *ptmp, *plgcmd = NULL; struct irc_hook *h, *htmp; - LIST_FOREACH_SAFE(h, &irc.hooks, link, htmp) + LL_FOREACH_SAFE(irc.hooks, h, htmp) irc_hook_invoke(h, ev); /* @@ -537,7 +539,7 @@ assert(h); assert(!irc_bot_hook_get(h->name)); - LIST_INSERT_HEAD(&irc.hooks, h, link); + LL_PREPEND(irc.hooks, h); } struct irc_hook * @@ -545,7 +547,7 @@ { struct irc_hook *h; - LIST_FOREACH(h, &irc.hooks, link) + LL_FOREACH(irc.hooks, h) if (strcmp(h->name, name) == 0) return h; @@ -560,7 +562,7 @@ struct irc_hook *h; if ((h = irc_bot_hook_get(name))) { - LIST_REMOVE(h, link); + LL_DELETE(irc.hooks, h); irc_hook_finish(h); } } @@ -570,9 +572,10 @@ { struct irc_hook *h, *tmp; - LIST_FOREACH_SAFE(h, &irc.hooks, link, tmp) + LL_FOREACH_SAFE(irc.hooks, h, tmp) irc_hook_finish(h); - LIST_INIT(&irc.hooks); + + irc.hooks = NULL; } size_t
--- a/lib/irccd/irccd.h Mon Jul 12 21:03:26 2021 +0200 +++ b/lib/irccd/irccd.h Mon Jul 12 21:07:23 2021 +0200 @@ -35,7 +35,7 @@ struct irc_plugin_list plugins; struct irc_plugin_loader_list plugin_loaders; struct irc_rule_list rules; - struct irc_hook_list hooks; + struct irc_hook *hooks; } irc; void