1 /*
2 * Summary: interface for the XML entities handling
3 * Description: this module provides some of the entity API needed
4 * for the parser and applications.
5 *
6 * Copy: See Copyright for the status of this software.
7 *
8 * Author: Daniel Veillard
9 */
10
11 #ifndef __XML_ENTITIES_H__
12 #define __XML_ENTITIES_H__
13
14 #include <libxml/xmlversion.h>
15 #define XML_TREE_INTERNALS
16 #include <libxml/tree.h>
17 #undef XML_TREE_INTERNALS
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /*
24 * The different valid entity types.
25 */
26 typedef enum {
27 XML_INTERNAL_GENERAL_ENTITY = 1,
28 XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
29 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
30 XML_INTERNAL_PARAMETER_ENTITY = 4,
31 XML_EXTERNAL_PARAMETER_ENTITY = 5,
32 XML_INTERNAL_PREDEFINED_ENTITY = 6
33 } xmlEntityType;
34
35 /*
36 * An unit of storage for an entity, contains the string, the value
37 * and the linkind data needed for the linking in the hash table.
38 */
39
40 struct _xmlEntity {
41 void *_private; /* application data */
42 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
43 const xmlChar *name; /* Entity name */
44 struct _xmlNode *children; /* First child link */
45 struct _xmlNode *last; /* Last child link */
46 struct _xmlDtd *parent; /* -> DTD */
47 struct _xmlNode *next; /* next sibling link */
48 struct _xmlNode *prev; /* previous sibling link */
49 struct _xmlDoc *doc; /* the containing document */
50
51 xmlChar *orig; /* content without ref substitution */
52 xmlChar *content; /* content or ndata if unparsed */
53 int length; /* the content length */
54 xmlEntityType etype; /* The entity type */
55 const xmlChar *ExternalID; /* External identifier for PUBLIC */
56 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
57
58 struct _xmlEntity *nexte; /* unused */
59 const xmlChar *URI; /* the full URI as computed */
60 int owner; /* does the entity own the childrens */
61 int flags; /* various flags */
62 unsigned long expandedSize; /* expanded size */
63 };
64
65 /*
66 * All entities are stored in an hash table.
67 * There is 2 separate hash tables for global and parameter entities.
68 */
69
70 typedef struct _xmlHashTable xmlEntitiesTable;
71 typedef xmlEntitiesTable *xmlEntitiesTablePtr;
72
73 /*
74 * External functions:
75 */
76
77 #ifdef LIBXML_LEGACY_ENABLED
78 XML_DEPRECATED
79 XMLPUBFUN void
80 xmlInitializePredefinedEntities (void);
81 #endif /* LIBXML_LEGACY_ENABLED */
82
83 XMLPUBFUN xmlEntityPtr
84 xmlNewEntity (xmlDocPtr doc,
85 const xmlChar *name,
86 int type,
87 const xmlChar *ExternalID,
88 const xmlChar *SystemID,
89 const xmlChar *content);
90 XMLPUBFUN void
91 xmlFreeEntity (xmlEntityPtr entity);
92 XMLPUBFUN xmlEntityPtr
93 xmlAddDocEntity (xmlDocPtr doc,
94 const xmlChar *name,
95 int type,
96 const xmlChar *ExternalID,
97 const xmlChar *SystemID,
98 const xmlChar *content);
99 XMLPUBFUN xmlEntityPtr
100 xmlAddDtdEntity (xmlDocPtr doc,
101 const xmlChar *name,
102 int type,
103 const xmlChar *ExternalID,
104 const xmlChar *SystemID,
105 const xmlChar *content);
106 XMLPUBFUN xmlEntityPtr
107 xmlGetPredefinedEntity (const xmlChar *name);
108 XMLPUBFUN xmlEntityPtr
109 xmlGetDocEntity (const xmlDoc *doc,
110 const xmlChar *name);
111 XMLPUBFUN xmlEntityPtr
112 xmlGetDtdEntity (xmlDocPtr doc,
113 const xmlChar *name);
114 XMLPUBFUN xmlEntityPtr
115 xmlGetParameterEntity (xmlDocPtr doc,
116 const xmlChar *name);
117 #ifdef LIBXML_LEGACY_ENABLED
118 XML_DEPRECATED
119 XMLPUBFUN const xmlChar *
120 xmlEncodeEntities (xmlDocPtr doc,
121 const xmlChar *input);
122 #endif /* LIBXML_LEGACY_ENABLED */
123 XMLPUBFUN xmlChar *
124 xmlEncodeEntitiesReentrant(xmlDocPtr doc,
125 const xmlChar *input);
126 XMLPUBFUN xmlChar *
127 xmlEncodeSpecialChars (const xmlDoc *doc,
128 const xmlChar *input);
129 XMLPUBFUN xmlEntitiesTablePtr
130 xmlCreateEntitiesTable (void);
131 #ifdef LIBXML_TREE_ENABLED
132 XMLPUBFUN xmlEntitiesTablePtr
133 xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
134 #endif /* LIBXML_TREE_ENABLED */
135 XMLPUBFUN void
136 xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
137 #ifdef LIBXML_OUTPUT_ENABLED
138 XMLPUBFUN void
139 xmlDumpEntitiesTable (xmlBufferPtr buf,
140 xmlEntitiesTablePtr table);
141 XMLPUBFUN void
142 xmlDumpEntityDecl (xmlBufferPtr buf,
143 xmlEntityPtr ent);
144 #endif /* LIBXML_OUTPUT_ENABLED */
145 #ifdef LIBXML_LEGACY_ENABLED
146 XMLPUBFUN void
147 xmlCleanupPredefinedEntities(void);
148 #endif /* LIBXML_LEGACY_ENABLED */
149
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 # endif /* __XML_ENTITIES_H__ */