00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef OSCAP_LIST_
00030 #define OSCAP_LIST_
00031
00032 #include <stdlib.h>
00033 #include <stdbool.h>
00034
00035 #include "util.h"
00036 #include "public/oscap.h"
00037
00038 OSCAP_HIDDEN_START;
00039
00040 typedef void(*oscap_dump_func)(void*,int);
00041
00042
00043
00044
00045
00046 struct oscap_list_item {
00047 void* data;
00048 struct oscap_list_item* next;
00049 };
00050
00051 struct oscap_list {
00052 struct oscap_list_item* first;
00053 struct oscap_list_item* last;
00054 size_t itemcount;
00055 };
00056
00057 struct oscap_list* oscap_list_new(void);
00058 bool oscap_list_add(struct oscap_list* list, void* value);
00059 void oscap_list_free(struct oscap_list* list, oscap_destruct_func destructor);
00060 void oscap_list_free0(struct oscap_list* list);
00061 void oscap_list_dump(struct oscap_list* list, oscap_dump_func dumper, int depth);
00062 int oscap_list_get_itemcount(struct oscap_list* list);
00063
00064
00065
00066 typedef bool(*oscap_filter_func)(void*,void*);
00067
00068 struct oscap_iterator {
00069 struct oscap_list_item *cur;
00070 struct oscap_list *list;
00071 oscap_filter_func filter;
00072 void* user_data;
00073 };
00074
00075 void* oscap_iterator_new(struct oscap_list* list);
00076 void* oscap_iterator_new_filter(struct oscap_list* list, oscap_filter_func filter, void* user_data);
00077 void* oscap_iterator_next(struct oscap_iterator* it);
00078 size_t oscap_iterator_get_itemcount(const struct oscap_iterator* it);
00079 bool oscap_iterator_has_more(struct oscap_iterator* it);
00080 void oscap_iterator_free(struct oscap_iterator* it);
00081
00082
00083
00084
00085
00086
00087 typedef int (*oscap_compare_func)(const char*, const char*);
00088
00089 struct oscap_htable_item {
00090 struct oscap_htable_item* next;
00091 char* key;
00092 void* value;
00093 };
00094
00095
00096 struct oscap_htable {
00097 size_t hsize;
00098 size_t itemcount;
00099 struct oscap_htable_item** table;
00100 oscap_compare_func cmp;
00101 };
00102
00103
00104
00105
00106
00107
00108
00109
00110 struct oscap_htable* oscap_htable_new1(oscap_compare_func cmp, size_t hsize);
00111
00112
00113
00114
00115
00116
00117
00118
00119 struct oscap_htable* oscap_htable_new(void);
00120
00121
00122
00123
00124
00125 bool oscap_htable_add(struct oscap_htable* htable, const char* key, void* item);
00126
00127
00128
00129
00130
00131 void* oscap_htable_get(struct oscap_htable* htable, const char* key);
00132
00133 void oscap_htable_dump(struct oscap_htable* htable, oscap_dump_func dumper, int depth);
00134
00135
00136
00137
00138
00139
00140 void oscap_htable_free(struct oscap_htable* htable, oscap_destruct_func destructor);
00141
00142 void oscap_print_depth(int depth);
00143
00144 OSCAP_HIDDEN_END;
00145
00146 #endif
00147
00148