Home | History | Annotate | Download | only in src
      1 /* Copyright (C) 2005 Red Hat, Inc. */
      2 
      3 /* Object: semanage_bool_t (Policy Boolean)
      4  * Object: semanage_bool_key_t (Policy Boolean Key)
      5  * Implements: record_t (Database Record)
      6  * Implements: record_key_t (Database Record Key)
      7  */
      8 
      9 #include <sepol/boolean_record.h>
     10 
     11 typedef sepol_bool_t semanage_bool_t;
     12 typedef sepol_bool_key_t semanage_bool_key_t;
     13 #define _SEMANAGE_BOOL_DEFINED_
     14 
     15 typedef semanage_bool_t record_t;
     16 typedef semanage_bool_key_t record_key_t;
     17 #define DBASE_RECORD_DEFINED
     18 
     19 #include "boolean_internal.h"
     20 #include "handle.h"
     21 #include "database.h"
     22 #include <stdlib.h>
     23 #include <selinux/selinux.h>
     24 
     25 /* Key */
     26 int semanage_bool_key_create(semanage_handle_t * handle,
     27 			     const char *name, semanage_bool_key_t ** key)
     28 {
     29 
     30 	return sepol_bool_key_create(handle->sepolh, name, key);
     31 }
     32 
     33 int semanage_bool_key_extract(semanage_handle_t * handle,
     34 			      const semanage_bool_t * boolean,
     35 			      semanage_bool_key_t ** key)
     36 {
     37 
     38 	return sepol_bool_key_extract(handle->sepolh, boolean, key);
     39 }
     40 
     41 hidden_def(semanage_bool_key_extract)
     42 
     43 void semanage_bool_key_free(semanage_bool_key_t * key)
     44 {
     45 	sepol_bool_key_free(key);
     46 }
     47 
     48 hidden_def(semanage_bool_key_free)
     49 
     50 int semanage_bool_compare(const semanage_bool_t * boolean,
     51 			  const semanage_bool_key_t * key)
     52 {
     53 
     54 	return sepol_bool_compare(boolean, key);
     55 }
     56 
     57 hidden_def(semanage_bool_compare)
     58 
     59 int semanage_bool_compare2(const semanage_bool_t * boolean,
     60 			   const semanage_bool_t * boolean2)
     61 {
     62 
     63 	return sepol_bool_compare2(boolean, boolean2);
     64 }
     65 
     66 hidden_def(semanage_bool_compare2)
     67 
     68 static int semanage_bool_compare2_qsort(const semanage_bool_t ** boolean,
     69 					const semanage_bool_t ** boolean2)
     70 {
     71 
     72 	return sepol_bool_compare2(*boolean, *boolean2);
     73 }
     74 
     75 /* Name */
     76 const char *semanage_bool_get_name(const semanage_bool_t * boolean)
     77 {
     78 
     79 	return sepol_bool_get_name(boolean);
     80 }
     81 
     82 hidden_def(semanage_bool_get_name)
     83 
     84 int semanage_bool_set_name(semanage_handle_t * handle,
     85 			   semanage_bool_t * boolean, const char *name)
     86 {
     87 	int rc;
     88 	char *subname = selinux_boolean_sub(name);
     89 	rc = sepol_bool_set_name(handle->sepolh, boolean, subname);
     90 	free(subname);
     91 	return rc;
     92 }
     93 
     94 hidden_def(semanage_bool_set_name)
     95 
     96 /* Value */
     97 int semanage_bool_get_value(const semanage_bool_t * boolean)
     98 {
     99 
    100 	return sepol_bool_get_value(boolean);
    101 }
    102 
    103 hidden_def(semanage_bool_get_value)
    104 
    105 void semanage_bool_set_value(semanage_bool_t * boolean, int value)
    106 {
    107 
    108 	sepol_bool_set_value(boolean, value);
    109 }
    110 
    111 hidden_def(semanage_bool_set_value)
    112 
    113 /* Create/Clone/Destroy */
    114 int semanage_bool_create(semanage_handle_t * handle,
    115 			 semanage_bool_t ** bool_ptr)
    116 {
    117 
    118 	return sepol_bool_create(handle->sepolh, bool_ptr);
    119 }
    120 
    121 hidden_def(semanage_bool_create)
    122 
    123 int semanage_bool_clone(semanage_handle_t * handle,
    124 			const semanage_bool_t * boolean,
    125 			semanage_bool_t ** bool_ptr)
    126 {
    127 
    128 	return sepol_bool_clone(handle->sepolh, boolean, bool_ptr);
    129 }
    130 
    131 hidden_def(semanage_bool_clone)
    132 
    133 void semanage_bool_free(semanage_bool_t * boolean)
    134 {
    135 
    136 	sepol_bool_free(boolean);
    137 }
    138 
    139 hidden_def(semanage_bool_free)
    140 
    141 /* Record base functions */
    142 record_table_t SEMANAGE_BOOL_RTABLE = {
    143 	.create = semanage_bool_create,
    144 	.key_extract = semanage_bool_key_extract,
    145 	.key_free = semanage_bool_key_free,
    146 	.clone = semanage_bool_clone,
    147 	.compare = semanage_bool_compare,
    148 	.compare2 = semanage_bool_compare2,
    149 	.compare2_qsort = semanage_bool_compare2_qsort,
    150 	.free = semanage_bool_free,
    151 };
    152