| 1 | /** |
| 2 | * @file oval_filter.c |
| 3 | * @brief OVAL filter data type implementation |
| 4 | * @author "Tomas Heinrich" <[email protected]> |
| 5 | * |
| 6 | * @addtogroup OVALDEF |
| 7 | * @{ |
| 8 | */ |
| 9 | /* |
| 10 | * Copyright 2010--2014 Red Hat Inc., Durham, North Carolina. |
| 11 | * All Rights Reserved. |
| 12 | * |
| 13 | * This library is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU Lesser General Public |
| 15 | * License as published by the Free Software Foundation; either |
| 16 | * version 2.1 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * This library is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | * Lesser General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU Lesser General Public |
| 24 | * License along with this library; if not, write to the Free Software |
| 25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 26 | * |
| 27 | * Authors: |
| 28 | * "Tomas Heinrich" <[email protected]> |
| 29 | */ |
| 30 | |
| 31 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 32 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 33 | #endif |
| 34 | |
| 35 | #include <string.h> |
| 36 | #include <stdlib.h> |
| 37 | |
| 38 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 39 | #include "common/elements.h"cxx . . $ `<file>/src/common/elements.h`/ |
| 40 | #include "oval_agent_api_impl.h"cxx . . $ `<file>/src/OVAL/oval_agent_api_impl.h`/ |
| 41 | #include "oval_definitions_impl.h"cxx . . $ `<file>/src/OVAL/oval_definitions_impl.h`/ |
| 42 | |
| 43 | struct oval_filtercxx . . $ oval_filter# { |
| 44 | struct oval_definition_modelcxx . . $ oval_definition_model# *modelcxx . . $ oval_filter#model.; |
| 45 | struct oval_statecxx . . $ oval_state# *statecxx . . $ oval_filter#state.; |
| 46 | oval_filter_action_tcxx . . $ oval_filter_action_t# actioncxx . . $ oval_filter#action.; |
| 47 | }; |
| 48 | |
| 49 | struct oval_filtercxx . . $ oval_filter# *oval_filter_newcxx . . $ oval_filter_new(50fad35bd0013fea).(struct oval_definition_modelcxx . . $ oval_definition_model# *model) |
| 50 | { |
| 51 | struct oval_filtercxx . . $ oval_filter# *filter; |
| 52 | |
| 53 | filter = (struct oval_filtercxx . . $ oval_filter# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof (struct oval_filtercxx . . $ oval_filter#)); |
| 54 | if (filter == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 55 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 56 | |
| 57 | filter->modelcxx . . $ oval_filter#model. = model; |
| 58 | filter->statecxx . . $ oval_filter#state. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 59 | filter->actioncxx . . $ oval_filter#action. = OVAL_FILTER_ACTION_UNKNOWNcxx . . $ OVAL_FILTER_ACTION_UNKNOWN.; |
| 60 | return filter; |
| 61 | } |
| 62 | |
| 63 | void oval_filter_freecxx . . $ oval_filter_free(e95a45dff1204a78).(struct oval_filtercxx . . $ oval_filter# *filter) |
| 64 | { |
| 65 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(filter); |
| 66 | |
| 67 | filter->modelcxx . . $ oval_filter#model. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 68 | filter->statecxx . . $ oval_filter#state. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 69 | freecxx . . $ free(5d22bdacc48458e8).(filter); |
| 70 | } |
| 71 | |
| 72 | struct oval_filtercxx . . $ oval_filter# *oval_filter_clonecxx . . $ oval_filter_clone(936b229ce6f90811).(struct oval_definition_modelcxx . . $ oval_definition_model# *new_model, |
| 73 | struct oval_filtercxx . . $ oval_filter# *old_filter) |
| 74 | { |
| 75 | struct oval_filtercxx . . $ oval_filter# *new_filter; |
| 76 | struct oval_statecxx . . $ oval_state# *ste; |
| 77 | oval_filter_action_tcxx . . $ oval_filter_action_t# fa; |
| 78 | |
| 79 | new_filter = oval_filter_newcxx . . $ oval_filter_new(50fad35bd0013fea).(new_model); |
| 80 | ste = oval_filter_get_statecxx . . $ oval_filter_get_state(4b60831d8443711d).(old_filter); |
| 81 | ste = oval_state_clonecxx . . $ oval_state_clone(4b918e9848c3d95f).(new_model, ste); |
| 82 | oval_filter_set_statecxx . . $ oval_filter_set_state(69867ebc2bfefcff).(new_filter, ste); |
| 83 | fa = oval_filter_get_filter_actioncxx . . $ oval_filter_get_filter_action(15d7b7da5646a184).(old_filter); |
| 84 | oval_filter_set_filter_actioncxx . . $ oval_filter_set_filter_action(f8e41038352b6f09).(new_filter, fa); |
| 85 | |
| 86 | return new_filter; |
| 87 | } |
| 88 | |
| 89 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_filter_iterator_has_morecxx . . $ oval_filter_iterator_has_more(1c196fda7090525b).(struct oval_filter_iteratorcxx . . $ oval_filter_iterator# *oc_filter) |
| 90 | { |
| 91 | return oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).((struct oval_iteratorcxx . . $ oval_iterator# *) oc_filter); |
| 92 | } |
| 93 | |
| 94 | struct oval_filtercxx . . $ oval_filter# *oval_filter_iterator_nextcxx . . $ oval_filter_iterator_next(54517aa6f88ff9ef).(struct oval_filter_iteratorcxx . . $ oval_filter_iterator# *oc_filter) |
| 95 | { |
| 96 | return (struct oval_filtercxx . . $ oval_filter# *) |
| 97 | oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).((struct oval_iteratorcxx . . $ oval_iterator# *) oc_filter); |
| 98 | } |
| 99 | |
| 100 | void oval_filter_iterator_freecxx . . $ oval_filter_iterator_free(af72975b992300c1).(struct oval_filter_iteratorcxx . . $ oval_filter_iterator# *oc_filter) |
| 101 | { |
| 102 | oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).((struct oval_iteratorcxx . . $ oval_iterator# *) oc_filter); |
| 103 | } |
| 104 | |
| 105 | struct oval_statecxx . . $ oval_state# *oval_filter_get_statecxx . . $ oval_filter_get_state(4b60831d8443711d).(struct oval_filtercxx . . $ oval_filter# *filter) |
| 106 | { |
| 107 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(filter); |
| 108 | |
| 109 | return filter->statecxx . . $ oval_filter#state.; |
| 110 | } |
| 111 | |
| 112 | oval_filter_action_tcxx . . $ oval_filter_action_t# oval_filter_get_filter_actioncxx . . $ oval_filter_get_filter_action(15d7b7da5646a184).(struct oval_filtercxx . . $ oval_filter# *filter) |
| 113 | { |
| 114 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(filter); |
| 115 | |
| 116 | return filter->actioncxx . . $ oval_filter#action.; |
| 117 | } |
| 118 | |
| 119 | void oval_filter_set_statecxx . . $ oval_filter_set_state(69867ebc2bfefcff).(struct oval_filtercxx . . $ oval_filter# *filter, struct oval_statecxx . . $ oval_state# *state) |
| 120 | { |
| 121 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(filter); |
| 122 | filter->statecxx . . $ oval_filter#state. = state; |
| 123 | } |
| 124 | |
| 125 | void oval_filter_set_filter_actioncxx . . $ oval_filter_set_filter_action(f8e41038352b6f09).(struct oval_filtercxx . . $ oval_filter# *filter, oval_filter_action_tcxx . . $ oval_filter_action_t# action) |
| 126 | { |
| 127 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(filter); |
| 128 | filter->actioncxx . . $ oval_filter#action. = action; |
| 129 | } |
| 130 | |
| 131 | static void _oval_filter_consume_ste_refcxx . . $ _oval_filter_consume_ste_ref(75961c4613ebf8f5).(char *steref, void *user) |
| 132 | { |
| 133 | struct oval_filtercxx . . $ oval_filter# *filter; |
| 134 | struct oval_statecxx . . $ oval_state# *ste; |
| 135 | |
| 136 | filter = (struct oval_filtercxx . . $ oval_filter# *) user; |
| 137 | ste = oval_definition_model_get_new_statecxx . . $ oval_definition_model_get_new_state(a16da6d5657b0c91).(filter->modelcxx . . $ oval_filter#model., steref); |
| 138 | oval_filter_set_statecxx . . $ oval_filter_set_state(69867ebc2bfefcff).(filter, ste); |
| 139 | } |
| 140 | |
| 141 | int oval_filter_parse_tagcxx . . $ oval_filter_parse_tag(12dbcd5e25ab57e3).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, struct oval_parser_contextcxx . . $ oval_parser_context# *context, |
| 142 | oval_filter_consumercxx . . $ oval_filter_consumer# consumer, void *user) |
| 143 | { |
| 144 | struct oval_filtercxx . . $ oval_filter# *filter; |
| 145 | oval_filter_action_tcxx . . $ oval_filter_action_t# fa; |
| 146 | int return_code; |
| 147 | |
| 148 | filter = oval_filter_newcxx . . $ oval_filter_new(50fad35bd0013fea).(context->definition_modelcxx . . $ oval_parser_context#definition_model.); |
| 149 | fa = oval_filter_action_parsecxx . . $ oval_filter_action_parse(406b84d9d97f85b1).(reader, "action", OVAL_FILTER_ACTION_EXCLUDEcxx . . $ OVAL_FILTER_ACTION_EXCLUDE.); |
| 150 | oval_filter_set_filter_actioncxx . . $ oval_filter_set_filter_action(f8e41038352b6f09).(filter, fa); |
| 151 | return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &_oval_filter_consume_ste_refcxx . . $ _oval_filter_consume_ste_ref(75961c4613ebf8f5)., filter); |
| 152 | |
| 153 | (*consumer) (filter, user); |
| 154 | |
| 155 | return return_code; |
| 156 | } |
| 157 | |
| 158 | xmlNodecxx . . $ xmlNode# *oval_filter_to_domcxx . . $ oval_filter_to_dom(20c739d1ed25bde8).(struct oval_filtercxx . . $ oval_filter# *filter, xmlDoccxx . . $ xmlDoc# *doc, xmlNodecxx . . $ xmlNode# *parent) |
| 159 | { |
| 160 | struct oval_statecxx . . $ oval_state# *ste; |
| 161 | char *ste_id; |
| 162 | oval_filter_action_tcxx . . $ oval_filter_action_t# fact; |
| 163 | xmlNscxx . . $ xmlNs# *ns_definitions; |
| 164 | xmlNodecxx . . $ xmlNode# *filter_node; |
| 165 | |
| 166 | ste = oval_filter_get_statecxx . . $ oval_filter_get_state(4b60831d8443711d).(filter); |
| 167 | ste_id = oval_state_get_idcxx . . $ oval_state_get_id(3f993b0a468bf006).(ste); |
| 168 | fact = oval_filter_get_filter_actioncxx . . $ oval_filter_get_filter_action(15d7b7da5646a184).(filter); |
| 169 | ns_definitions = xmlSearchNsByHrefcxx . . $ xmlSearchNsByHref(d0fb0b6b99319c4).(doc, parent, OVAL_DEFINITIONS_NAMESPACEcxx . . $ `src/OVAL/oval_agent_api_impl.h:50:9`!); |
| 170 | filter_node = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(parent, ns_definitions, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "filter", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! ste_id); |
| 171 | if (fact != OVAL_FILTER_ACTION_EXCLUDEcxx . . $ OVAL_FILTER_ACTION_EXCLUDE.) |
| 172 | xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(filter_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "action", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_filter_action_get_textcxx . . $ oval_filter_action_get_text(f6f4ab580eb4714a).(fact)); |
| 173 | |
| 174 | return filter_node; |
| 175 | } |
| 176 | |
| 177 | /// @} |