Debian Codegraph @

src/OVAL/adt/oval_collection.c

raw symbols SCIP
1 /**
2 * @file oval_collection.c
3 * \brief Open Vulnerability and Assessment Language
4 *
5 * See more details at http://oval.mitre.org/
6 */
7
8 /*
9 * Copyright 2009--2013 Red Hat Inc., Durham, North Carolina.
10 * All Rights Reserved.
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 * Authors:
27 * "David Niemoller" <[email protected]>
28 */
29
30 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
31 #include <config.h>cxx . . $ `<file>/build/config.h`/
32 #endif
33
34 #include <stdlib.h>
35 #include <stdio.h>
36
37 #include "oval_adt.h"cxx . . $ `<file>/src/OVAL/public/oval_adt.h`/
38 #include "oval_collection_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_collection_impl.h`/
39 #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/
40
41 /***************************************************************************/
42 /* Variable definitions
43 * */
44
45 typedef struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# {
46 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *nextcxx . . $ _oval_collection_item_frame#next.;
47 void *itemcxx . . $ _oval_collection_item_frame#item.;
48 } _oval_collection_item_frame_tcxx . . $ _oval_collection_item_frame_t#;
49
50 typedef struct oval_collectioncxx . . $ oval_collection# {
51 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *item_collection_framecxx . . $ oval_collection#item_collection_frame.;
52 } oval_collection_tcxx . . $ oval_collection_t#;
53
54 typedef struct oval_iteratorcxx . . $ oval_iterator# {
55 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *item_iterator_framecxx . . $ oval_iterator#item_iterator_frame.;
56 } oval_iterator_tcxx . . $ oval_iterator_t#;
57
58 /* End of variable definitions
59 * */
60 /***************************************************************************/
61
62 struct oval_collectioncxx . . $ oval_collection# *oval_collection_newcxx . . $ oval_collection_new(18476da3f812812d).()
63 {
64 struct oval_collectioncxx . . $ oval_collection# *collection = (struct oval_collectioncxx . . $ oval_collection# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_collection_tcxx . . $ oval_collection_t#));
65 if (collection == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
66 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
67
68 collection->item_collection_framecxx . . $ oval_collection#item_collection_frame. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
69 return collection;
70 }
71
72 void oval_collection_freecxx . . $ oval_collection_free(7f543398a7666e77).(struct oval_collectioncxx . . $ oval_collection# *collection)
73 {
74 oval_collection_free_itemscxx . . $ oval_collection_free_items(637ec69504f927f1).(collection, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
75 }
76
77 void oval_collection_free_itemscxx . . $ oval_collection_free_items(637ec69504f927f1).(struct oval_collectioncxx . . $ oval_collection# *collection, oscap_destruct_funccxx . . $ oscap_destruct_func# free_func)
78 {
79 if (collection) {
80 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *frame = collection->item_collection_framecxx . . $ oval_collection#item_collection_frame.;
81 while (frame != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
82 if (free_func != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
83 void *item = frame->itemcxx . . $ _oval_collection_item_frame#item.;
84 if (item)
85 (*free_func) (item);
86 frame->itemcxx . . $ _oval_collection_item_frame#item. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
87 }
88 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *temp = frame;
89 frame = frame->nextcxx . . $ _oval_collection_item_frame#next.;
90 temp->nextcxx . . $ _oval_collection_item_frame#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
91 freecxx . . $ free(5d22bdacc48458e8).(temp);
92 }
93 freecxx . . $ free(5d22bdacc48458e8).(collection);
94 }
95 }
96
97 int oval_collection_is_emptycxx . . $ oval_collection_is_empty(48e809a55b244f15).(struct oval_collectioncxx . . $ oval_collection# *collection)
98 {
99 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(collection);
100 return collection->item_collection_framecxx . . $ oval_collection#item_collection_frame. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
101 }
102
103 void oval_collection_addcxx . . $ oval_collection_add(3c6bf54730c0284).(struct oval_collectioncxx . . $ oval_collection# *collection, void *item)
104 {
105 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(collection);
106
107 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *next = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(_oval_collection_item_frame_tcxx . . $ _oval_collection_item_frame_t#));
108 if (next == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
109 return;
110
111 next->nextcxx . . $ _oval_collection_item_frame#next. = collection->item_collection_framecxx . . $ oval_collection#item_collection_frame.;
112 collection->item_collection_framecxx . . $ oval_collection#item_collection_frame. = next;
113 next->itemcxx . . $ _oval_collection_item_frame#item. = item;
114 }
115
116 struct oval_iteratorcxx . . $ oval_iterator# *oval_collection_iteratorcxx . . $ oval_collection_iterator(8bdeb6a25e21af3e).(struct oval_collectioncxx . . $ oval_collection# *collection)
117 {
118 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(collection);
119
120 struct oval_iteratorcxx . . $ oval_iterator# *iterator = (struct oval_iteratorcxx . . $ oval_iterator# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_iterator_tcxx . . $ oval_iterator_t#));
121 if (iterator == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
122 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
123
124 iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
125 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *collection_frame = collection->item_collection_framecxx . . $ oval_collection#item_collection_frame.;
126
127 while (collection_frame != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
128 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *iterator_frame =
129 (struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(_oval_collection_item_frame_tcxx . . $ _oval_collection_item_frame_t#));
130
131 iterator_frame->nextcxx . . $ _oval_collection_item_frame#next. = iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame.;
132 iterator_frame->itemcxx . . $ _oval_collection_item_frame#item. = collection_frame->itemcxx . . $ _oval_collection_item_frame#item.;
133 iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. = iterator_frame;
134 collection_frame = collection_frame->nextcxx . . $ _oval_collection_item_frame#next.;
135 }
136 return iterator;
137 }
138
139 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).(struct oval_iteratorcxx . . $ oval_iterator# * iterator)
140 {
141 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(iterator);
142
143 return iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
144 }
145
146 int oval_collection_iterator_remainingcxx . . $ oval_collection_iterator_remaining(4404665b78efb7c8).(struct oval_iteratorcxx . . $ oval_iterator# *iterator)
147 {
148 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(iterator);
149
150 int remaining;
151 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *next = iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame.;
152
153 for (remaining = 0; next; remaining++)
154 next = next->nextcxx . . $ _oval_collection_item_frame#next.;
155
156 return remaining;
157 }
158
159 void *oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).(struct oval_iteratorcxx . . $ oval_iterator# *iterator)
160 {
161 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(iterator);
162
163 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *oc_next = iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame.;
164 void *next;
165
166 if (oc_next == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
167 next = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
168 } else {
169 next = oc_next->itemcxx . . $ _oval_collection_item_frame#item.;
170 iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. = oc_next->nextcxx . . $ _oval_collection_item_frame#next.;
171 oc_next->itemcxx . . $ _oval_collection_item_frame#item. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
172 oc_next->nextcxx . . $ _oval_collection_item_frame#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
173 freecxx . . $ free(5d22bdacc48458e8).(oc_next);
174 }
175 return next;
176 }
177
178 void oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).(struct oval_iteratorcxx . . $ oval_iterator# *iterator)
179 {
180 if (iterator) { //NOOP if iterator is NULL
181 while (iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame.) {
182 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *oc_this;
183 oc_this = iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame.;
184 iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. = oc_this->nextcxx . . $ _oval_collection_item_frame#next.;
185 oc_this->itemcxx . . $ _oval_collection_item_frame#item. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
186 oc_this->nextcxx . . $ _oval_collection_item_frame#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
187 freecxx . . $ free(5d22bdacc48458e8).(oc_this);
188 }
189 iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
190 freecxx . . $ free(5d22bdacc48458e8).(iterator);
191 }
192 }
193
194 struct oval_iteratorcxx . . $ oval_iterator# *oval_collection_iterator_newcxx . . $ oval_collection_iterator_new(b73131c625ff44d1).()
195 {
196 struct oval_iteratorcxx . . $ oval_iterator# *iterator = (struct oval_iteratorcxx . . $ oval_iterator# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_iterator_tcxx . . $ oval_iterator_t#));
197 if (iterator == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
198 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
199
200 iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
201 return iterator;
202 }
203
204 void oval_collection_iterator_addcxx . . $ oval_collection_iterator_add(a59eba6ba5efb2ef).(struct oval_iteratorcxx . . $ oval_iterator# *iterator, void *item)
205 {
206 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(iterator);
207
208 struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *newframe =
209 (struct _oval_collection_item_framecxx . . $ _oval_collection_item_frame# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(_oval_collection_item_frame_tcxx . . $ _oval_collection_item_frame_t#));
210 if (newframe == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) /* We don't have any information that error occurred ! */
211 return;
212
213 newframe->nextcxx . . $ _oval_collection_item_frame#next. = iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame.;
214 newframe->itemcxx . . $ _oval_collection_item_frame#item. = item;
215 iterator->item_iterator_framecxx . . $ oval_iterator#item_iterator_frame. = newframe;
216 }
217
218 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_string_iterator_has_morecxx . . $ oval_string_iterator_has_more(41a15bd829ecb6dd).(struct oval_string_iteratorcxx . . $ oval_string_iterator# * iterator)
219 {
220 return oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).((struct oval_iteratorcxx . . $ oval_iterator# *)iterator);
221 }
222
223 int oval_string_iterator_remainingcxx . . $ oval_string_iterator_remaining(b083ed19c60d30cd).(struct oval_string_iteratorcxx . . $ oval_string_iterator# *iterator)
224 {
225 return oval_collection_iterator_remainingcxx . . $ oval_collection_iterator_remaining(4404665b78efb7c8).((struct oval_iteratorcxx . . $ oval_iterator# *)iterator);
226 }
227
228 char *oval_string_iterator_nextcxx . . $ oval_string_iterator_next(fc393b19611653f6).(struct oval_string_iteratorcxx . . $ oval_string_iterator# *iterator)
229 {
230 return (char *)oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).((struct oval_iteratorcxx . . $ oval_iterator# *)iterator);
231 }
232
233 void oval_string_iterator_freecxx . . $ oval_string_iterator_free(eccafcd0705f3c29).(struct oval_string_iteratorcxx . . $ oval_string_iterator# *iterator)
234 {
235 oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).((struct oval_iteratorcxx . . $ oval_iterator# *)iterator);
236 }