diff --git a/extensions/m_remove.c b/extensions/m_remove.c index 25bbd470..b213a12c 100644 --- a/extensions/m_remove.c +++ b/extensions/m_remove.c @@ -61,7 +61,7 @@ mapi_hfn_list_av1 remove_hfnlist[] = { static int modinit(void) { - CAP_REMOVE = capability_put(serv_capindex, "REMOVE"); + CAP_REMOVE = capability_put(serv_capindex, "REMOVE", NULL); return 0; } diff --git a/include/capability.h b/include/capability.h index 8857f0a1..f48529c3 100644 --- a/include/capability.h +++ b/include/capability.h @@ -24,8 +24,8 @@ struct CapabilityIndex; struct CapabilityEntry; -extern unsigned int capability_get(struct CapabilityIndex *idx, const char *cap); -extern unsigned int capability_put(struct CapabilityIndex *idx, const char *cap); +extern unsigned int capability_get(struct CapabilityIndex *idx, const char *cap, void **ownerdata); +extern unsigned int capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata); extern unsigned int capability_put_anonymous(struct CapabilityIndex *idx); extern void capability_orphan(struct CapabilityIndex *idx, const char *cap); extern void capability_require(struct CapabilityIndex *idx, const char *cap); diff --git a/ircd/capability.c b/ircd/capability.c index 71950212..6cc803bd 100644 --- a/ircd/capability.c +++ b/ircd/capability.c @@ -39,10 +39,11 @@ struct CapabilityEntry { char *cap; unsigned int value; unsigned int flags; + void *ownerdata; }; unsigned int -capability_get(struct CapabilityIndex *idx, const char *cap) +capability_get(struct CapabilityIndex *idx, const char *cap, void **ownerdata) { struct CapabilityEntry *entry; @@ -52,13 +53,17 @@ capability_get(struct CapabilityIndex *idx, const char *cap) entry = irc_dictionary_retrieve(idx->cap_dict, cap); if (entry != NULL && !(entry->flags & CAP_ORPHANED)) + { + if (ownerdata != NULL) + *ownerdata = entry->ownerdata; return (1 << entry->value); + } return 0; } unsigned int -capability_put(struct CapabilityIndex *idx, const char *cap) +capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata) { struct CapabilityEntry *entry; @@ -76,6 +81,7 @@ capability_put(struct CapabilityIndex *idx, const char *cap) entry->cap = rb_strdup(cap); entry->flags = 0; entry->value = idx->highest_bit; + entry->ownerdata = ownerdata; irc_dictionary_add(idx->cap_dict, entry->cap, entry); diff --git a/modules/m_capab.c b/modules/m_capab.c index 88303ff2..f6a225a1 100644 --- a/modules/m_capab.c +++ b/modules/m_capab.c @@ -83,7 +83,7 @@ mr_capab(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source { char *t = LOCAL_COPY(parv[i]); for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p)) - client_p->localClient->caps |= capability_get(serv_capindex, s); + client_p->localClient->caps |= capability_get(serv_capindex, s, NULL); } return 0; @@ -110,7 +110,7 @@ me_gcap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ source_p->serv->fullcaps = rb_strdup(parv[1]); for (s = rb_strtok_r(t, " ", &p); s; s = rb_strtok_r(NULL, " ", &p)) - source_p->serv->caps |= capability_get(serv_capindex, s); + source_p->serv->caps |= capability_get(serv_capindex, s, NULL); return 0; }