| 1 | /* |
| 2 | * Copyright 2012--2016 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 "public/scap_ds.h"cxx . . $ `<file>/src/DS/public/scap_ds.h`/ |
| 28 | #include "public/oscap_text.h"cxx . . $ `<file>/src/common/public/oscap_text.h`/ |
| 29 | |
| 30 | #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 31 | #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/ |
| 32 | #include "rds_index_priv.h"cxx . . $ `<file>/src/DS/rds_index_priv.h`/ |
| 33 | |
| 34 | #include <libxml/xmlreader.h> |
| 35 | #include <string.h> |
| 36 | |
| 37 | |
| 38 | struct rds_asset_indexcxx . . $ rds_asset_index# |
| 39 | { |
| 40 | char *idcxx . . $ rds_asset_index#id.; |
| 41 | struct oscap_listcxx . . $ oscap_list# *reportscxx . . $ rds_asset_index#reports.; //< rds_report_index |
| 42 | }; |
| 43 | |
| 44 | struct rds_asset_indexcxx . . $ rds_asset_index# *rds_asset_index_newcxx . . $ rds_asset_index_new(212d24d16e89760f).(void) |
| 45 | { |
| 46 | struct rds_asset_indexcxx . . $ rds_asset_index# *ret = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct rds_asset_indexcxx . . $ rds_asset_index#)); |
| 47 | ret->idcxx . . $ rds_asset_index#id. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 48 | ret->reportscxx . . $ rds_asset_index#reports. = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).(); |
| 49 | |
| 50 | return ret; |
| 51 | } |
| 52 | |
| 53 | void rds_asset_index_freecxx . . $ rds_asset_index_free(bcd68406d6a1081b).(struct rds_asset_indexcxx . . $ rds_asset_index# *s) |
| 54 | { |
| 55 | if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 56 | oscap_list_free0cxx . . $ oscap_list_free0(27ed2064e5aec1b1).(s->reportscxx . . $ rds_asset_index#reports.); |
| 57 | freecxx . . $ free(5d22bdacc48458e8).(s->idcxx . . $ rds_asset_index#id.); |
| 58 | freecxx . . $ free(5d22bdacc48458e8).(s); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | const char *rds_asset_index_get_idcxx . . $ rds_asset_index_get_id(b3b31caa40644001).(struct rds_asset_indexcxx . . $ rds_asset_index# *s) |
| 63 | { |
| 64 | return s->idcxx . . $ rds_asset_index#id.; |
| 65 | } |
| 66 | |
| 67 | void rds_asset_index_add_report_refcxx . . $ rds_asset_index_add_report_ref(ff8e4d261059116e).(struct rds_asset_indexcxx . . $ rds_asset_index# *s, struct rds_report_indexcxx . . $ rds_report_index# *report) |
| 68 | { |
| 69 | oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(s->reportscxx . . $ rds_asset_index#reports., report); |
| 70 | } |
| 71 | |
| 72 | struct rds_report_index_iteratorcxx . . $ rds_report_index_iterator# *rds_asset_index_get_reportscxx . . $ rds_asset_index_get_reports(b9dd5c21a29fd511).(struct rds_asset_indexcxx . . $ rds_asset_index# *s) |
| 73 | { |
| 74 | return (struct rds_report_index_iteratorcxx . . $ rds_report_index_iterator#*)oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(s->reportscxx . . $ rds_asset_index#reports.); |
| 75 | } |
| 76 | |
| 77 | struct rds_asset_indexcxx . . $ rds_asset_index# *rds_asset_index_parsecxx . . $ rds_asset_index_parse(397a34762cf0d0a6).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader) |
| 78 | { |
| 79 | // sanity check |
| 80 | if (xmlTextReaderNodeTypecxx . . $ xmlTextReaderNodeType(82a242a19623f75).(reader) != XML_READER_TYPE_ELEMENTcxx . . $ XML_READER_TYPE_ELEMENT. || |
| 81 | strcmpcxx . . $ strcmp(5ae29d726ae57f88).((const char*)xmlTextReaderConstLocalNamecxx . . $ xmlTextReaderConstLocalName(60a5affeeceb06fd).(reader), "asset") != 0) { |
| 82 | oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_XMLcxx . . $ `src/common/public/oscap_error.h:59:9`!, |
| 83 | "Expected to have xmlTextReader at start of <arf:report>, " |
| 84 | "the current event is '%i' at '%s' instead. I refuse to parse!", |
| 85 | xmlTextReaderNodeType(reader), (const char*)xmlTextReaderConstLocalName(reader)); |
| 86 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 87 | } |
| 88 | |
| 89 | struct rds_asset_indexcxx . . $ rds_asset_index# *ret = rds_asset_index_newcxx . . $ rds_asset_index_new(212d24d16e89760f).(); |
| 90 | |
| 91 | ret->idcxx . . $ rds_asset_index#id. = (char*)xmlTextReaderGetAttributecxx . . $ xmlTextReaderGetAttribute(6d056300a6ef2116).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "id"); |
| 92 | return ret; |
| 93 | } |
| 94 | |
| 95 | struct rds_asset_indexcxx . . $ rds_asset_index# *rds_asset_index_iterator_nextcxx . . $ rds_asset_index_iterator_next(73e5ef02dfc800bd).(struct rds_asset_index_iteratorcxx . . $ rds_asset_index_iterator# *it) |
| 96 | { |
| 97 | return (struct rds_asset_indexcxx . . $ rds_asset_index#*)(oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).((struct oscap_iteratorcxx . . $ oscap_iterator#*)it)); |
| 98 | } |
| 99 | |
| 100 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! rds_asset_index_iterator_has_morecxx . . $ rds_asset_index_iterator_has_more(4cc1dd73741dac97).(struct rds_asset_index_iteratorcxx . . $ rds_asset_index_iterator# *it) |
| 101 | { |
| 102 | return oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).((struct oscap_iteratorcxx . . $ oscap_iterator#*)it); |
| 103 | } |
| 104 | |
| 105 | void rds_asset_index_iterator_freecxx . . $ rds_asset_index_iterator_free(ef3bbd2d878f06c8).(struct rds_asset_index_iteratorcxx . . $ rds_asset_index_iterator# *it) |
| 106 | { |
| 107 | oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).((struct oscap_iteratorcxx . . $ oscap_iterator#*)it); |
| 108 | } |