From 5058c8ebcee8b8f27a737e4f06b0e44bb923d50e Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 4 Feb 2012 01:55:11 -0600 Subject: [PATCH] capability: change CapabilityIndex.orphaned to (CapabilityIndex.flags & CAP_ORPHANED) This makes it possible to add other flags to capabilities. --- src/capability.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/capability.c b/src/capability.c index f478daa2..b42e7978 100644 --- a/src/capability.c +++ b/src/capability.c @@ -27,9 +27,11 @@ struct CapabilityIndex { unsigned int highest_bit; }; +#define CAP_ORPHANED 0x1 + struct CapabilityEntry { - unsigned int orphaned; unsigned int value; + unsigned int flags; }; unsigned int @@ -40,7 +42,7 @@ capability_get(struct CapabilityIndex *index, const char *cap) s_assert(index != NULL); entry = irc_dictionary_retrieve(index->cap_dict, cap); - if (entry != NULL && !entry->orphaned) + if (entry != NULL && !(entry->flags & CAP_ORPHANED)) return entry->value; return 0xFFFFFFFF; @@ -55,12 +57,12 @@ capability_put(struct CapabilityIndex *index, const char *cap) if ((entry = irc_dictionary_retrieve(index->cap_dict, cap)) != NULL) { - entry->orphaned = 0; + entry->flags &= ~CAP_ORPHANED; return entry->value; } entry = rb_malloc(sizeof(struct CapabilityEntry)); - entry->orphaned = 0; + entry->flags = 0; entry->value = index->highest_bit; irc_dictionary_add(index->cap_dict, cap, entry); @@ -83,7 +85,7 @@ capability_orphan(struct CapabilityIndex *index, const char *cap) entry = irc_dictionary_retrieve(index->cap_dict, cap); if (entry != NULL) - entry->orphaned = 1; + entry->flags |= CAP_ORPHANED; } static void