Greenbone Vulnerability Management Libraries  22.8.0
xmlutils_tests.c
Go to the documentation of this file.
1 /* SPDX-FileCopyrightText: 2019-2023 Greenbone AG
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  */
5 
6 #include "xmlutils.c"
7 
8 #include <cgreen/cgreen.h>
9 #include <cgreen/mocks.h>
10 
11 Describe (xmlutils);
12 BeforeEach (xmlutils)
13 {
14 }
15 AfterEach (xmlutils)
16 {
17 }
18 
19 /* parse_entity */
20 
21 Ensure (xmlutils, parse_entity_parses_simple_xml)
22 {
23  entity_t entity, b;
24  const gchar *xml;
25 
26  xml = "<a><b>1</b></a>";
27 
28  assert_that (parse_entity (xml, &entity), is_equal_to (0));
29 
30  assert_that (entity_name (entity), is_equal_to_string ("a"));
31 
32  b = entity_child (entity, "b");
33  assert_that (entity_name (b), is_equal_to_string ("b"));
34 
35  assert_that (entity_text (b), is_equal_to_string ("1"));
36 }
37 
38 Ensure (xmlutils, parse_entity_parses_xml_with_attributes)
39 {
40  entity_t entity, b;
41  const gchar *xml;
42 
43  xml = "<a><b ba1='test'>1</b></a>";
44 
45  assert_that (parse_entity (xml, &entity), is_equal_to (0));
46 
47  b = entity_child (entity, "b");
48 
49  assert_that (entity_attribute (b, "ba1"), is_equal_to_string ("test"));
50 }
51 
52 Ensure (xmlutils, parse_entity_handles_declaration)
53 {
54  entity_t entity, b;
55  const gchar *xml;
56 
57  xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a><b ba1='test'>1</b></a>";
58 
59  assert_that (parse_entity (xml, &entity), is_equal_to (0));
60 
61  assert_that (entity_name (entity), is_equal_to_string ("a"));
62 
63  b = entity_child (entity, "b");
64  assert_that (entity_name (b), is_equal_to_string ("b"));
65 
66  assert_that (entity_text (b), is_equal_to_string ("1"));
67 }
68 
69 Ensure (xmlutils, parse_entity_handles_namespace)
70 {
71  entity_t entity, b;
72  const gchar *xml;
73 
74  xml =
75  "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a><n:b ba1='test'>1</n:b></a>";
76 
77  assert_that (parse_entity (xml, &entity), is_equal_to (0));
78 
79  assert_that (entity_name (entity), is_equal_to_string ("a"));
80 
81  b = entity_child (entity, "n:b");
82  assert_that (entity_name (b), is_equal_to_string ("n:b"));
83 
84  assert_that (entity_text (b), is_equal_to_string ("1"));
85 }
86 
87 Ensure (xmlutils, parse_entity_oval_timestamp)
88 {
89  gchar *generator_name;
90  entity_t generator, timestamp, entity;
91  const gchar *xml;
92 
93  xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
94  "<oval_definitions "
95  "xsi:schemaLocation=\"http://oval.mitre.org/XMLSchema/"
96  "oval-definitions-5 oval-definitions-schema.xsd "
97  "http://oval.mitre.org/XMLSchema/oval-definitions-5#linux "
98  "linux-definitions-schema.xsd "
99  "http://oval.mitre.org/XMLSchema/oval-definitions-5#windows "
100  "windows-definitions-schema.xsd "
101  "http://oval.mitre.org/XMLSchema/oval-definitions-5#independent "
102  "independent-definitions-schema.xsd "
103  "http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd "
104  "http://oval.mitre.org/XMLSchema/oval-definitions-5#unix "
105  "unix-definitions-schema.xsd\" "
106  "xmlns=\"http://oval.mitre.org/XMLSchema/oval-definitions-5\" "
107  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
108  "xmlns:oval=\"http://oval.mitre.org/XMLSchema/oval-common-5\" "
109  "xmlns:oval-def=\"http://oval.mitre.org/XMLSchema/oval-definitions-5\">"
110  " <generator>"
111  " <oval:product_name>The OVAL Repository</oval:product_name>"
112  " <oval:schema_version>5.10</oval:schema_version>"
113  " <oval:timestamp>2015-08-20T10:09:07.183-04:00</oval:timestamp>"
114  " </generator>"
115  "</oval_definitions>";
116 
117  assert_that (parse_entity (xml, &entity), is_equal_to (0));
118 
119  assert_that (entity_name (entity), is_equal_to_string ("oval_definitions"));
120  generator_name = g_strdup ("generator");
121  generator = entity_child (entity, generator_name);
122  g_free (generator_name);
123  assert_that (generator, is_not_null);
124  timestamp = entity_child (generator, "oval:timestamp");
125  assert_that (timestamp, is_not_null);
126  assert_that (entity_text (timestamp),
127  is_equal_to_string ("2015-08-20T10:09:07.183-04:00"));
128 }
129 
130 /* next_entities. */
131 
132 Ensure (xmlutils, next_entities_handles_multiple_children)
133 {
134  entity_t entity, child;
135  entities_t children;
136  const gchar *xml;
137 
138  xml = "<top><a>1</a><b></b><c>3</c></top>";
139 
140  assert_that (parse_entity (xml, &entity), is_equal_to (0));
141 
142  assert_that (entity_name (entity), is_equal_to_string ("top"));
143 
144  children = entity->entities;
145 
146  child = first_entity (children);
147  assert_that (child, is_not_null);
148  assert_that (entity_name (child), is_equal_to_string ("a"));
149  assert_that (entity_text (child), is_equal_to_string ("1"));
150  children = next_entities (children);
151 
152  child = first_entity (children);
153  assert_that (child, is_not_null);
154  assert_that (entity_name (child), is_equal_to_string ("b"));
155  assert_that (entity_text (child), is_equal_to_string (""));
156  children = next_entities (children);
157 
158  child = first_entity (children);
159  assert_that (child, is_not_null);
160  assert_that (entity_name (child), is_equal_to_string ("c"));
161  assert_that (entity_text (child), is_equal_to_string ("3"));
162  children = next_entities (children);
163 }
164 
165 /* parse_element */
166 
167 Ensure (xmlutils, parse_element_parses_simple_xml)
168 {
169  element_t element, b;
170  const gchar *xml;
171 
172  xml = "<a><b>1</b></a>";
173 
174  assert_that (parse_element (xml, &element), is_equal_to (0));
175 
176  assert_that (element_name (element), is_equal_to_string ("a"));
177 
178  b = element_child (element, "b");
179  assert_that (element_name (b), is_equal_to_string ("b"));
180 
181  assert_that (element_text (b), is_equal_to_string ("1"));
182 }
183 
184 Ensure (xmlutils, parse_element_parses_xml_with_attributes)
185 {
186  element_t element, b;
187  const gchar *xml;
188 
189  xml = "<a><b ba1='test'>1</b></a>";
190 
191  assert_that (parse_element (xml, &element), is_equal_to (0));
192 
193  b = element_child (element, "b");
194 
195  assert_that (element_attribute (b, "ba1"), is_equal_to_string ("test"));
196 }
197 
198 Ensure (xmlutils, parse_element_handles_declaration)
199 {
200  element_t element, b;
201  const gchar *xml;
202 
203  xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a><b ba1='test'>1</b></a>";
204 
205  assert_that (parse_element (xml, &element), is_equal_to (0));
206 
207  assert_that (element_name (element), is_equal_to_string ("a"));
208 
209  b = element_child (element, "b");
210  assert_that (element_name (b), is_equal_to_string ("b"));
211 
212  assert_that (element_text (b), is_equal_to_string ("1"));
213 }
214 
215 Ensure (xmlutils, parse_element_handles_namespace)
216 {
217  element_t element, b;
218  const gchar *xml;
219 
220  xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a><n:b ba1='test' "
221  "n2:ba2='test2'>1</n:b></a>";
222 
223  assert_that (parse_element (xml, &element), is_equal_to (0));
224 
225  assert_that (element_name (element), is_equal_to_string ("a"));
226 
227  b = element_child (element, "n:b");
228  assert_that (element_name (b), is_equal_to_string ("n:b"));
229 
230  assert_that (element_text (b), is_equal_to_string ("1"));
231 
232  assert_that (element_attribute (b, "n2:ba2"), is_equal_to_string ("test2"));
233 }
234 
235 Ensure (xmlutils, parse_element_oval_timestamp)
236 {
237  gchar *generator_name;
238  element_t generator, timestamp, element;
239  const gchar *xml;
240 
241  xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
242  "<oval_definitions "
243  "xsi:schemaLocation=\"http://oval.mitre.org/XMLSchema/"
244  "oval-definitions-5 oval-definitions-schema.xsd "
245  "http://oval.mitre.org/XMLSchema/oval-definitions-5#linux "
246  "linux-definitions-schema.xsd "
247  "http://oval.mitre.org/XMLSchema/oval-definitions-5#windows "
248  "windows-definitions-schema.xsd "
249  "http://oval.mitre.org/XMLSchema/oval-definitions-5#independent "
250  "independent-definitions-schema.xsd "
251  "http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd "
252  "http://oval.mitre.org/XMLSchema/oval-definitions-5#unix "
253  "unix-definitions-schema.xsd\" "
254  "xmlns=\"http://oval.mitre.org/XMLSchema/oval-definitions-5\" "
255  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
256  "xmlns:oval=\"http://oval.mitre.org/XMLSchema/oval-common-5\" "
257  "xmlns:oval-def=\"http://oval.mitre.org/XMLSchema/oval-definitions-5\">"
258  " <generator>"
259  " <oval:product_name>The OVAL Repository</oval:product_name>"
260  " <oval:schema_version>5.10</oval:schema_version>"
261  " <oval:timestamp>2015-08-20T10:09:07.183-04:00</oval:timestamp>"
262  " </generator>"
263  "</oval_definitions>";
264 
265  assert_that (parse_element (xml, &element), is_equal_to (0));
266 
267  assert_that (element_name (element), is_equal_to_string ("oval_definitions"));
268  generator_name = g_strdup ("generator");
269  generator = element_child (element, generator_name);
270  g_free (generator_name);
271  assert_that (generator, is_not_null);
272  timestamp = element_child (generator, "oval:timestamp");
273  assert_that (timestamp, is_not_null);
274  assert_that (element_text (timestamp),
275  is_equal_to_string ("2015-08-20T10:09:07.183-04:00"));
276 }
277 
278 Ensure (xmlutils, parse_element_item_metadata)
279 {
280  element_t element, item, meta;
281  const gchar *xml;
282 
283  xml = "<cpe-list>"
284  " <cpe-item "
285  "name=\"cpe:/"
286  "a:%240.99_kindle_books_project:%240.99_kindle_books:6::~~~android~~\">"
287  " <title xml:lang=\"en-US\">$0.99 Kindle Books project $0.99 Kindle "
288  "Books (aka com.kindle.books.for99) for android 6.0</title>"
289  " <references>"
290  " <reference "
291  "href=\"https://play.google.com/store/apps/"
292  "details?id=com.kindle.books.for99\">Product information</reference>"
293  " <reference "
294  "href=\"https://docs.google.com/spreadsheets/d/"
295  "1t5GXwjw82SyunALVJb2w0zi3FoLRIkfGPc7AMjRF0r4/"
296  "edit?pli=1#gid=1053404143\">Government Advisory</reference>"
297  " </references>"
298  " <meta:item-metadata nvd-id=\"289692\" status=\"FINAL\" "
299  "modification-date=\"2014-11-10T17:01:25.103Z\"/>"
300  " </cpe-item>"
301  "</cpe-list>";
302 
303  assert_that (parse_element (xml, &element), is_equal_to (0));
304 
305  assert_that (element_name (element), is_equal_to_string ("cpe-list"));
306  item = element_child (element, "cpe-item");
307  assert_that (item, is_not_null);
308  meta = element_child (item, "meta:item-metadata");
309  assert_that (meta, is_not_null);
310  assert_that (element_name (meta), is_equal_to_string ("meta:item-metadata"));
311 }
312 
313 Ensure (xmlutils, parse_element_item_metadata_with_namespace)
314 {
315  element_t element, item, meta;
316  const gchar *xml;
317 
318  xml = "<cpe-list xmlns=\"http://cpe.mitre.org/dictionary/2.0\" "
319  "xmlns:ns6=\"http://scap.nist.gov/schema/scap-core/0.1\" "
320  "xmlns:config=\"http://scap.nist.gov/schema/configuration/0.1\" "
321  "xmlns:meta=\"http://scap.nist.gov/schema/cpe-dictionary-metadata/"
322  "0.2\" xmlns:cpe-23=\"http://scap.nist.gov/schema/cpe-extension/2.3\" "
323  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
324  "xmlns:scap-core=\"http://scap.nist.gov/schema/scap-core/0.3\" "
325  "xsi:schemaLocation=\"http://cpe.mitre.org/dictionary/2.0 "
326  "https://scap.nist.gov/schema/cpe/2.2/cpe-dictionary_2.2.xsd "
327  "http://scap.nist.gov/schema/cpe-dictionary-metadata/0.2 "
328  "https://scap.nist.gov/schema/cpe/2.1/cpe-dictionary-metadata_0.2.xsd "
329  "http://scap.nist.gov/schema/scap-core/0.3 "
330  "https://scap.nist.gov/schema/nvd/scap-core_0.3.xsd "
331  "http://scap.nist.gov/schema/configuration/0.1 "
332  "https://scap.nist.gov/schema/nvd/configuration_0.1.xsd "
333  "http://scap.nist.gov/schema/scap-core/0.1 "
334  "https://scap.nist.gov/schema/nvd/scap-core_0.1.xsd\">"
335  " <cpe-item "
336  "name=\"cpe:/"
337  "a:%240.99_kindle_books_project:%240.99_kindle_books:6::~~~android~~\">"
338  " <title xml:lang=\"en-US\">$0.99 Kindle Books project $0.99 Kindle "
339  "Books (aka com.kindle.books.for99) for android 6.0</title>"
340  " <references>"
341  " <reference "
342  "href=\"https://play.google.com/store/apps/"
343  "details?id=com.kindle.books.for99\">Product information</reference>"
344  " <reference "
345  "href=\"https://docs.google.com/spreadsheets/d/"
346  "1t5GXwjw82SyunALVJb2w0zi3FoLRIkfGPc7AMjRF0r4/"
347  "edit?pli=1#gid=1053404143\">Government Advisory</reference>"
348  " </references>"
349  " <meta:item-metadata nvd-id=\"289692\" status=\"FINAL\" "
350  "modification-date=\"2014-11-10T17:01:25.103Z\"/>"
351  " </cpe-item>"
352  "</cpe-list>";
353 
354  assert_that (parse_element (xml, &element), is_equal_to (0));
355 
356  assert_that (element_name (element), is_equal_to_string ("cpe-list"));
357  item = element_child (element, "cpe-item");
358  assert_that (item, is_not_null);
359  meta = element_child (item, "item-metadata");
360  assert_that (meta, is_not_null);
361  // NB
362  assert_that (element_name (meta), is_equal_to_string ("item-metadata"));
363  // assert_that (element_name (meta), is_equal_to_string
364  // ("meta:item-metadata"));
365 }
366 
367 Ensure (xmlutils, parse_element_item_handles_cdata)
368 {
369  element_t element;
370  const gchar *xml;
371 
372  xml =
373  "<description><![CDATA[Several vulnerabilities were discovered in the "
374  "Chromium browser. The Common Vulnerabilities and Exposures project "
375  "identifies the following problems: CVE-2011-1108 Google Chrome before "
376  "9.0.597.107 does not properly implement JavaScript dialogs, which allows "
377  "remote attackers to cause a denial of service or possibly have "
378  "unspecified other impact via a crafted HTML document. CVE-2011-1109 "
379  "Google Chrome before 9.0.597.107 does not properly process nodes in "
380  "Cascading Style Sheets stylesheets, which allows remote attackers to "
381  "cause a denial of service or possibly have unspecified other impact via "
382  "unknown vectors that lead to a &quot;stale pointer.&quot; CVE-2011-1113 "
383  "Google Chrome before 9.0.597.107 on 64-bit Linux platforms does not "
384  "properly perform pickle deserialization, which allows remote attackers to "
385  "cause a denial of service via unspecified vectors. CVE-2011-1114 Google "
386  "Chrome before 9.0.597.107 does not properly handle tables, which allows "
387  "remote attackers to cause a denial of service or possibly have "
388  "unspecified other impact via unknown vectors that lead to a &quot;stale "
389  "node.&quot; CVE-2011-1115 Google Chrome before 9.0.597.107 does not "
390  "properly render tables, which allows remote attackers to cause a denial "
391  "of service or possibly have unspecified other impact via unknown vectors "
392  "that lead to a &quot;stale pointer.&quot; CVE-2011-1121 Integer overflow "
393  "in Google Chrome before 9.0.597.107 allows remote attackers to cause a "
394  "denial of service or possibly have unspecified other impact via vectors "
395  "involving a TEXTAREA element. CVE-2011-1122 The WebGL implementation in "
396  "Google Chrome before 9.0.597.107 allows remote attackers to cause a "
397  "denial of service via unspecified vectors, aka Issue 71960. In addition, "
398  "this upload fixes the following issues : Out-of-bounds read in text "
399  "searching [69640] Memory corruption in SVG fonts. [72134] Memory "
400  "corruption with counter nodes. [69628] Stale node in box layout. [70027] "
401  "Cross-origin error message leak with workers. [70336] Stale pointer in "
402  "table painting. [72028] Stale pointer with SVG cursors. "
403  "[73746]]]></description>";
404 
405  assert_that (parse_element (xml, &element), is_equal_to (0));
406  assert_that (element_name (element), is_equal_to_string ("description"));
407  assert_that (
408  element_text (element),
409  is_equal_to_string (
410  "Several vulnerabilities were discovered in the Chromium browser. The "
411  "Common Vulnerabilities and Exposures project identifies the following "
412  "problems: CVE-2011-1108 Google Chrome before 9.0.597.107 does not "
413  "properly implement JavaScript dialogs, which allows remote attackers to "
414  "cause a denial of service or possibly have unspecified other impact via "
415  "a crafted HTML document. CVE-2011-1109 Google Chrome before 9.0.597.107 "
416  "does not properly process nodes in Cascading Style Sheets stylesheets, "
417  "which allows remote attackers to cause a denial of service or possibly "
418  "have unspecified other impact via unknown vectors that lead to a "
419  "&quot;stale pointer.&quot; CVE-2011-1113 Google Chrome before "
420  "9.0.597.107 on 64-bit Linux platforms does not properly perform pickle "
421  "deserialization, which allows remote attackers to cause a denial of "
422  "service via unspecified vectors. CVE-2011-1114 Google Chrome before "
423  "9.0.597.107 does not properly handle tables, which allows remote "
424  "attackers to cause a denial of service or possibly have unspecified "
425  "other impact via unknown vectors that lead to a &quot;stale node.&quot; "
426  "CVE-2011-1115 Google Chrome before 9.0.597.107 does not properly render "
427  "tables, which allows remote attackers to cause a denial of service or "
428  "possibly have unspecified other impact via unknown vectors that lead to "
429  "a &quot;stale pointer.&quot; CVE-2011-1121 Integer overflow in Google "
430  "Chrome before 9.0.597.107 allows remote attackers to cause a denial of "
431  "service or possibly have unspecified other impact via vectors involving "
432  "a TEXTAREA element. CVE-2011-1122 The WebGL implementation in Google "
433  "Chrome before 9.0.597.107 allows remote attackers to cause a denial of "
434  "service via unspecified vectors, aka Issue 71960. In addition, this "
435  "upload fixes the following issues : Out-of-bounds read in text "
436  "searching [69640] Memory corruption in SVG fonts. [72134] Memory "
437  "corruption with counter nodes. [69628] Stale node in box layout. "
438  "[70027] Cross-origin error message leak with workers. [70336] Stale "
439  "pointer in table painting. [72028] Stale pointer with SVG cursors. "
440  "[73746]"));
441 }
442 
443 /* element_next. */
444 
445 Ensure (xmlutils, element_next_handles_multiple_children)
446 {
447  element_t element, child;
448  const gchar *xml;
449 
450  xml = "<top><a>1</a><b>2</b><c>3</c></top>";
451 
452  assert_that (parse_element (xml, &element), is_equal_to (0));
453 
454  assert_that (element_name (element), is_equal_to_string ("top"));
455 
456  child = element_first_child (element);
457  assert_that (child, is_not_null);
458  assert_that (element_name (child), is_equal_to_string ("a"));
459  assert_that (element_text (child), is_equal_to_string ("1"));
460 
461  child = element_next (child);
462  assert_that (child, is_not_null);
463  assert_that (element_name (child), is_equal_to_string ("b"));
464  assert_that (element_text (child), is_equal_to_string ("2"));
465 
466  child = element_next (child);
467  assert_that (child, is_not_null);
468  assert_that (element_name (child), is_equal_to_string ("c"));
469  assert_that (element_text (child), is_equal_to_string ("3"));
470 }
471 
472 Ensure (xmlutils, parse_element_free_using_child)
473 {
474  element_t element;
475  const gchar *xml;
476 
477  xml = "<a><b><c>1</c></b></a>";
478 
479  assert_that (parse_element (xml, &element), is_equal_to (0));
480  assert_that (element_name (element), is_equal_to_string ("a"));
481  element = element_child (element, "b");
482  assert_that (element, is_not_null);
483  element = element_child (element, "c");
484  assert_that (element, is_not_null);
485  element_free (element);
486 }
487 
488 Ensure (xmlutils, print_element_to_string_prints)
489 {
490  element_t element;
491  const gchar *xml;
492  GString *str;
493 
494  xml = "<a aa=\"1\">a text<b><c ca=\"x\" ca2=\"y\">1</c><d/><e></e></b> and "
495  "more a text</a>";
496  str = g_string_new ("");
497 
498  assert_that (parse_element (xml, &element), is_equal_to (0));
499  print_element_to_string (element, str);
500  assert_that (str->str, is_equal_to_string (
501  "<a aa=\"1\">a text and more a text<b><c ca=\"x\" "
502  "ca2=\"y\">1</c><d></d><e></e></b></a>"));
503  g_string_free (str, TRUE);
504  element_free (element);
505 }
506 
507 /* Test suite. */
508 
509 int
510 main (int argc, char **argv)
511 {
512  TestSuite *suite;
513 
514  suite = create_test_suite ();
515 
516  add_test_with_context (suite, xmlutils, parse_entity_parses_simple_xml);
517  add_test_with_context (suite, xmlutils,
518  parse_entity_parses_xml_with_attributes);
519  add_test_with_context (suite, xmlutils, parse_entity_handles_declaration);
520  add_test_with_context (suite, xmlutils, parse_entity_handles_namespace);
521  add_test_with_context (suite, xmlutils, parse_entity_oval_timestamp);
522 
523  add_test_with_context (suite, xmlutils,
524  next_entities_handles_multiple_children);
525 
526  add_test_with_context (suite, xmlutils, parse_element_parses_simple_xml);
527  add_test_with_context (suite, xmlutils,
528  parse_element_parses_xml_with_attributes);
529  add_test_with_context (suite, xmlutils, parse_element_handles_declaration);
530  add_test_with_context (suite, xmlutils, parse_element_handles_namespace);
531  add_test_with_context (suite, xmlutils, parse_element_oval_timestamp);
532  add_test_with_context (suite, xmlutils, parse_element_item_metadata);
533  add_test_with_context (suite, xmlutils,
534  parse_element_item_metadata_with_namespace);
535  add_test_with_context (suite, xmlutils, parse_element_item_handles_cdata);
536  add_test_with_context (suite, xmlutils, parse_element_free_using_child);
537 
538  add_test_with_context (suite, xmlutils, print_element_to_string_prints);
539 
540  add_test_with_context (suite, xmlutils,
541  element_next_handles_multiple_children);
542 
543  if (argc > 1)
544  return run_single_test (suite, argv[1], create_text_reporter ());
545 
546  return run_test_suite (suite, create_text_reporter ());
547 }
element_text
gchar * element_text(element_t element)
Get text of an element.
Definition: xmlutils.c:2133
entity_attribute
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition: xmlutils.c:216
element_attribute
gchar * element_attribute(element_t element, const gchar *name)
Get an attribute of an element.
Definition: xmlutils.c:2158
entity_child
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition: xmlutils.c:193
element_child
element_t element_child(element_t element, const gchar *name)
Get a child of an element.
Definition: xmlutils.c:2082
BeforeEach
BeforeEach(xmlutils)
Definition: xmlutils_tests.c:12
first_entity
entity_t first_entity(entities_t entities)
Return the first entity from an entities_t.
Definition: xmlutils.c:82
AfterEach
AfterEach(xmlutils)
Definition: xmlutils_tests.c:15
entity_s::entities
entities_t entities
Children.
Definition: xmlutils.h:56
entity_text
char * entity_text(entity_t entity)
Get the text an entity.
Definition: xmlutils.c:145
parse_element
int parse_element(const gchar *string, element_t *element)
Read an XML element tree from a string.
Definition: xmlutils.c:1999
element_first_child
element_t element_first_child(element_t element)
Get the first child of an element.
Definition: xmlutils.c:2206
main
int main(int argc, char **argv)
Definition: xmlutils_tests.c:510
entity_name
char * entity_name(entity_t entity)
Get the name an entity.
Definition: xmlutils.c:161
next_entities
entities_t next_entities(entities_t entities)
Return all the entities from an entities_t after the first.
Definition: xmlutils.c:67
Describe
Describe(xmlutils)
element_t
struct _xmlNode * element_t
Definition: xmlutils.h:157
print_element_to_string
void print_element_to_string(element_t element, GString *string)
Print an XML element tree to a GString, appending it if string is not.
Definition: xmlutils.c:2276
xmlutils.c
Simple XML reader.
element_free
void element_free(element_t element)
Free an entire element tree.
Definition: xmlutils.c:2031
element_name
const gchar * element_name(element_t element)
Get the name of an element.
Definition: xmlutils.c:2048
entity_s
XML element.
Definition: xmlutils.h:52
element_next
element_t element_next(element_t element)
Get the next sibling of an element.
Definition: xmlutils.c:2226
Ensure
Ensure(xmlutils, parse_entity_parses_simple_xml)
Definition: xmlutils_tests.c:21
entities_t
GSList * entities_t
Entities.
Definition: xmlutils.h:46
parse_entity
int parse_entity(const char *string, entity_t *entity)
Read an XML entity tree from a string.
Definition: xmlutils.c:1511