blob: e3930425cdffc3b0ae3d2e94c0bd0f6fd2628f6f [file] [log] [blame]
Daniel Veillard260a68f1998-08-13 03:39:55 +00001/*
2 * entities.h : interface for the XML entities handking
3 *
4 * See Copyright for the status of this software.
5 *
Daniel Veillard39a1f9a1999-01-17 19:11:59 +00006 * Daniel.Veillard@w3.org
Daniel Veillard260a68f1998-08-13 03:39:55 +00007 */
8
9#ifndef __XML_ENTITIES_H__
10#define __XML_ENTITIES_H__
Daniel Veillard260a68f1998-08-13 03:39:55 +000011
Daniel Veillard361d8452000-04-03 19:48:13 +000012#include <libxml/tree.h>
Daniel Veillard260a68f1998-08-13 03:39:55 +000013
14#ifdef __cplusplus
15extern "C" {
16#endif
17
Daniel Veillardcf461992000-03-14 18:30:20 +000018/*
19 * The different valid entity types
20 */
21typedef enum {
22 XML_INTERNAL_GENERAL_ENTITY = 1,
23 XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
24 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
25 XML_INTERNAL_PARAMETER_ENTITY = 4,
26 XML_EXTERNAL_PARAMETER_ENTITY = 5,
27 XML_INTERNAL_PREDEFINED_ENTITY = 6
28} xmlEntityType;
Daniel Veillard260a68f1998-08-13 03:39:55 +000029
30/*
31 * An unit of storage for an entity, contains the string, the value
32 * and the linkind data needed for the linking in the hash table.
33 */
34
Daniel Veillard71b656e2000-01-05 14:46:17 +000035typedef struct _xmlEntity xmlEntity;
36typedef xmlEntity *xmlEntityPtr;
37struct _xmlEntity {
Daniel Veillardcf461992000-03-14 18:30:20 +000038#ifndef XML_WITHOUT_CORBA
39 void *_private; /* for Corba, must be first ! */
40#endif
41 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
42 const xmlChar *name; /* Attribute name */
43 struct _xmlNode *children; /* NULL */
44 struct _xmlNode *last; /* NULL */
45 struct _xmlDtd *parent; /* -> DTD */
46 struct _xmlNode *next; /* next sibling link */
47 struct _xmlNode *prev; /* previous sibling link */
48 struct _xmlDoc *doc; /* the containing document */
49
50 xmlChar *orig; /* content without ref substitution */
51 xmlChar *content; /* content or ndata if unparsed */
52 int length; /* the content length */
53 xmlEntityType etype; /* The entity type */
54 const xmlChar *ExternalID; /* External identifier for PUBLIC */
55 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
56
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +000057 struct _xmlEntity *nexte; /* next entity in the hash table */
58
Daniel Veillardcf461992000-03-14 18:30:20 +000059#ifdef WITH_EXTRA_ENT_DETECT
60 /* Referenced entities name stack */
61 xmlChar *ent; /* Current parsed Node */
62 int entNr; /* Depth of the parsing stack */
63 int entMax; /* Max depth of the parsing stack */
64 xmlChar * *entTab; /* array of nodes */
65#endif
Daniel Veillard71b656e2000-01-05 14:46:17 +000066};
Daniel Veillard260a68f1998-08-13 03:39:55 +000067
68/*
69 * ALl entities are stored in a table there is one table per DTD
70 * and one extra per document.
71 */
72
73#define XML_MIN_ENTITIES_TABLE 32
74
Daniel Veillard71b656e2000-01-05 14:46:17 +000075typedef struct _xmlEntitiesTable xmlEntitiesTable;
76typedef xmlEntitiesTable *xmlEntitiesTablePtr;
77struct _xmlEntitiesTable {
Daniel Veillard260a68f1998-08-13 03:39:55 +000078 int nb_entities; /* number of elements stored */
79 int max_entities; /* maximum number of elements */
Daniel Veillardcf461992000-03-14 18:30:20 +000080 xmlEntityPtr *table; /* the table of entities */
Daniel Veillard71b656e2000-01-05 14:46:17 +000081};
Daniel Veillard260a68f1998-08-13 03:39:55 +000082
Daniel Veillardccb09631998-10-27 06:21:04 +000083
Daniel Veillard260a68f1998-08-13 03:39:55 +000084/*
85 * External functions :
86 */
87
Daniel Veillardcf461992000-03-14 18:30:20 +000088xmlEntityPtr xmlAddDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000089 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000090 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000091 const xmlChar *ExternalID,
92 const xmlChar *SystemID,
93 const xmlChar *content);
Daniel Veillardcf461992000-03-14 18:30:20 +000094xmlEntityPtr xmlAddDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000095 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000096 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000097 const xmlChar *ExternalID,
98 const xmlChar *SystemID,
99 const xmlChar *content);
100xmlEntityPtr xmlGetPredefinedEntity (const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000101xmlEntityPtr xmlGetDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000102 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000103xmlEntityPtr xmlGetDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000104 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000105xmlEntityPtr xmlGetParameterEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000106 const xmlChar *name);
107const xmlChar * xmlEncodeEntities (xmlDocPtr doc,
108 const xmlChar *input);
Daniel Veillard00fdf371999-10-08 09:40:39 +0000109xmlChar * xmlEncodeEntitiesReentrant(xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000110 const xmlChar *input);
Daniel Veillardbe803962000-06-28 23:40:59 +0000111xmlChar * xmlEncodeSpecialChars (xmlDocPtr doc,
112 const xmlChar *input);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000113xmlEntitiesTablePtr xmlCreateEntitiesTable (void);
114xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
115void xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
116void xmlDumpEntitiesTable (xmlBufferPtr buf,
117 xmlEntitiesTablePtr table);
Daniel Veillardcf461992000-03-14 18:30:20 +0000118void xmlDumpEntityDecl (xmlBufferPtr buf,
119 xmlEntityPtr ent);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000120xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
Daniel Veillarda594bf41999-12-01 09:51:45 +0000121void xmlCleanupPredefinedEntities(void);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000122
Daniel Veillardcf461992000-03-14 18:30:20 +0000123#ifdef WITH_EXTRA_ENT_DETECT
124int xmlEntityAddReference (xmlEntityPtr ent,
125 const xmlChar *to);
126#endif
127
Daniel Veillard260a68f1998-08-13 03:39:55 +0000128#ifdef __cplusplus
129}
130#endif
131
132# endif /* __XML_ENTITIES_H__ */