1 #ifndef _SEPOL_BOOLEANS_H_
2 #define _SEPOL_BOOLEANS_H_
3 
4 #include <stddef.h>
5 #include <sepol/policydb.h>
6 #include <sepol/boolean_record.h>
7 #include <sepol/handle.h>
8 #include <sys/cdefs.h>
9 
10 __BEGIN_DECLS
11 
12 /*--------------compatibility--------------*/
13 
14 /* Given an existing binary policy (starting at 'data', with length 'len')
15    and a boolean configuration file named by 'boolpath', rewrite the binary
16    policy for the boolean settings in the boolean configuration file.
17    The binary policy is rewritten in place in memory.
18    Returns 0 upon success, or -1 otherwise. */
19 extern int sepol_genbools(void *data, size_t len, char *boolpath);
20 
21 /* Given an existing binary policy (starting at 'data', with length 'len')
22    and boolean settings specified by the parallel arrays ('names', 'values')
23    with 'nel' elements, rewrite the binary policy for the boolean settings.
24    The binary policy is rewritten in place in memory.
25    Returns 0 upon success or -1 otherwise. */
26 extern int sepol_genbools_array(void *data, size_t len,
27 				char **names, int *values, int nel);
28 /*---------------end compatbility------------*/
29 
30 /* Set the specified boolean */
31 extern int sepol_bool_set(sepol_handle_t * handle,
32 			  sepol_policydb_t * policydb,
33 			  const sepol_bool_key_t * key,
34 			  const sepol_bool_t * data);
35 
36 /* Return the number of booleans */
37 extern int sepol_bool_count(sepol_handle_t * handle,
38 			    const sepol_policydb_t * p, unsigned int *response);
39 
40 /* Check if the specified boolean exists */
41 extern int sepol_bool_exists(sepol_handle_t * handle,
42 			     const sepol_policydb_t * policydb,
43 			     const sepol_bool_key_t * key, int *response);
44 
45 /* Query a boolean - returns the boolean, or NULL if not found */
46 extern int sepol_bool_query(sepol_handle_t * handle,
47 			    const sepol_policydb_t * p,
48 			    const sepol_bool_key_t * key,
49 			    sepol_bool_t ** response);
50 
51 /* Iterate the booleans
52  * The handler may return:
53  * -1 to signal an error condition,
54  * 1 to signal successful exit
55  * 0 to signal continue */
56 
57 extern int sepol_bool_iterate(sepol_handle_t * handle,
58 			      const sepol_policydb_t * policydb,
59 			      int (*fn) (const sepol_bool_t * boolean,
60 					 void *fn_arg), void *arg);
61 
62 __END_DECLS
63 #endif
64