mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 16:34:13 +01:00
capability: add global list of capability indexes, and name all capability indexes
This commit is contained in:
parent
deee7b4388
commit
885cd603b5
3 changed files with 12 additions and 3 deletions
|
@ -29,7 +29,7 @@ extern unsigned int capability_put(struct CapabilityIndex *idx, const char *cap)
|
|||
extern void capability_orphan(struct CapabilityIndex *idx, const char *cap);
|
||||
extern void capability_require(struct CapabilityIndex *idx, const char *cap);
|
||||
|
||||
extern struct CapabilityIndex *capability_index_create(void);
|
||||
extern struct CapabilityIndex *capability_index_create(const char *name);
|
||||
extern void capability_index_destroy(struct CapabilityIndex *);
|
||||
extern const char *capability_index_list(struct CapabilityIndex *, unsigned int capability_mask);
|
||||
extern unsigned int capability_index_mask(struct CapabilityIndex *);
|
||||
|
|
|
@ -22,9 +22,13 @@
|
|||
#include "capability.h"
|
||||
#include "irc_dictionary.h"
|
||||
|
||||
static rb_dlink_list capability_indexes = { NULL, NULL, 0 };
|
||||
|
||||
struct CapabilityIndex {
|
||||
char *name;
|
||||
struct Dictionary *cap_dict;
|
||||
unsigned int highest_bit;
|
||||
rb_dlink_node node;
|
||||
};
|
||||
|
||||
#define CAP_ORPHANED 0x1
|
||||
|
@ -115,14 +119,17 @@ capability_destroy(struct DictionaryElement *delem, void *privdata)
|
|||
}
|
||||
|
||||
struct CapabilityIndex *
|
||||
capability_index_create(void)
|
||||
capability_index_create(const char *name)
|
||||
{
|
||||
struct CapabilityIndex *idx;
|
||||
|
||||
idx = rb_malloc(sizeof(struct CapabilityIndex));
|
||||
idx->name = rb_strdup(name);
|
||||
idx->cap_dict = irc_dictionary_create(strcasecmp);
|
||||
idx->highest_bit = 1;
|
||||
|
||||
rb_dlinkAdd(idx, &idx->node, &capability_indexes);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
@ -131,6 +138,8 @@ capability_index_destroy(struct CapabilityIndex *idx)
|
|||
{
|
||||
s_assert(idx != NULL);
|
||||
|
||||
rb_dlinkDelete(&idx->node, &capability_indexes);
|
||||
|
||||
irc_dictionary_destroy(idx->cap_dict, capability_destroy, NULL);
|
||||
rb_free(idx);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ unsigned int CAP_MLOCK;
|
|||
void
|
||||
init_builtin_capabs(void)
|
||||
{
|
||||
serv_capindex = capability_index_create();
|
||||
serv_capindex = capability_index_create("server capabilities");
|
||||
|
||||
CAP_QS = capability_put(serv_capindex, "QS");
|
||||
CAP_EX = capability_put(serv_capindex, "EX");
|
||||
|
|
Loading…
Reference in a new issue