Debian Codegraph @

src/OVAL/adt/oval_smc_iterator.c

raw symbols SCIP
1 /*
2 * Copyright 2013 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Šimon Lukašík
21 *
22 *
23 *
24 * This module implements a simple iterator iterating through SMC structure.
25 * That is StringMap that points to the oval_collection objects.
26 *
27 * This module implements only sub set of iterator functionality for iterating
28 * through map/list structure. Limits: It supposes that list (secondary_col) is
29 * never empty.
30 */
31
32 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
33 #include <config.h>cxx . . $ `<file>/build/config.h`/
34 #endif
35
36 #include "oval_smc_iterator_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_smc_iterator_impl.h`/
37 #include "oval_string_map_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_string_map_impl.h`/
38 #include "oval_smc_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_smc_impl.h`/
39
40 struct oval_smc_iteratorcxx . . $ oval_smc_iterator# {
41 struct oval_collectioncxx . . $ oval_collection# *primary_colcxx . . $ oval_smc_iterator#primary_col.; ///< list of lists
42 struct oval_iteratorcxx . . $ oval_iterator# *primary_itcxx . . $ oval_smc_iterator#primary_it.; ///< iterating through primary_col
43 struct oval_iteratorcxx . . $ oval_iterator# *secondary_itcxx . . $ oval_smc_iterator#secondary_it.; ///< iterating through a single item of primary_col
44 };
45
46 struct oval_smc_iteratorcxx . . $ oval_smc_iterator# *oval_smc_iterator_newcxx . . $ oval_smc_iterator_new(b25fd823588405a4).(struct oval_smccxx . . $ oval_smc# *mapping)
47 {
48 if (mapping == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
49 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
50
51 struct oval_smc_iteratorcxx . . $ oval_smc_iterator# *it = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct oval_smc_iteratorcxx . . $ oval_smc_iterator#));
52
53 it->primary_colcxx . . $ oval_smc_iterator#primary_col. = oval_string_map_collect_valuescxx . . $ oval_string_map_collect_values(5121c6e4df28049d).((struct oval_string_mapcxx . . $ oval_string_map# *) mapping, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
54 it->primary_itcxx . . $ oval_smc_iterator#primary_it. = oval_collection_iteratorcxx . . $ oval_collection_iterator(8bdeb6a25e21af3e).(it->primary_colcxx . . $ oval_smc_iterator#primary_col.);
55 it->secondary_itcxx . . $ oval_smc_iterator#secondary_it. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
56 return it;
57 }
58
59 void oval_smc_iterator_freecxx . . $ oval_smc_iterator_free(ecf89839dce0fea).(struct oval_smc_iteratorcxx . . $ oval_smc_iterator# *it)
60 {
61 if (it == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
62 return;
63 oval_collection_freecxx . . $ oval_collection_free(7f543398a7666e77).(it->primary_colcxx . . $ oval_smc_iterator#primary_col.);
64 oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).(it->primary_itcxx . . $ oval_smc_iterator#primary_it.);
65 oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).(it->secondary_itcxx . . $ oval_smc_iterator#secondary_it.);
66 freecxx . . $ free(5d22bdacc48458e8).(it);
67 }
68
69 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_smc_iterator_has_morecxx . . $ oval_smc_iterator_has_more(d7926f168e3d45db).(struct oval_smc_iteratorcxx . . $ oval_smc_iterator# *it)
70 {
71 return it != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! &&
72 (oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).(it->primary_itcxx . . $ oval_smc_iterator#primary_it.) ||
73 (it->secondary_itcxx . . $ oval_smc_iterator#secondary_it. &&
74 oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).(it->secondary_itcxx . . $ oval_smc_iterator#secondary_it.)));
75 }
76
77 void *oval_smc_iterator_nextcxx . . $ oval_smc_iterator_next(aa65d553c349a165).(struct oval_smc_iteratorcxx . . $ oval_smc_iterator# *it)
78 {
79 if (it == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
80 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
81 if (it->secondary_itcxx . . $ oval_smc_iterator#secondary_it. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || !oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).(it->secondary_itcxx . . $ oval_smc_iterator#secondary_it.)) {
82 // Rewind primary and find new secondary
83 if (it->secondary_itcxx . . $ oval_smc_iterator#secondary_it. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
84 oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).(it->secondary_itcxx . . $ oval_smc_iterator#secondary_it.);
85 it->secondary_itcxx . . $ oval_smc_iterator#secondary_it. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
86 }
87 if (!oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).(it->primary_itcxx . . $ oval_smc_iterator#primary_it.)) {
88 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(false);
89 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
90 }
91 struct oval_collectioncxx . . $ oval_collection# *secondary_col = (struct oval_collectioncxx . . $ oval_collection# *) oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).(it->primary_itcxx . . $ oval_smc_iterator#primary_it.);
92 it->secondary_itcxx . . $ oval_smc_iterator#secondary_it. = oval_collection_iteratorcxx . . $ oval_collection_iterator(8bdeb6a25e21af3e).(secondary_col);
93 }
94 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(oval_collection_iterator_has_more(it->secondary_it));
95 return oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).(it->secondary_itcxx . . $ oval_smc_iterator#secondary_it.);
96 }