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 * Author: Daniel Veillard
32 */
33
34 /*
35 * Summary: interface for the XML entities handling
36 * Description: this module provides some of the entity API needed
37 * for the parser and applications.
38 */
39
40 #ifndef __XML_ENTITIES_H__
41 #define __XML_ENTITIES_H__
42
43 #include <libxml/xmlversion.h>
44 #include <libxml/tree.h>
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /*
51 * The different valid entity types.
52 */
53 typedef enum {
54 XML_INTERNAL_GENERAL_ENTITY = 1,
55 XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
56 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
57 XML_INTERNAL_PARAMETER_ENTITY = 4,
58 XML_EXTERNAL_PARAMETER_ENTITY = 5,
59 XML_INTERNAL_PREDEFINED_ENTITY = 6
60 } xmlEntityType;
61
62 /*
63 * An unit of storage for an entity, contains the string, the value
64 * and the linkind data needed for the linking in the hash table.
65 */
66
67 struct _xmlEntity {
68 void *_private; /* application data */
69 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
70 const xmlChar *name; /* Entity name */
71 struct _xmlNode *children; /* First child link */
72 struct _xmlNode *last; /* Last child link */
73 struct _xmlDtd *parent; /* -> DTD */
74 struct _xmlNode *next; /* next sibling link */
75 struct _xmlNode *prev; /* previous sibling link */
76 struct _xmlDoc *doc; /* the containing document */
77
78 xmlChar *orig; /* content without ref substitution */
79 xmlChar *content; /* content or ndata if unparsed */
80 int length; /* the content length */
81 xmlEntityType etype; /* The entity type */
82 const xmlChar *ExternalID; /* External identifier for PUBLIC */
83 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
84
85 struct _xmlEntity *nexte; /* unused */
86 const xmlChar *URI; /* the full URI as computed */
87 int owner; /* does the entity own the childrens */
88 int checked; /* was the entity content checked */
89 /* this is also used to count entities
90 * references done from that entity
91 * and if it contains '<' */
92 };
93
94 /*
95 * All entities are stored in an hash table.
96 * There is 2 separate hash tables for global and parameter entities.
97 */
98
99 typedef struct _xmlHashTable xmlEntitiesTable;
100 typedef xmlEntitiesTable *xmlEntitiesTablePtr;
101
102 /*
103 * External functions:
104 */
105
106 #ifdef LIBXML_LEGACY_ENABLED
107 XMLPUBFUN void XMLCALL
108 xmlInitializePredefinedEntities (void);
109 #endif /* LIBXML_LEGACY_ENABLED */
110
111 XMLPUBFUN xmlEntityPtr XMLCALL
112 xmlNewEntity (xmlDocPtr doc,
113 const xmlChar *name,
114 int type,
115 const xmlChar *ExternalID,
116 const xmlChar *SystemID,
117 const xmlChar *content);
118 XMLPUBFUN xmlEntityPtr XMLCALL
119 xmlAddDocEntity (xmlDocPtr doc,
120 const xmlChar *name,
121 int type,
122 const xmlChar *ExternalID,
123 const xmlChar *SystemID,
124 const xmlChar *content);
125 XMLPUBFUN xmlEntityPtr XMLCALL
126 xmlAddDtdEntity (xmlDocPtr doc,
127 const xmlChar *name,
128 int type,
129 const xmlChar *ExternalID,
130 const xmlChar *SystemID,
131 const xmlChar *content);
132 XMLPUBFUN xmlEntityPtr XMLCALL
133 xmlGetPredefinedEntity (const xmlChar *name);
134 XMLPUBFUN xmlEntityPtr XMLCALL
135 xmlGetDocEntity (const xmlDoc *doc,
136 const xmlChar *name);
137 XMLPUBFUN xmlEntityPtr XMLCALL
138 xmlGetDtdEntity (xmlDocPtr doc,
139 const xmlChar *name);
140 XMLPUBFUN xmlEntityPtr XMLCALL
141 xmlGetParameterEntity (xmlDocPtr doc,
142 const xmlChar *name);
143 #ifdef LIBXML_LEGACY_ENABLED
144 XMLPUBFUN const xmlChar * XMLCALL
145 xmlEncodeEntities (xmlDocPtr doc,
146 const xmlChar *input);
147 #endif /* LIBXML_LEGACY_ENABLED */
148 XMLPUBFUN xmlChar * XMLCALL
149 xmlEncodeEntitiesReentrant(xmlDocPtr doc,
150 const xmlChar *input);
151 XMLPUBFUN xmlChar * XMLCALL
152 xmlEncodeSpecialChars (const xmlDoc *doc,
153 const xmlChar *input);
154 XMLPUBFUN xmlEntitiesTablePtr XMLCALL
155 xmlCreateEntitiesTable (void);
156 #ifdef LIBXML_TREE_ENABLED
157 XMLPUBFUN xmlEntitiesTablePtr XMLCALL
158 xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
159 #endif /* LIBXML_TREE_ENABLED */
160 XMLPUBFUN void XMLCALL
161 xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
162 #ifdef LIBXML_OUTPUT_ENABLED
163 XMLPUBFUN void XMLCALL
164 xmlDumpEntitiesTable (xmlBufferPtr buf,
165 xmlEntitiesTablePtr table);
166 XMLPUBFUN void XMLCALL
167 xmlDumpEntityDecl (xmlBufferPtr buf,
168 xmlEntityPtr ent);
169 #endif /* LIBXML_OUTPUT_ENABLED */
170 #ifdef LIBXML_LEGACY_ENABLED
171 XMLPUBFUN void XMLCALL
172 xmlCleanupPredefinedEntities(void);
173 #endif /* LIBXML_LEGACY_ENABLED */
174
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180 # endif /* __XML_ENTITIES_H__ */