mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 15:00:51 +01:00
capability: clean up CAP_REQUIRED and CAP_ORPHANED flags, use bool variables instead
This commit is contained in:
parent
e7a768ca22
commit
09d19cbbd3
3 changed files with 11 additions and 13 deletions
|
@ -24,17 +24,15 @@
|
|||
#include <ircd/stdinc.h>
|
||||
#include <ircd/util.h>
|
||||
|
||||
#define CAP_ORPHANED 0x1
|
||||
#define CAP_REQUIRED 0x2
|
||||
|
||||
struct CapabilityEntry {
|
||||
std::string cap;
|
||||
unsigned int value;
|
||||
unsigned int flags;
|
||||
bool require;
|
||||
bool orphan;
|
||||
void *ownerdata;
|
||||
|
||||
CapabilityEntry(std::string cap_, unsigned int value_, void *ownerdata_)
|
||||
: cap(cap_), value(value_), flags(0), ownerdata(ownerdata_) { }
|
||||
: cap(cap_), value(value_), require(false), orphan(false), ownerdata(ownerdata_) { }
|
||||
};
|
||||
|
||||
struct CapabilityIndex {
|
||||
|
|
|
@ -56,7 +56,7 @@ CapabilityIndex::get(std::string cap, void **ownerdata)
|
|||
std::shared_ptr<CapabilityEntry> entry;
|
||||
|
||||
entry = find(cap);
|
||||
if (entry != NULL && !(entry->flags & CAP_ORPHANED))
|
||||
if (entry != NULL && !entry->orphan)
|
||||
{
|
||||
if (ownerdata != NULL)
|
||||
*ownerdata = entry->ownerdata;
|
||||
|
@ -76,7 +76,7 @@ CapabilityIndex::put(std::string cap, void *ownerdata)
|
|||
|
||||
if ((entry = find(cap)) != NULL)
|
||||
{
|
||||
entry->flags &= ~CAP_ORPHANED;
|
||||
entry->orphan = false;
|
||||
return (1 << entry->value);
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,8 @@ CapabilityIndex::orphan(std::string cap)
|
|||
entry = cap_dict[cap];
|
||||
if (entry != NULL)
|
||||
{
|
||||
entry->flags &= ~CAP_REQUIRED;
|
||||
entry->flags |= CAP_ORPHANED;
|
||||
entry->require = false;
|
||||
entry->orphan = true;
|
||||
entry->ownerdata = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ CapabilityIndex::require(std::string cap)
|
|||
|
||||
entry = cap_dict[cap];
|
||||
if (entry != NULL)
|
||||
entry->flags |= CAP_REQUIRED;
|
||||
entry->require = true;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -157,7 +157,7 @@ CapabilityIndex::mask()
|
|||
for (auto it = cap_dict.begin(); it != cap_dict.end(); it++)
|
||||
{
|
||||
auto entry = it->second;
|
||||
if (!(entry->flags & CAP_ORPHANED))
|
||||
if (!entry->orphan)
|
||||
mask |= (1 << entry->value);
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ CapabilityIndex::required()
|
|||
for (auto it = cap_dict.begin(); it != cap_dict.end(); it++)
|
||||
{
|
||||
auto entry = it->second;
|
||||
if (!(entry->flags & CAP_ORPHANED) && (entry->flags & CAP_REQUIRED))
|
||||
if (!entry->orphan && entry->require)
|
||||
mask |= (1 << entry->value);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ clicap_visible(struct Client *client_p, const std::shared_ptr<CapabilityEntry> c
|
|||
struct ClientCapability *clicap;
|
||||
|
||||
/* orphaned caps shouldn't be visible */
|
||||
if (cap->flags & CAP_ORPHANED)
|
||||
if (cap->orphan)
|
||||
return 0;
|
||||
|
||||
if (cap->ownerdata == NULL)
|
||||
|
|
Loading…
Reference in a new issue