]> jfr.im git - solanum.git/blob - include/capability.h
Add +R channel mode module requiring services account to chat (#102)
[solanum.git] / include / capability.h
1 /*
2 * Copyright (c) 2012 William Pitcock <nenolod@dereferenced.org>.
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
24 #include "stdinc.h"
25 #include "rb_dictionary.h"
26
27 struct CapabilityIndex {
28 const char *name;
29 rb_dictionary *cap_dict;
30 unsigned int highest_bit;
31 rb_dlink_node node;
32 };
33
34 #define CAP_ORPHANED 0x1
35 #define CAP_REQUIRED 0x2
36
37 struct CapabilityEntry {
38 const char *cap;
39 unsigned int value;
40 unsigned int flags;
41 void *ownerdata;
42 };
43
44 extern struct CapabilityEntry *capability_find(struct CapabilityIndex *idx, const char *cap);
45 extern unsigned int capability_get(struct CapabilityIndex *idx, const char *cap, void **ownerdata);
46 extern unsigned int capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata);
47 extern unsigned int capability_put_anonymous(struct CapabilityIndex *idx);
48 extern void capability_orphan(struct CapabilityIndex *idx, const char *cap);
49 extern void capability_require(struct CapabilityIndex *idx, const char *cap);
50
51 extern struct CapabilityIndex *capability_index_create(const char *name);
52 extern void capability_index_destroy(struct CapabilityIndex *);
53 extern const char *capability_index_list(struct CapabilityIndex *, unsigned int capability_mask);
54 extern unsigned int capability_index_mask(struct CapabilityIndex *);
55 extern unsigned int capability_index_get_required(struct CapabilityIndex *);
56 extern void capability_index_stats(void (*cb)(const char *line, void *privdata), void *privdata);
57
58 #endif