]> jfr.im git - solanum.git/blame - include/capability.h
Keep propagated bans in a dictionary, not a list
[solanum.git] / include / capability.h
CommitLineData
64b56afd 1/*
3fc0499e 2 * Copyright (c) 2012 Ariadne Conill <ariadne@dereferenced.org>.
64b56afd
AC
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice is present in all copies.
7 *
8 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
9 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
11 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
12 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
13 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
14 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
15 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
16 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
17 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
18 * POSSIBILITY OF SUCH DAMAGE.
19 */
20
21#ifndef __CAPABILITY_H__
22#define __CAPABILITY_H__
23
4177311e
EM
24#include "stdinc.h"
25#include "rb_dictionary.h"
26
ba832267
AC
27struct CapabilityIndex {
28 const char *name;
4177311e 29 rb_dictionary *cap_dict;
ba832267
AC
30 unsigned int highest_bit;
31 rb_dlink_node node;
32};
33
34#define CAP_ORPHANED 0x1
35#define CAP_REQUIRED 0x2
36
37struct CapabilityEntry {
38 const char *cap;
39 unsigned int value;
40 unsigned int flags;
41 void *ownerdata;
42};
64b56afd 43
32df5e96 44extern struct CapabilityEntry *capability_find(struct CapabilityIndex *idx, const char *cap);
63b9db96
AC
45extern unsigned int capability_get(struct CapabilityIndex *idx, const char *cap, void **ownerdata);
46extern unsigned int capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata);
22cae20f 47extern unsigned int capability_put_anonymous(struct CapabilityIndex *idx);
bde42c60
JT
48extern void capability_orphan(struct CapabilityIndex *idx, const char *cap);
49extern void capability_require(struct CapabilityIndex *idx, const char *cap);
64b56afd 50
885cd603 51extern struct CapabilityIndex *capability_index_create(const char *name);
64b56afd 52extern void capability_index_destroy(struct CapabilityIndex *);
5e773521 53extern const char *capability_index_list(struct CapabilityIndex *, unsigned int capability_mask);
ec3a9055 54extern unsigned int capability_index_mask(struct CapabilityIndex *);
f01f67f0 55extern unsigned int capability_index_get_required(struct CapabilityIndex *);
a16910aa 56extern void capability_index_stats(void (*cb)(const char *line, void *privdata), void *privdata);
5e773521 57
64b56afd 58#endif