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; static unsigned int CAP_INVITE_NOTIFY;
mapi_hfn_list_av1 inv_notify_hfnlist[] = { mapi_hfn_list_av1 inv_notify_hfnlist[] = {
{ "invite", hook_invite }, { "invite", hook_invite, HOOK_MONITOR },
{ NULL, NULL } { NULL, NULL }
}; };

View file

@ -66,7 +66,8 @@ mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
static void new_local_user(void *data); static void new_local_user(void *data);
mapi_hfn_list_av1 webirc_hfnlist[] = { 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 } { NULL, NULL }
}; };

View file

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

View file

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

View file

@ -198,7 +198,7 @@ add_hook_prio(const char *name, hookfn fn, enum hook_priority priority)
entry->fn = fn; entry->fn = fn;
entry->priority = priority; 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; struct hook_entry *o = ptr->data;
if (entry->priority < o->priority) if (entry->priority < o->priority)
@ -223,7 +223,7 @@ remove_hook(const char *name, hookfn fn)
if((i = find_hook(name)) < 0) if((i = find_hook(name)) < 0)
return; 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; struct hook_entry *entry = ptr->data;
if (entry->fn == fn) if (entry->fn == fn)