]>
Commit | Line | Data |
---|---|---|
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 | struct CapabilityIndex { | |
25 | const char *name; | |
26 | struct Dictionary *cap_dict; | |
27 | unsigned int highest_bit; | |
28 | rb_dlink_node node; | |
29 | }; | |
30 | ||
31 | #define CAP_ORPHANED 0x1 | |
32 | #define CAP_REQUIRED 0x2 | |
33 | ||
34 | struct CapabilityEntry { | |
35 | const char *cap; | |
36 | unsigned int value; | |
37 | unsigned int flags; | |
38 | void *ownerdata; | |
39 | }; | |
40 | ||
41 | extern struct CapabilityEntry *capability_find(struct CapabilityIndex *idx, const char *cap); | |
42 | extern unsigned int capability_get(struct CapabilityIndex *idx, const char *cap, void **ownerdata); | |
43 | extern unsigned int capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata); | |
44 | extern unsigned int capability_put_anonymous(struct CapabilityIndex *idx); | |
45 | extern void capability_orphan(struct CapabilityIndex *idx, const char *cap); | |
46 | extern void capability_require(struct CapabilityIndex *idx, const char *cap); | |
47 | ||
48 | extern struct CapabilityIndex *capability_index_create(const char *name); | |
49 | extern void capability_index_destroy(struct CapabilityIndex *); | |
50 | extern const char *capability_index_list(struct CapabilityIndex *, unsigned int capability_mask); | |
51 | extern unsigned int capability_index_mask(struct CapabilityIndex *); | |
52 | extern unsigned int capability_index_get_required(struct CapabilityIndex *); | |
53 | extern void capability_index_stats(void (*cb)(const char *line, void *privdata), void *privdata); | |
54 | ||
55 | #endif |