• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;	/* unused */
59     int                    flags;       /* various flags */
60     unsigned long   expandedSize;       /* expanded size */
61 };
62 
63 /*
64  * All entities are stored in an hash table.
65  * There is 2 separate hash tables for global and parameter entities.
66  */
67 
68 typedef struct _xmlHashTable xmlEntitiesTable;
69 typedef xmlEntitiesTable *xmlEntitiesTablePtr;
70 
71 /*
72  * External functions:
73  */
74 
75 #ifdef LIBXML_LEGACY_ENABLED
76 XML_DEPRECATED
77 XMLPUBFUN void
78 		xmlInitializePredefinedEntities	(void);
79 #endif /* LIBXML_LEGACY_ENABLED */
80 
81 XMLPUBFUN xmlEntityPtr
82 			xmlNewEntity		(xmlDocPtr doc,
83 						 const xmlChar *name,
84 						 int type,
85 						 const xmlChar *ExternalID,
86 						 const xmlChar *SystemID,
87 						 const xmlChar *content);
88 XMLPUBFUN void
89 			xmlFreeEntity		(xmlEntityPtr entity);
90 XMLPUBFUN int
91 			xmlAddEntity		(xmlDocPtr doc,
92 						 int extSubset,
93 						 const xmlChar *name,
94 						 int type,
95 						 const xmlChar *ExternalID,
96 						 const xmlChar *SystemID,
97 						 const xmlChar *content,
98 						 xmlEntityPtr *out);
99 XMLPUBFUN xmlEntityPtr
100 			xmlAddDocEntity		(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 			xmlAddDtdEntity		(xmlDocPtr doc,
108 						 const xmlChar *name,
109 						 int type,
110 						 const xmlChar *ExternalID,
111 						 const xmlChar *SystemID,
112 						 const xmlChar *content);
113 XMLPUBFUN xmlEntityPtr
114 			xmlGetPredefinedEntity	(const xmlChar *name);
115 XMLPUBFUN xmlEntityPtr
116 			xmlGetDocEntity		(const xmlDoc *doc,
117 						 const xmlChar *name);
118 XMLPUBFUN xmlEntityPtr
119 			xmlGetDtdEntity		(xmlDocPtr doc,
120 						 const xmlChar *name);
121 XMLPUBFUN xmlEntityPtr
122 			xmlGetParameterEntity	(xmlDocPtr doc,
123 						 const xmlChar *name);
124 #ifdef LIBXML_LEGACY_ENABLED
125 XML_DEPRECATED
126 XMLPUBFUN const xmlChar *
127 			xmlEncodeEntities	(xmlDocPtr doc,
128 						 const xmlChar *input);
129 #endif /* LIBXML_LEGACY_ENABLED */
130 XMLPUBFUN xmlChar *
131 			xmlEncodeEntitiesReentrant(xmlDocPtr doc,
132 						 const xmlChar *input);
133 XMLPUBFUN xmlChar *
134 			xmlEncodeSpecialChars	(const xmlDoc *doc,
135 						 const xmlChar *input);
136 XMLPUBFUN xmlEntitiesTablePtr
137 			xmlCreateEntitiesTable	(void);
138 #ifdef LIBXML_TREE_ENABLED
139 XMLPUBFUN xmlEntitiesTablePtr
140 			xmlCopyEntitiesTable	(xmlEntitiesTablePtr table);
141 #endif /* LIBXML_TREE_ENABLED */
142 XMLPUBFUN void
143 			xmlFreeEntitiesTable	(xmlEntitiesTablePtr table);
144 #ifdef LIBXML_OUTPUT_ENABLED
145 XMLPUBFUN void
146 			xmlDumpEntitiesTable	(xmlBufferPtr buf,
147 						 xmlEntitiesTablePtr table);
148 XMLPUBFUN void
149 			xmlDumpEntityDecl	(xmlBufferPtr buf,
150 						 xmlEntityPtr ent);
151 #endif /* LIBXML_OUTPUT_ENABLED */
152 #ifdef LIBXML_LEGACY_ENABLED
153 XMLPUBFUN void
154 			xmlCleanupPredefinedEntities(void);
155 #endif /* LIBXML_LEGACY_ENABLED */
156 
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 # endif /* __XML_ENTITIES_H__ */
163