blob: e5bcc1b56732f10eeaaeff31f28e859b45cb9ea1 [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 */
Daniel Veillard39c7d712000-09-10 16:14:55 +000058 const xmlChar *URI; /* the full URI as computed */
Daniel Veillardf0cc7cc2000-08-26 21:40:43 +000059
Daniel Veillardcf461992000-03-14 18:30:20 +000060#ifdef WITH_EXTRA_ENT_DETECT
61 /* Referenced entities name stack */
62 xmlChar *ent; /* Current parsed Node */
63 int entNr; /* Depth of the parsing stack */
64 int entMax; /* Max depth of the parsing stack */
65 xmlChar * *entTab; /* array of nodes */
66#endif
Daniel Veillard71b656e2000-01-05 14:46:17 +000067};
Daniel Veillard260a68f1998-08-13 03:39:55 +000068
69/*
70 * ALl entities are stored in a table there is one table per DTD
71 * and one extra per document.
72 */
73
74#define XML_MIN_ENTITIES_TABLE 32
75
Daniel Veillard71b656e2000-01-05 14:46:17 +000076typedef struct _xmlEntitiesTable xmlEntitiesTable;
77typedef xmlEntitiesTable *xmlEntitiesTablePtr;
78struct _xmlEntitiesTable {
Daniel Veillard260a68f1998-08-13 03:39:55 +000079 int nb_entities; /* number of elements stored */
80 int max_entities; /* maximum number of elements */
Daniel Veillardcf461992000-03-14 18:30:20 +000081 xmlEntityPtr *table; /* the table of entities */
Daniel Veillard71b656e2000-01-05 14:46:17 +000082};
Daniel Veillard260a68f1998-08-13 03:39:55 +000083
Daniel Veillardccb09631998-10-27 06:21:04 +000084
Daniel Veillard260a68f1998-08-13 03:39:55 +000085/*
86 * External functions :
87 */
88
Daniel Veillardcf461992000-03-14 18:30:20 +000089xmlEntityPtr xmlAddDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000090 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000091 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000092 const xmlChar *ExternalID,
93 const xmlChar *SystemID,
94 const xmlChar *content);
Daniel Veillardcf461992000-03-14 18:30:20 +000095xmlEntityPtr xmlAddDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000096 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000097 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000098 const xmlChar *ExternalID,
99 const xmlChar *SystemID,
100 const xmlChar *content);
101xmlEntityPtr xmlGetPredefinedEntity (const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000102xmlEntityPtr xmlGetDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000103 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000104xmlEntityPtr xmlGetDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000105 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000106xmlEntityPtr xmlGetParameterEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000107 const xmlChar *name);
108const xmlChar * xmlEncodeEntities (xmlDocPtr doc,
109 const xmlChar *input);
Daniel Veillard00fdf371999-10-08 09:40:39 +0000110xmlChar * xmlEncodeEntitiesReentrant(xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000111 const xmlChar *input);
Daniel Veillardbe803962000-06-28 23:40:59 +0000112xmlChar * xmlEncodeSpecialChars (xmlDocPtr doc,
113 const xmlChar *input);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000114xmlEntitiesTablePtr xmlCreateEntitiesTable (void);
115xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
116void xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
117void xmlDumpEntitiesTable (xmlBufferPtr buf,
118 xmlEntitiesTablePtr table);
Daniel Veillardcf461992000-03-14 18:30:20 +0000119void xmlDumpEntityDecl (xmlBufferPtr buf,
120 xmlEntityPtr ent);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000121xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
Daniel Veillarda594bf41999-12-01 09:51:45 +0000122void xmlCleanupPredefinedEntities(void);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000123
Daniel Veillardcf461992000-03-14 18:30:20 +0000124#ifdef WITH_EXTRA_ENT_DETECT
125int xmlEntityAddReference (xmlEntityPtr ent,
126 const xmlChar *to);
127#endif
128
Daniel Veillard260a68f1998-08-13 03:39:55 +0000129#ifdef __cplusplus
130}
131#endif
132
133# endif /* __XML_ENTITIES_H__ */