| 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 | * Martin Preisler <[email protected]> |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 24 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 25 | #endif |
| 26 | |
| 27 | #include "ds_common.h"cxx . . $ `<file>/src/DS/ds_common.h`/ |
| 28 | #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/ |
| 29 | #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 30 | #include "common/oscap_acquire.h"cxx . . $ `<file>/src/common/oscap_acquire.h`/ |
| 31 | #include "source/public/oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/ |
| 32 | #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/ |
| 33 | |
| 34 | #include <libxml/tree.h> |
| 35 | |
| 36 | xmlDoccxx . . $ xmlDoc# *ds_doc_from_foreign_nodecxx . . $ ds_doc_from_foreign_node(c7a03b65c170feae).(xmlNodecxx . . $ xmlNode# *node, xmlDoccxx . . $ xmlDoc# *parent) |
| 37 | { |
| 38 | xmlDOMWrapCtxtPtrcxx . . $ xmlDOMWrapCtxtPtr# wrap_ctxt = xmlDOMWrapNewCtxtcxx . . $ xmlDOMWrapNewCtxt(cf68cd44886dfff6).(); |
| 39 | xmlDocPtrcxx . . $ xmlDocPtr# new_doc = xmlNewDoccxx . . $ xmlNewDoc(6ad5ddcc52642397).(BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "1.0"); |
| 40 | xmlNodePtrcxx . . $ xmlNodePtr# res_node = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 41 | if (xmlDOMWrapCloneNodecxx . . $ xmlDOMWrapCloneNode(1d59bf3bdf7b6ffa).(wrap_ctxt, parent, node, &res_node, new_doc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 1, 0) != 0) |
| 42 | { |
| 43 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Error when cloning node '%s' while dumping component " |
| 44 | "from DataStream", node->name); |
| 45 | xmlFreeDoccxx . . $ xmlFreeDoc(42de24d0ab3f771).(new_doc); |
| 46 | xmlDOMWrapFreeCtxtcxx . . $ xmlDOMWrapFreeCtxt(e842b388ca82d286).(wrap_ctxt); |
| 47 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 48 | } |
| 49 | xmlDocSetRootElementcxx . . $ xmlDocSetRootElement(ad0e42d5f79fdac5).(new_doc, res_node); |
| 50 | if (xmlDOMWrapReconcileNamespacescxx . . $ xmlDOMWrapReconcileNamespaces(d2ba4bf5093ab1a3).(wrap_ctxt, res_node, 0) != 0) |
| 51 | { |
| 52 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, "Internal libxml error when reconciling namespaces " |
| 53 | "for node '%s' while dumping component.", node->name); |
| 54 | xmlFreeDoccxx . . $ xmlFreeDoc(42de24d0ab3f771).(new_doc); |
| 55 | xmlDOMWrapFreeCtxtcxx . . $ xmlDOMWrapFreeCtxt(e842b388ca82d286).(wrap_ctxt); |
| 56 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 57 | } |
| 58 | xmlDOMWrapFreeCtxtcxx . . $ xmlDOMWrapFreeCtxt(e842b388ca82d286).(wrap_ctxt); |
| 59 | return new_doc; |
| 60 | } |
| 61 | |
| 62 | int ds_dump_component_sourcescxx . . $ ds_dump_component_sources(a69679bdbc451fa5).(struct oscap_htablecxx . . $ oscap_htable# *component_sources, const char *target_dir) |
| 63 | { |
| 64 | struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit = oscap_htable_iterator_newcxx . . $ oscap_htable_iterator_new(81743c99830972e7).(component_sources); |
| 65 | while (oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(hit)) { |
| 66 | struct oscap_sourcecxx . . $ oscap_source# *s = oscap_htable_iterator_next_valuecxx . . $ oscap_htable_iterator_next_value(4e1156670e4376db).(hit); |
| 67 | char *filename = target_dir == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(oscap_source_readable_origincxx . . $ oscap_source_readable_origin(1485dc36ee4b63be).(s)) |
| 68 | : oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("%s/%s", target_dir, oscap_source_readable_origincxx . . $ oscap_source_readable_origin(1485dc36ee4b63be).(s)); |
| 69 | int ret = oscap_acquire_ensure_parent_dircxx . . $ oscap_acquire_ensure_parent_dir(5c4306d8553b3696).(filename); |
| 70 | if (ret != 0) { |
| 71 | freecxx . . $ free(5d22bdacc48458e8).(filename); |
| 72 | oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(hit); |
| 73 | return ret; |
| 74 | } |
| 75 | ret = oscap_source_save_ascxx . . $ oscap_source_save_as(b44a10f6a0e05d3e).(s, filename); |
| 76 | freecxx . . $ free(5d22bdacc48458e8).(filename); |
| 77 | if (ret != 0) { |
| 78 | oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(hit); |
| 79 | return ret; |
| 80 | } |
| 81 | } |
| 82 | oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(hit); |
| 83 | return 0; |
| 84 | } |