capability: add capability_index_mask() which calculates old CAP_MASK

This commit is contained in:
William Pitcock 2012-02-04 00:39:53 -06:00
parent 5e773521a9
commit ec3a9055f2
2 changed files with 19 additions and 1 deletions

View file

@ -30,7 +30,7 @@ extern void capability_orphan(struct CapabilityIndex *index, const char *cap);
extern struct CapabilityIndex *capability_index_create(void);
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 *);
#endif

View file

@ -142,3 +142,21 @@ capability_index_list(struct CapabilityIndex *index, unsigned int cap_mask)
return buf;
}
unsigned int
capability_index_mask(struct CapabilityIndex *index)
{
struct DictionaryIter iter;
struct CapabilityEntry *entry;
unsigned int mask = 0;
s_assert(index != NULL);
DICTIONARY_FOREACH(entry, &iter, index->cap_dict)
{
if (!entry->orphaned)
mask |= entry->value;
}
return mask;
}