blob: 0347170eae3b95dad65d276d86177f0b0536d403 [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 Veillard517752b1999-04-05 12:20:10 +000012#include "tree.h"
Daniel Veillard260a68f1998-08-13 03:39:55 +000013
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#define XML_INTERNAL_GENERAL_ENTITY 1
19#define XML_EXTERNAL_GENERAL_PARSED_ENTITY 2
20#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY 3
21#define XML_INTERNAL_PARAMETER_ENTITY 4
22#define XML_EXTERNAL_PARAMETER_ENTITY 5
Daniel Veillard25940b71998-10-29 05:51:30 +000023#define XML_INTERNAL_PREDEFINED_ENTITY 6
Daniel Veillard260a68f1998-08-13 03:39:55 +000024
25/*
26 * An unit of storage for an entity, contains the string, the value
27 * and the linkind data needed for the linking in the hash table.
28 */
29
Daniel Veillard71b656e2000-01-05 14:46:17 +000030typedef struct _xmlEntity xmlEntity;
31typedef xmlEntity *xmlEntityPtr;
32struct _xmlEntity {
Daniel Veillard260a68f1998-08-13 03:39:55 +000033 int type; /* The entity type */
34 int len; /* The lenght of the name */
Daniel Veillard00fdf371999-10-08 09:40:39 +000035 const xmlChar *name; /* Name of the entity */
36 const xmlChar *ExternalID; /* External identifier for PUBLIC Entity */
37 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
Daniel Veillarddd6b3671999-09-23 22:19:22 +000038 xmlChar *content; /* The entity content or ndata if unparsed */
Daniel Veillarddbfd6411999-12-28 16:35:14 +000039 int length; /* the content length */
Daniel Veillard00fdf371999-10-08 09:40:39 +000040 xmlChar *orig; /* The entity cont without ref substitution */
Daniel Veillard71b656e2000-01-05 14:46:17 +000041};
Daniel Veillard260a68f1998-08-13 03:39:55 +000042
43/*
44 * ALl entities are stored in a table there is one table per DTD
45 * and one extra per document.
46 */
47
48#define XML_MIN_ENTITIES_TABLE 32
49
Daniel Veillard71b656e2000-01-05 14:46:17 +000050typedef struct _xmlEntitiesTable xmlEntitiesTable;
51typedef xmlEntitiesTable *xmlEntitiesTablePtr;
52struct _xmlEntitiesTable {
Daniel Veillard260a68f1998-08-13 03:39:55 +000053 int nb_entities; /* number of elements stored */
54 int max_entities; /* maximum number of elements */
Daniel Veillardbe36afe1998-11-27 06:39:50 +000055 xmlEntityPtr table; /* the table of entities */
Daniel Veillard71b656e2000-01-05 14:46:17 +000056};
Daniel Veillard260a68f1998-08-13 03:39:55 +000057
Daniel Veillardccb09631998-10-27 06:21:04 +000058
Daniel Veillard260a68f1998-08-13 03:39:55 +000059/*
60 * External functions :
61 */
62
Daniel Veillardb96e6431999-08-29 21:02:19 +000063void xmlAddDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000064 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000065 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000066 const xmlChar *ExternalID,
67 const xmlChar *SystemID,
68 const xmlChar *content);
Daniel Veillardb96e6431999-08-29 21:02:19 +000069void xmlAddDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000070 const xmlChar *name,
Daniel Veillardb96e6431999-08-29 21:02:19 +000071 int type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000072 const xmlChar *ExternalID,
73 const xmlChar *SystemID,
74 const xmlChar *content);
75xmlEntityPtr xmlGetPredefinedEntity (const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +000076xmlEntityPtr xmlGetDocEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000077 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +000078xmlEntityPtr xmlGetDtdEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000079 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +000080xmlEntityPtr xmlGetParameterEntity (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000081 const xmlChar *name);
82const xmlChar * xmlEncodeEntities (xmlDocPtr doc,
83 const xmlChar *input);
Daniel Veillard00fdf371999-10-08 09:40:39 +000084xmlChar * xmlEncodeEntitiesReentrant(xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +000085 const xmlChar *input);
Daniel Veillardb96e6431999-08-29 21:02:19 +000086xmlEntitiesTablePtr xmlCreateEntitiesTable (void);
87xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
88void xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
89void xmlDumpEntitiesTable (xmlBufferPtr buf,
90 xmlEntitiesTablePtr table);
91xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
Daniel Veillarda594bf41999-12-01 09:51:45 +000092void xmlCleanupPredefinedEntities(void);
Daniel Veillard260a68f1998-08-13 03:39:55 +000093
94#ifdef __cplusplus
95}
96#endif
97
98# endif /* __XML_ENTITIES_H__ */