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 #include <libxml/tree.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /*
22  * The different valid entity types.
23  */
24 typedef enum {
25     XML_INTERNAL_GENERAL_ENTITY = 1,
26     XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
27     XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
28     XML_INTERNAL_PARAMETER_ENTITY = 4,
29     XML_EXTERNAL_PARAMETER_ENTITY = 5,
30     XML_INTERNAL_PREDEFINED_ENTITY = 6
31 } xmlEntityType;
32 
33 /*
34  * An unit of storage for an entity, contains the string, the value
35  * and the linkind data needed for the linking in the hash table.
36  */
37 
38 struct _xmlEntity {
39     void           *_private;	        /* application data */
40     xmlElementType          type;       /* XML_ENTITY_DECL, must be second ! */
41     const xmlChar          *name;	/* Entity name */
42     struct _xmlNode    *children;	/* First child link */
43     struct _xmlNode        *last;	/* Last child link */
44     struct _xmlDtd       *parent;	/* -> DTD */
45     struct _xmlNode        *next;	/* next sibling link  */
46     struct _xmlNode        *prev;	/* previous sibling link  */
47     struct _xmlDoc          *doc;       /* the containing document */
48 
49     xmlChar                *orig;	/* content without ref substitution */
50     xmlChar             *content;	/* content or ndata if unparsed */
51     int                   length;	/* the content length */
52     xmlEntityType          etype;	/* The entity type */
53     const xmlChar    *ExternalID;	/* External identifier for PUBLIC */
54     const xmlChar      *SystemID;	/* URI for a SYSTEM or PUBLIC Entity */
55 
56     struct _xmlEntity     *nexte;	/* unused */
57     const xmlChar           *URI;	/* the full URI as computed */
58     int                    owner;	/* does the entity own the childrens */
59     int			 checked;	/* was the entity content checked */
60 					/* this is also used to count entities
61 					 * references done from that entity
62 					 * and if it contains '<' */
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 XMLCALL
80 		xmlInitializePredefinedEntities	(void);
81 #endif /* LIBXML_LEGACY_ENABLED */
82 
83 XMLPUBFUN xmlEntityPtr XMLCALL
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 xmlEntityPtr XMLCALL
91 			xmlAddDocEntity		(xmlDocPtr doc,
92 						 const xmlChar *name,
93 						 int type,
94 						 const xmlChar *ExternalID,
95 						 const xmlChar *SystemID,
96 						 const xmlChar *content);
97 XMLPUBFUN xmlEntityPtr XMLCALL
98 			xmlAddDtdEntity		(xmlDocPtr doc,
99 						 const xmlChar *name,
100 						 int type,
101 						 const xmlChar *ExternalID,
102 						 const xmlChar *SystemID,
103 						 const xmlChar *content);
104 XMLPUBFUN xmlEntityPtr XMLCALL
105 			xmlGetPredefinedEntity	(const xmlChar *name);
106 XMLPUBFUN xmlEntityPtr XMLCALL
107 			xmlGetDocEntity		(const xmlDoc *doc,
108 						 const xmlChar *name);
109 XMLPUBFUN xmlEntityPtr XMLCALL
110 			xmlGetDtdEntity		(xmlDocPtr doc,
111 						 const xmlChar *name);
112 XMLPUBFUN xmlEntityPtr XMLCALL
113 			xmlGetParameterEntity	(xmlDocPtr doc,
114 						 const xmlChar *name);
115 #ifdef LIBXML_LEGACY_ENABLED
116 XML_DEPRECATED
117 XMLPUBFUN const xmlChar * XMLCALL
118 			xmlEncodeEntities	(xmlDocPtr doc,
119 						 const xmlChar *input);
120 #endif /* LIBXML_LEGACY_ENABLED */
121 XMLPUBFUN xmlChar * XMLCALL
122 			xmlEncodeEntitiesReentrant(xmlDocPtr doc,
123 						 const xmlChar *input);
124 XMLPUBFUN xmlChar * XMLCALL
125 			xmlEncodeSpecialChars	(const xmlDoc *doc,
126 						 const xmlChar *input);
127 XMLPUBFUN xmlEntitiesTablePtr XMLCALL
128 			xmlCreateEntitiesTable	(void);
129 #ifdef LIBXML_TREE_ENABLED
130 XMLPUBFUN xmlEntitiesTablePtr XMLCALL
131 			xmlCopyEntitiesTable	(xmlEntitiesTablePtr table);
132 #endif /* LIBXML_TREE_ENABLED */
133 XMLPUBFUN void XMLCALL
134 			xmlFreeEntitiesTable	(xmlEntitiesTablePtr table);
135 #ifdef LIBXML_OUTPUT_ENABLED
136 XMLPUBFUN void XMLCALL
137 			xmlDumpEntitiesTable	(xmlBufferPtr buf,
138 						 xmlEntitiesTablePtr table);
139 XMLPUBFUN void XMLCALL
140 			xmlDumpEntityDecl	(xmlBufferPtr buf,
141 						 xmlEntityPtr ent);
142 #endif /* LIBXML_OUTPUT_ENABLED */
143 #ifdef LIBXML_LEGACY_ENABLED
144 XMLPUBFUN void XMLCALL
145 			xmlCleanupPredefinedEntities(void);
146 #endif /* LIBXML_LEGACY_ENABLED */
147 
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 # endif /* __XML_ENTITIES_H__ */
154