1 /* libxml2 - Library for parsing XML documents
2 * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 *
4 * This file is not part of the GNU gettext program, but is used with
5 * GNU gettext.
6 *
7 * The original copyright notice is as follows:
8 */
9
10 /*
11 * Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this software and associated documentation files (the "Software"), to deal
15 * in the Software without restriction, including without limitation the rights
16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 * copies of the Software, and to permit persons to whom the Software is fur-
18 * nished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
25 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 * THE SOFTWARE.
30 *
31 * Daniel Veillard <daniel@veillard.com>
32 */
33
34 /*
35 * SAX.c : Old SAX v1 handlers to build a tree.
36 * Deprecated except for compatibility
37 */
38
39 #define IN_LIBXML
40 #include "libxml.h"
41 #include <stdlib.h>
42 #include <string.h>
43 #include <libxml/xmlmemory.h>
44 #include <libxml/tree.h>
45 #include <libxml/parser.h>
46 #include <libxml/parserInternals.h>
47 #include <libxml/valid.h>
48 #include <libxml/entities.h>
49 #include <libxml/xmlerror.h>
50 #include <libxml/debugXML.h>
51 #include <libxml/xmlIO.h>
52 #include <libxml/SAX.h>
53 #include <libxml/uri.h>
54 #include <libxml/valid.h>
55 #include <libxml/HTMLtree.h>
56 #include <libxml/globals.h>
57 #include <libxml/SAX2.h>
58
59 #ifdef LIBXML_LEGACY_ENABLED
60 #ifdef LIBXML_SAX1_ENABLED
61 /**
62 * initxmlDefaultSAXHandler:
63 * @hdlr: the SAX handler
64 * @warning: flag if non-zero sets the handler warning procedure
65 *
66 * Initialize the default XML SAX version 1 handler
67 * DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
68 */
69 void
initxmlDefaultSAXHandler(xmlSAXHandlerV1 * hdlr,int warning)70 initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
71 {
72
73 if(hdlr->initialized == 1)
74 return;
75
76 hdlr->internalSubset = xmlSAX2InternalSubset;
77 hdlr->externalSubset = xmlSAX2ExternalSubset;
78 hdlr->isStandalone = xmlSAX2IsStandalone;
79 hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
80 hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
81 hdlr->resolveEntity = xmlSAX2ResolveEntity;
82 hdlr->getEntity = xmlSAX2GetEntity;
83 hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
84 hdlr->entityDecl = xmlSAX2EntityDecl;
85 hdlr->attributeDecl = xmlSAX2AttributeDecl;
86 hdlr->elementDecl = xmlSAX2ElementDecl;
87 hdlr->notationDecl = xmlSAX2NotationDecl;
88 hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
89 hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
90 hdlr->startDocument = xmlSAX2StartDocument;
91 hdlr->endDocument = xmlSAX2EndDocument;
92 hdlr->startElement = xmlSAX2StartElement;
93 hdlr->endElement = xmlSAX2EndElement;
94 hdlr->reference = xmlSAX2Reference;
95 hdlr->characters = xmlSAX2Characters;
96 hdlr->cdataBlock = xmlSAX2CDataBlock;
97 hdlr->ignorableWhitespace = xmlSAX2Characters;
98 hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
99 if (warning == 0)
100 hdlr->warning = NULL;
101 else
102 hdlr->warning = xmlParserWarning;
103 hdlr->error = xmlParserError;
104 hdlr->fatalError = xmlParserError;
105
106 hdlr->initialized = 1;
107 }
108
109 #ifdef LIBXML_HTML_ENABLED
110
111 /**
112 * inithtmlDefaultSAXHandler:
113 * @hdlr: the SAX handler
114 *
115 * Initialize the default HTML SAX version 1 handler
116 * DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
117 */
118 void
inithtmlDefaultSAXHandler(xmlSAXHandlerV1 * hdlr)119 inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
120 {
121 if(hdlr->initialized == 1)
122 return;
123
124 hdlr->internalSubset = xmlSAX2InternalSubset;
125 hdlr->externalSubset = NULL;
126 hdlr->isStandalone = NULL;
127 hdlr->hasInternalSubset = NULL;
128 hdlr->hasExternalSubset = NULL;
129 hdlr->resolveEntity = NULL;
130 hdlr->getEntity = xmlSAX2GetEntity;
131 hdlr->getParameterEntity = NULL;
132 hdlr->entityDecl = NULL;
133 hdlr->attributeDecl = NULL;
134 hdlr->elementDecl = NULL;
135 hdlr->notationDecl = NULL;
136 hdlr->unparsedEntityDecl = NULL;
137 hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
138 hdlr->startDocument = xmlSAX2StartDocument;
139 hdlr->endDocument = xmlSAX2EndDocument;
140 hdlr->startElement = xmlSAX2StartElement;
141 hdlr->endElement = xmlSAX2EndElement;
142 hdlr->reference = NULL;
143 hdlr->characters = xmlSAX2Characters;
144 hdlr->cdataBlock = xmlSAX2CDataBlock;
145 hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
146 hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
147 hdlr->comment = xmlSAX2Comment;
148 hdlr->warning = xmlParserWarning;
149 hdlr->error = xmlParserError;
150 hdlr->fatalError = xmlParserError;
151
152 hdlr->initialized = 1;
153 }
154
155 #endif /* LIBXML_HTML_ENABLED */
156
157 #ifdef LIBXML_DOCB_ENABLED
158 /**
159 * initdocbDefaultSAXHandler:
160 * @hdlr: the SAX handler
161 *
162 * Initialize the default DocBook SAX version 1 handler
163 * DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks
164 */
165 void
initdocbDefaultSAXHandler(xmlSAXHandlerV1 * hdlr)166 initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
167 {
168 if(hdlr->initialized == 1)
169 return;
170
171 hdlr->internalSubset = xmlSAX2InternalSubset;
172 hdlr->externalSubset = NULL;
173 hdlr->isStandalone = xmlSAX2IsStandalone;
174 hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
175 hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
176 hdlr->resolveEntity = xmlSAX2ResolveEntity;
177 hdlr->getEntity = xmlSAX2GetEntity;
178 hdlr->getParameterEntity = NULL;
179 hdlr->entityDecl = xmlSAX2EntityDecl;
180 hdlr->attributeDecl = NULL;
181 hdlr->elementDecl = NULL;
182 hdlr->notationDecl = NULL;
183 hdlr->unparsedEntityDecl = NULL;
184 hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
185 hdlr->startDocument = xmlSAX2StartDocument;
186 hdlr->endDocument = xmlSAX2EndDocument;
187 hdlr->startElement = xmlSAX2StartElement;
188 hdlr->endElement = xmlSAX2EndElement;
189 hdlr->reference = xmlSAX2Reference;
190 hdlr->characters = xmlSAX2Characters;
191 hdlr->cdataBlock = NULL;
192 hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
193 hdlr->processingInstruction = NULL;
194 hdlr->comment = xmlSAX2Comment;
195 hdlr->warning = xmlParserWarning;
196 hdlr->error = xmlParserError;
197 hdlr->fatalError = xmlParserError;
198
199 hdlr->initialized = 1;
200 }
201
202 #endif /* LIBXML_DOCB_ENABLED */
203
204 #endif /* LIBXML_SAX1_ENABLED */
205
206 #define bottom_SAX
207 #include "elfgcchack.h"
208 #endif /* LIBXML_LEGACY_ENABLED */
209