Debian Codegraph @

src/OVAL/oval_value.c

raw symbols SCIP
1 /**
2 * @file oval_value.c
3 * \brief Open Vulnerability and Assessment Language
4 *
5 * See more details at http://oval.mitre.org/
6 */
7
8 /*
9 * Copyright 2009--2014 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 #include <string.h>
37 #include <stdbool.h>
38
39 #include "oval_definitions_impl.h"cxx . . $ `<file>/src/OVAL/oval_definitions_impl.h`/
40 #include "adt/oval_collection_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_collection_impl.h`/
41 #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/
42 #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
43 #include "common/elements.h"cxx . . $ `<file>/src/common/elements.h`/
44
45 typedef struct oval_valuecxx . . $ oval_value# {
46 oval_datatype_tcxx . . $ oval_datatype_t# datatypecxx . . $ oval_value#datatype.;
47 char *textcxx . . $ oval_value#text.;
48 } oval_value_tcxx . . $ oval_value_t#;
49
50 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_value_iterator_has_morecxx . . $ oval_value_iterator_has_more(753adc45e63e3dec).(struct oval_value_iteratorcxx . . $ oval_value_iterator# *oc_value)
51 {
52 return oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).((struct oval_iteratorcxx . . $ oval_iterator# *)
53 oc_value);
54 }
55
56 struct oval_valuecxx . . $ oval_value# *oval_value_iterator_nextcxx . . $ oval_value_iterator_next(c6f435863c40c2c6).(struct oval_value_iteratorcxx . . $ oval_value_iterator#
57 *oc_value)
58 {
59 return (struct oval_valuecxx . . $ oval_value# *)
60 oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_value);
61 }
62
63 void oval_value_iterator_freecxx . . $ oval_value_iterator_free(1b9ed96dce1b7286).(struct oval_value_iteratorcxx . . $ oval_value_iterator#
64 *oc_value)
65 {
66 oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_value);
67 }
68
69 int oval_value_iterator_remainingcxx . . $ oval_value_iterator_remaining(4724f34e41a7ec75).(struct oval_value_iteratorcxx . . $ oval_value_iterator# *iterator)
70 {
71 return oval_collection_iterator_remainingcxx . . $ oval_collection_iterator_remaining(4404665b78efb7c8).((struct oval_iteratorcxx . . $ oval_iterator# *)iterator);
72 }
73
74 oval_datatype_tcxx . . $ oval_datatype_t# oval_value_get_datatypecxx . . $ oval_value_get_datatype(9f2201a27f3b3b4).(struct oval_valuecxx . . $ oval_value# *value)
75 {
76 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(value);
77
78 return (value)->datatypecxx . . $ oval_value#datatype.;
79 }
80
81 char *oval_value_get_textcxx . . $ oval_value_get_text(cab4e37bbd1656d5).(struct oval_valuecxx . . $ oval_value# *value)
82 {
83 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(value);
84
85 return value->textcxx . . $ oval_value#text.;
86 }
87
88 unsigned char *oval_value_get_binarycxx . . $ oval_value_get_binary(53b00c5418e475d0).(struct oval_valuecxx . . $ oval_value# *value)
89 {
90 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; //TODO: implement oval_value_binary
91 }
92
93 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_value_get_booleancxx . . $ oval_value_get_boolean(8dfe0b3bf64f23f).(struct oval_valuecxx . . $ oval_value# * value)
94 {
95 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(value);
96
97 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("false", (value)->textcxx . . $ oval_value#text.) == 0
98 || strcmpcxx . . $ strcmp(5ae29d726ae57f88).("0", (value)->textcxx . . $ oval_value#text.) == 0)
99 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
100 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
101 }
102
103 float oval_value_get_floatcxx . . $ oval_value_get_float(65ea1e3a8a2f306c).(struct oval_valuecxx . . $ oval_value# *value)
104 {
105 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(value);
106
107 char *endptr;
108 return strtofcxx . . $ strtof(b468a9b7c38cd11a).((const char *)value->textcxx . . $ oval_value#text., &endptr);
109 }
110
111 long long oval_value_get_integercxx . . $ oval_value_get_integer(342b6ffec2724d54).(struct oval_valuecxx . . $ oval_value# *value)
112 {
113 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(value);
114
115 char *endptr;
116 return strtollcxx . . $ strtoll(c50972e7488cbac6).((const char *)value->textcxx . . $ oval_value#text., &endptr, 10);
117 }
118
119 struct oval_valuecxx . . $ oval_value# *oval_value_newcxx . . $ oval_value_new(c58b1d972ef552d6).(oval_datatype_tcxx . . $ oval_datatype_t# datatype, char *text_value)
120 {
121 oval_value_tcxx . . $ oval_value_t# *value = (oval_value_tcxx . . $ oval_value_t# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_value_tcxx . . $ oval_value_t#));
122 if (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
123 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
124
125 value->datatypecxx . . $ oval_value#datatype. = datatype;
126 value->textcxx . . $ oval_value#text. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(text_value);
127 return value;
128 }
129
130
131 struct oval_valuecxx . . $ oval_value# *oval_value_clonecxx . . $ oval_value_clone(5de282da9e151d11).(struct oval_valuecxx . . $ oval_value# *old_value)
132 {
133 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(old_value);
134
135 struct oval_valuecxx . . $ oval_value# *new_value = oval_value_newcxx . . $ oval_value_new(c58b1d972ef552d6).(old_value->datatypecxx . . $ oval_value#datatype., old_value->textcxx . . $ oval_value#text.);
136 return new_value;
137 }
138
139 void oval_value_freecxx . . $ oval_value_free(d25d962808f14280).(struct oval_valuecxx . . $ oval_value# *value)
140 {
141 if (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
142 return;
143
144 freecxx . . $ free(5d22bdacc48458e8).(value->textcxx . . $ oval_value#text.);
145 freecxx . . $ free(5d22bdacc48458e8).(value);
146 }
147
148 int oval_value_castcxx . . $ oval_value_cast(c3c9a672ec64b437).(struct oval_valuecxx . . $ oval_value# *value, oval_datatype_tcxx . . $ oval_datatype_t# new_dt)
149 {
150 /*
151 oval_datatype_t old_dt;
152
153 old_dt = oval_value_get_datatype(value);
154 */
155 // todo: attempt a proper cast here
156 value->datatypecxx . . $ oval_value#datatype. = new_dt;
157
158 return 0;
159 }
160
161 void oval_value_set_datatypecxx . . $ oval_value_set_datatype(7a0d03628f42a32).(struct oval_valuecxx . . $ oval_value# *value, oval_datatype_tcxx . . $ oval_datatype_t# datatype)
162 {
163 value->datatypecxx . . $ oval_value#datatype. = datatype;
164 }
165
166 /*
167 void oval_value_set_text(struct oval_value *value, char *text)
168 {
169 if(value->text!=NULL)
170 free(value->text);
171 value->text = oscap_strdup(text);
172 }
173 */
174
175 static void oval_value_parse_tag_consume_textcxx . . $ oval_value_parse_tag_consume_text(75961c4613ebf8f5).(char *string, void *text)
176 {
177 *(char **)text = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(string);
178 }
179
180 int oval_value_parse_tagcxx . . $ oval_value_parse_tag(24b85e39d8efe8a).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader,
181 struct oval_parser_contextcxx . . $ oval_parser_context# *context, oval_value_consumercxx . . $ oval_value_consumer# consumer, void *user)
182 {
183 int return_code;
184 oval_datatype_tcxx . . $ oval_datatype_t# datatype = oval_datatype_parsecxx . . $ oval_datatype_parse(439a79c16bdf367b).(reader, "datatype", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING.);
185 char *text = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
186 int isNil = oval_parser_boolean_attributecxx . . $ oval_parser_boolean_attribute(a53adaee35698733).(reader, "xsi:nil", 0);
187 if (isNil) {
188 return_code = 0;
189 } else {
190 return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &oval_value_parse_tag_consume_textcxx . . $ oval_value_parse_tag_consume_text(75961c4613ebf8f5)., &text);
191 }
192 struct oval_valuecxx . . $ oval_value# *value = oval_value_newcxx . . $ oval_value_new(c58b1d972ef552d6).(datatype, text ? text : "");
193 freecxx . . $ free(5d22bdacc48458e8).(text);
194 (*consumer) (value, user);
195 return return_code;
196 }
197
198 xmlNodecxx . . $ xmlNode# *oval_value_to_domcxx . . $ oval_value_to_dom(1b5b8f7b29806a91).(struct oval_valuecxx . . $ oval_value# *value, xmlDoccxx . . $ xmlDoc# * doc, xmlNodecxx . . $ xmlNode# * parent) {
199 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; //TODO: implement oval_value_to_dom
200 }