Debian Codegraph @

src/DS/rds_report_request_index.c

raw symbols SCIP
1 /*
2 * Copyright 2013--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_H
24 #include <config.h>
25 #endif
26
27 #include "public/scap_ds.h"
28 #include "common/list.h"
29 #include "common/_error.h"
30 #include "rds_index_priv.h"
31
32
33 #include <libxml/xmlreader.h>
34 #include <string.h>
35
36 struct rds_report_request_index
37 {
38 char *id;
39 };
40
41 struct rds_report_request_index *rds_report_request_index_new(void)
42 {
43 struct rds_report_request_index *ret = calloc(1, sizeof(struct rds_report_request_index));
44 ret->id = NULL;
45
46 return ret;
47 }
48
49 void rds_report_request_index_free(struct rds_report_request_index *s)
50 {
51 if (s != NULL) {
52 free(s->id);
53 free(s);
54 }
55 }
56
57 const char *rds_report_request_index_get_id(struct rds_report_request_index *s)
58 {
59 return s->id;
60 }
61
62 struct rds_report_request_index *rds_report_request_index_parse(xmlTextReaderPtr reader)
63 {
64 // sanity check
65 if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT ||
66 strcmp((const char*)xmlTextReaderConstLocalName(reader), "report-request") != 0) {
67 oscap_seterr(OSCAP_EFAMILY_XML,
68 "Expected to have xmlTextReader at start of <arf:report-request>, "
69 "the current event is '%i' at '%s' instead. I refuse to parse!",
70 xmlTextReaderNodeType(reader), (const char*)xmlTextReaderConstLocalName(reader));
71
72 return NULL;
73 }
74
75 struct rds_report_request_index* ret = rds_report_request_index_new();
76
77 ret->id = (char*)xmlTextReaderGetAttribute(reader, BAD_CAST "id");
78 return ret;
79 }
80
81 struct rds_report_request_index *rds_report_request_index_iterator_next(struct rds_report_request_index_iterator *it)
82 {
83 return (struct rds_report_request_index*)(oscap_iterator_next((struct oscap_iterator*)it));
84 }
85
86 bool rds_report_request_index_iterator_has_more(struct rds_report_request_index_iterator *it)
87 {
88 return oscap_iterator_has_more((struct oscap_iterator*)it);
89 }
90
91 void rds_report_request_index_iterator_free(struct rds_report_request_index_iterator *it)
92 {
93 oscap_iterator_free((struct oscap_iterator*)it);
94 }