41 typedef void (*oscap_dump_func) ();
43 typedef bool (*oscap_cmp_func) (
void *,
void *);
61 void oscap_create_lists(
struct oscap_list **first, ...);
62 bool oscap_list_add(
struct oscap_list *list,
void *value);
63 bool oscap_list_push(
struct oscap_list *list,
void *value);
64 bool oscap_list_pop(
struct oscap_list *list, oscap_destruct_func destructor);
66 void oscap_list_free(
struct oscap_list *list, oscap_destruct_func destructor);
67 void oscap_list_free0(
struct oscap_list *list);
68 void oscap_list_dump(
struct oscap_list *list, oscap_dump_func dumper,
int depth);
69 int oscap_list_get_itemcount(
struct oscap_list *list);
70 bool oscap_list_contains(
struct oscap_list *list,
void *what, oscap_cmp_func compare);
76 typedef bool(*oscap_filter_func) (
void *,
void *);
81 oscap_filter_func filter;
85 void *oscap_iterator_new(
struct oscap_list *list);
86 void *oscap_iterator_new_filter(
struct oscap_list *list, oscap_filter_func filter,
void *user_data);
88 size_t oscap_iterator_get_itemcount(
const struct oscap_iterator *it);
94 void *oscap_list_find(
struct oscap_list *list,
void *what, oscap_cmp_func compare);
102 #define OSCAP_FOREACH_GENERIC(itype, vtype, val, init_val, code) \
104 struct itype##_iterator *val##_iter = (init_val); \
106 while (itype##_iterator_has_more(val##_iter)) { \
107 val = itype##_iterator_next(val##_iter); \
110 itype##_iterator_free(val##_iter); \
121 #define OSCAP_FOREACH(type, val, init_val, code) \
122 OSCAP_FOREACH_GENERIC(type, struct type *, val, init_val, code)
135 #define OSCAP_FOR_GENERIC(itype, vtype, val, init_val) \
136 vtype val = NULL; struct itype##_iterator *val##_iter = (init_val); \
137 while (itype##_iterator_has_more(val##_iter) \
138 ? (val = itype##_iterator_next(val##_iter), true) \
139 : (itype##_iterator_free(val##_iter), val##_iter = NULL, false))
148 #define OSCAP_FOR(type, val, init_val) OSCAP_FOR_GENERIC(type, struct type *, val, init_val)
156 #define OSCAP_FOR_STR(val, init_val) OSCAP_FOR_GENERIC(oscap_string, const char *, val, init_val)
163 typedef int (*oscap_compare_func) (
const char *,
const char *);
176 oscap_compare_func cmp;
186 struct oscap_htable *oscap_htable_new1(oscap_compare_func cmp,
size_t hsize);
208 bool oscap_htable_add(
struct oscap_htable *htable,
const char *key,
void *item);
214 void *oscap_htable_get(
struct oscap_htable *htable,
const char *key);
216 void *oscap_htable_detach(
struct oscap_htable *htable,
const char *key);
218 void oscap_htable_dump(
struct oscap_htable *htable, oscap_dump_func dumper,
int depth);
225 void oscap_htable_free(
struct oscap_htable *htable, oscap_destruct_func destructor);
285 void oscap_print_depth(
int depth);