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 "xmlversion.h"
15 #include "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 };
61 
62 /*
63  * All entities are stored in an hash table.
64  * There is 2 separate hash tables for global and parameter entities.
65  */
66 
67 typedef struct _xmlHashTable xmlEntitiesTable;
68 typedef xmlEntitiesTable *xmlEntitiesTablePtr;
69 
70 /*
71  * External functions:
72  */
73 
74 #ifdef LIBXML_LEGACY_ENABLED
75 XMLPUBFUN void XMLCALL
76                 xmlInitializePredefinedEntities (void);
77 #endif /* LIBXML_LEGACY_ENABLED */
78 XMLPUBFUN xmlEntityPtr XMLCALL
79                         xmlAddDocEntity         (xmlDocPtr doc,
80                                                  const xmlChar *name,
81                                                  int type,
82                                                  const xmlChar *ExternalID,
83                                                  const xmlChar *SystemID,
84                                                  const xmlChar *content);
85 XMLPUBFUN xmlEntityPtr XMLCALL
86                         xmlAddDtdEntity         (xmlDocPtr doc,
87                                                  const xmlChar *name,
88                                                  int type,
89                                                  const xmlChar *ExternalID,
90                                                  const xmlChar *SystemID,
91                                                  const xmlChar *content);
92 XMLPUBFUN xmlEntityPtr XMLCALL
93                         xmlGetPredefinedEntity  (const xmlChar *name);
94 XMLPUBFUN xmlEntityPtr XMLCALL
95                         xmlGetDocEntity         (xmlDocPtr doc,
96                                                  const xmlChar *name);
97 XMLPUBFUN xmlEntityPtr XMLCALL
98                         xmlGetDtdEntity         (xmlDocPtr doc,
99                                                  const xmlChar *name);
100 XMLPUBFUN xmlEntityPtr XMLCALL
101                         xmlGetParameterEntity   (xmlDocPtr doc,
102                                                  const xmlChar *name);
103 #ifdef LIBXML_LEGACY_ENABLED
104 XMLPUBFUN const xmlChar * XMLCALL
105                         xmlEncodeEntities       (xmlDocPtr doc,
106                                                  const xmlChar *input);
107 #endif /* LIBXML_LEGACY_ENABLED */
108 XMLPUBFUN xmlChar * XMLCALL
109                         xmlEncodeEntitiesReentrant(xmlDocPtr doc,
110                                                  const xmlChar *input);
111 XMLPUBFUN xmlChar * XMLCALL
112                         xmlEncodeSpecialChars   (xmlDocPtr doc,
113                                                  const xmlChar *input);
114 XMLPUBFUN xmlEntitiesTablePtr XMLCALL
115                         xmlCreateEntitiesTable  (void);
116 #ifdef LIBXML_TREE_ENABLED
117 XMLPUBFUN xmlEntitiesTablePtr XMLCALL
118                         xmlCopyEntitiesTable    (xmlEntitiesTablePtr table);
119 #endif /* LIBXML_TREE_ENABLED */
120 XMLPUBFUN void XMLCALL
121                         xmlFreeEntitiesTable    (xmlEntitiesTablePtr table);
122 #ifdef LIBXML_OUTPUT_ENABLED
123 XMLPUBFUN void XMLCALL
124                         xmlDumpEntitiesTable    (xmlBufferPtr buf,
125                                                  xmlEntitiesTablePtr table);
126 XMLPUBFUN void XMLCALL
127                         xmlDumpEntityDecl       (xmlBufferPtr buf,
128                                                  xmlEntityPtr ent);
129 #endif /* LIBXML_OUTPUT_ENABLED */
130 #ifdef LIBXML_LEGACY_ENABLED
131 XMLPUBFUN void XMLCALL
132                         xmlCleanupPredefinedEntities(void);
133 #endif /* LIBXML_LEGACY_ENABLED */
134 
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 # endif /* __XML_ENTITIES_H__ */
141