if ((entry = rb_dictionary_retrieve(idx->cap_dict, cap)) != NULL)
{
entry->flags &= ~CAP_ORPHANED;
+ if (ownerdata != NULL)
+ {
+ s_assert(entry->ownerdata == NULL);
+ entry->ownerdata = ownerdata;
+ }
return (1 << entry->value);
}
entry = rb_malloc(sizeof(struct CapabilityEntry));
- entry->cap = cap;
+ entry->cap = rb_strdup(cap);
entry->flags = 0;
entry->value = idx->highest_bit;
entry->ownerdata = ownerdata;
}
static void
-capability_destroy(struct DictionaryElement *delem, void *privdata)
+capability_destroy(rb_dictionary_element *delem, void *privdata)
{
s_assert(delem != NULL);
- rb_free(delem->data);
+ struct CapabilityEntry *entry = delem->data;
+ rb_free((char *)entry->cap);
+ rb_free(entry);
}
struct CapabilityIndex *
idx = rb_malloc(sizeof(struct CapabilityIndex));
idx->name = name;
- idx->cap_dict = rb_dictionary_create(name, strcasecmp);
+ idx->cap_dict = rb_dictionary_create(name, rb_strcasecmp);
idx->highest_bit = 1;
rb_dlinkAdd(idx, &idx->node, &capability_indexes);
const char *
capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask)
{
- struct DictionaryIter iter;
+ rb_dictionary_iter iter;
struct CapabilityEntry *entry;
static char buf[BUFSIZE];
char *t = buf;
*t = '\0';
- DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
+ RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
{
if ((1 << entry->value) & cap_mask)
{
unsigned int
capability_index_mask(struct CapabilityIndex *idx)
{
- struct DictionaryIter iter;
+ rb_dictionary_iter iter;
struct CapabilityEntry *entry;
unsigned int mask = 0;
s_assert(idx != NULL);
- DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
+ RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
{
if (!(entry->flags & CAP_ORPHANED))
mask |= (1 << entry->value);
unsigned int
capability_index_get_required(struct CapabilityIndex *idx)
{
- struct DictionaryIter iter;
+ rb_dictionary_iter iter;
struct CapabilityEntry *entry;
unsigned int mask = 0;
s_assert(idx != NULL);
- DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
+ RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
{
if (!(entry->flags & CAP_ORPHANED) && (entry->flags & CAP_REQUIRED))
mask |= (1 << entry->value);
RB_DLINK_FOREACH(node, capability_indexes.head)
{
struct CapabilityIndex *idx = node->data;
- struct DictionaryIter iter;
+ rb_dictionary_iter iter;
struct CapabilityEntry *entry;
snprintf(buf, sizeof buf, "'%s': allocated bits - %d", idx->name, (idx->highest_bit - 1));
cb(buf, privdata);
- DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
+ RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
{
snprintf(buf, sizeof buf, "bit %d: '%s'", entry->value, entry->cap);
cb(buf, privdata);