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_orphan(struct CapabilityIndex *idx, const char *cap);
|
||||||
extern void capability_require(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 void capability_index_destroy(struct CapabilityIndex *);
|
||||||
extern const char *capability_index_list(struct CapabilityIndex *, unsigned int capability_mask);
|
extern const char *capability_index_list(struct CapabilityIndex *, unsigned int capability_mask);
|
||||||
extern unsigned int capability_index_mask(struct CapabilityIndex *);
|
extern unsigned int capability_index_mask(struct CapabilityIndex *);
|
||||||
|
|
|
@ -22,9 +22,13 @@
|
||||||
#include "capability.h"
|
#include "capability.h"
|
||||||
#include "irc_dictionary.h"
|
#include "irc_dictionary.h"
|
||||||
|
|
||||||
|
static rb_dlink_list capability_indexes = { NULL, NULL, 0 };
|
||||||
|
|
||||||
struct CapabilityIndex {
|
struct CapabilityIndex {
|
||||||
|
char *name;
|
||||||
struct Dictionary *cap_dict;
|
struct Dictionary *cap_dict;
|
||||||
unsigned int highest_bit;
|
unsigned int highest_bit;
|
||||||
|
rb_dlink_node node;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CAP_ORPHANED 0x1
|
#define CAP_ORPHANED 0x1
|
||||||
|
@ -115,14 +119,17 @@ capability_destroy(struct DictionaryElement *delem, void *privdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CapabilityIndex *
|
struct CapabilityIndex *
|
||||||
capability_index_create(void)
|
capability_index_create(const char *name)
|
||||||
{
|
{
|
||||||
struct CapabilityIndex *idx;
|
struct CapabilityIndex *idx;
|
||||||
|
|
||||||
idx = rb_malloc(sizeof(struct CapabilityIndex));
|
idx = rb_malloc(sizeof(struct CapabilityIndex));
|
||||||
|
idx->name = rb_strdup(name);
|
||||||
idx->cap_dict = irc_dictionary_create(strcasecmp);
|
idx->cap_dict = irc_dictionary_create(strcasecmp);
|
||||||
idx->highest_bit = 1;
|
idx->highest_bit = 1;
|
||||||
|
|
||||||
|
rb_dlinkAdd(idx, &idx->node, &capability_indexes);
|
||||||
|
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +138,8 @@ capability_index_destroy(struct CapabilityIndex *idx)
|
||||||
{
|
{
|
||||||
s_assert(idx != NULL);
|
s_assert(idx != NULL);
|
||||||
|
|
||||||
|
rb_dlinkDelete(&idx->node, &capability_indexes);
|
||||||
|
|
||||||
irc_dictionary_destroy(idx->cap_dict, capability_destroy, NULL);
|
irc_dictionary_destroy(idx->cap_dict, capability_destroy, NULL);
|
||||||
rb_free(idx);
|
rb_free(idx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ unsigned int CAP_MLOCK;
|
||||||
void
|
void
|
||||||
init_builtin_capabs(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_QS = capability_put(serv_capindex, "QS");
|
||||||
CAP_EX = capability_put(serv_capindex, "EX");
|
CAP_EX = capability_put(serv_capindex, "EX");
|
||||||
|
|
Loading…
Reference in a new issue