Debian Codegraph @

src/common/xmltext_priv.c

raw symbols SCIP
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 * Šimon Lukašík
21 */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "xmltext_priv.h"
27 #include "_error.h"
28
29 int xmlTextReaderNextElement(xmlTextReaderPtr reader)
30 {
31 __attribute__nonnull__(reader);
32
33 int ret;
34 do {
35 ret = xmlTextReaderRead(reader);
36 // if end of file
37 if (ret < 1)
38 break;
39 } while (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT);
40
41 if (ret == -1) {
42 oscap_setxmlerr(xmlCtxtGetLastError(reader));
43 /* TODO: Should we end here as fatal ? */
44 }
45
46 return ret;
47 }
48
49 int xmlTextReaderNextNode(xmlTextReaderPtr reader)
50 {
51 __attribute__nonnull__(reader);
52
53 int ret = xmlTextReaderRead(reader);
54 if (ret == -1)
55 oscap_setxmlerr(xmlGetLastError());
56
57 return ret;
58 }
59
60 int xmlTextReaderNextElementWE(xmlTextReaderPtr reader, xmlChar* end_tag)
61 {
62 __attribute__nonnull__(reader);
63
64 int ret;
65 do {
66 ret = xmlTextReaderRead(reader);
67 // if end of file
68 if (ret < 1)
69 break;
70
71 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
72 if (!xmlStrcmp(xmlTextReaderConstLocalName(reader), end_tag)) {
73 ret = 0;
74 break;
75 }
76 }
77 } while (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT);
78
79 if (ret == -1) {
80 oscap_setxmlerr(xmlCtxtGetLastError(reader));
81 /* TODO: Should we end here as fatal ? */
82 }
83
84 return ret;
85 }