Add priorities to some hooks

This commit is contained in:
Ed Kellett 2020-04-27 00:42:53 +01:00
parent 91b1278224
commit c500b0bdb5
No known key found for this signature in database
GPG key ID: CB9986DEF342FABC
5 changed files with 10 additions and 9 deletions

View file

@ -13,7 +13,7 @@ static void m_invited(struct MsgBuf *, struct Client *, struct Client *, int, co
static unsigned int CAP_INVITE_NOTIFY;
mapi_hfn_list_av1 inv_notify_hfnlist[] = {
{ "invite", hook_invite },
{ "invite", hook_invite, HOOK_MONITOR },
{ NULL, NULL }
};

View file

@ -66,7 +66,8 @@ mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
static void new_local_user(void *data);
mapi_hfn_list_av1 webirc_hfnlist[] = {
{ "new_local_user", (hookfn) new_local_user },
/* unintuitive but correct--we want to be called first */
{ "new_local_user", (hookfn) new_local_user, HOOK_LOWEST },
{ NULL, NULL }
};

View file

@ -34,10 +34,10 @@ static void handle_client_exit(void *data);
mapi_hfn_list_av1 override_hfnlist[] = {
{ "umode_changed", (hookfn) check_umode_change },
{ "get_channel_access", (hookfn) hack_channel_access },
{ "can_join", (hookfn) hack_can_join },
{ "can_kick", (hookfn) hack_can_kick },
{ "can_send", (hookfn) hack_can_send },
{ "get_channel_access", (hookfn) hack_channel_access, HOOK_HIGHEST },
{ "can_join", (hookfn) hack_can_join, HOOK_HIGHEST },
{ "can_kick", (hookfn) hack_can_kick, HOOK_HIGHEST },
{ "can_send", (hookfn) hack_can_send, HOOK_HIGHEST },
{ "client_exit", (hookfn) handle_client_exit },
{ NULL, NULL }
};

View file

@ -14,7 +14,7 @@ static const char override_kick_immunity_desc[] =
static void can_kick(void *data);
mapi_hfn_list_av1 override_kick_immunity_hfnlist[] = {
{ "can_kick", (hookfn) can_kick },
{ "can_kick", (hookfn) can_kick, HOOK_HIGHEST },
{ NULL, NULL }
};

View file

@ -198,7 +198,7 @@ add_hook_prio(const char *name, hookfn fn, enum hook_priority priority)
entry->fn = fn;
entry->priority = priority;
RB_DLINK_FOREACH(ptr, &hooks[i].hooks.head)
RB_DLINK_FOREACH(ptr, hooks[i].hooks.head)
{
struct hook_entry *o = ptr->data;
if (entry->priority < o->priority)
@ -223,7 +223,7 @@ remove_hook(const char *name, hookfn fn)
if((i = find_hook(name)) < 0)
return;
RB_DLINK_FOREACH_SAFE(ptr, scratch, &hooks[i].hooks.head)
RB_DLINK_FOREACH_SAFE(ptr, scratch, hooks[i].hooks.head)
{
struct hook_entry *entry = ptr->data;
if (entry->fn == fn)