capability: allow attaching capability-owner data to a capability token, to enable extended data for client capabilities
This commit is contained in:
parent
4d2f203026
commit
63b9db9675
4 changed files with 13 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue