blob: 47b4573eba656f2bef00ea4b4e9a3d8613101636 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
Daniel Veillardbe586972003-11-18 20:56:51 +00002 * Summary: interface for the XML entities handling
3 * Description: this module provides some of the entity API needed
4 * for the parser and applications.
Owen Taylor3473f882001-02-23 17:55:21 +00005 *
Daniel Veillardbe586972003-11-18 20:56:51 +00006 * Copy: See Copyright for the status of this software.
Owen Taylor3473f882001-02-23 17:55:21 +00007 *
Daniel Veillardbe586972003-11-18 20:56:51 +00008 * Author: Daniel Veillard
Owen Taylor3473f882001-02-23 17:55:21 +00009 */
10
11#ifndef __XML_ENTITIES_H__
12#define __XML_ENTITIES_H__
13
Igor Zlatkovic76874e42003-08-25 09:05:12 +000014#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000015#include <libxml/tree.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/*
Daniel Veillard61f26172002-03-12 18:46:39 +000022 * The different valid entity types.
Owen Taylor3473f882001-02-23 17:55:21 +000023 */
24typedef 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
Owen Taylor3473f882001-02-23 17:55:21 +000038struct _xmlEntity {
Daniel Veillardcbaf3992001-12-31 16:16:02 +000039 void *_private; /* application data */
Owen Taylor3473f882001-02-23 17:55:21 +000040 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
Daniel Veillarde4301c82002-02-13 13:32:35 +000041 const xmlChar *name; /* Entity name */
Daniel Veillard8ee9c8f2002-01-26 21:42:58 +000042 struct _xmlNode *children; /* First child link */
43 struct _xmlNode *last; /* Last child link */
Owen Taylor3473f882001-02-23 17:55:21 +000044 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 */
Daniel Veillard2d84a892002-12-30 00:01:08 +000058 int owner; /* does the entity own the childrens */
Daniel Veillarda37a6ad2006-10-10 20:05:45 +000059 int checked; /* was the entity content checked */
Jan Pokorný9a85d402013-11-29 23:26:25 +010060 /* this is also used to count entities
Daniel Veillardcff25462013-03-11 15:57:55 +080061 * references done from that entity
62 * and if it contains '<' */
Owen Taylor3473f882001-02-23 17:55:21 +000063};
64
65/*
Daniel Veillard61f26172002-03-12 18:46:39 +000066 * All entities are stored in an hash table.
67 * There is 2 separate hash tables for global and parameter entities.
Owen Taylor3473f882001-02-23 17:55:21 +000068 */
69
70typedef struct _xmlHashTable xmlEntitiesTable;
71typedef xmlEntitiesTable *xmlEntitiesTablePtr;
72
73/*
Daniel Veillard61f26172002-03-12 18:46:39 +000074 * External functions:
Owen Taylor3473f882001-02-23 17:55:21 +000075 */
76
William M. Brack21e4ef22005-01-02 09:53:13 +000077#ifdef LIBXML_LEGACY_ENABLED
Daniel Veillardaa6de472008-08-25 14:53:31 +000078XMLPUBFUN void XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +000079 xmlInitializePredefinedEntities (void);
William M. Brack21e4ef22005-01-02 09:53:13 +000080#endif /* LIBXML_LEGACY_ENABLED */
Daniel Veillardaa6de472008-08-25 14:53:31 +000081
82XMLPUBFUN xmlEntityPtr XMLCALL
83 xmlNewEntity (xmlDocPtr doc,
84 const xmlChar *name,
85 int type,
86 const xmlChar *ExternalID,
87 const xmlChar *SystemID,
88 const xmlChar *content);
Igor Zlatkovic76874e42003-08-25 09:05:12 +000089XMLPUBFUN xmlEntityPtr XMLCALL
90 xmlAddDocEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +000091 const xmlChar *name,
92 int type,
93 const xmlChar *ExternalID,
94 const xmlChar *SystemID,
95 const xmlChar *content);
Daniel Veillardaa6de472008-08-25 14:53:31 +000096XMLPUBFUN xmlEntityPtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +000097 xmlAddDtdEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +000098 const xmlChar *name,
99 int type,
100 const xmlChar *ExternalID,
101 const xmlChar *SystemID,
102 const xmlChar *content);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000103XMLPUBFUN xmlEntityPtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000104 xmlGetPredefinedEntity (const xmlChar *name);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000105XMLPUBFUN xmlEntityPtr XMLCALL
Kurt Roeckx95ebe532014-10-13 16:06:21 +0800106 xmlGetDocEntity (const xmlDoc *doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000107 const xmlChar *name);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000108XMLPUBFUN xmlEntityPtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000109 xmlGetDtdEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000110 const xmlChar *name);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000111XMLPUBFUN xmlEntityPtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000112 xmlGetParameterEntity (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000113 const xmlChar *name);
William M. Brack21e4ef22005-01-02 09:53:13 +0000114#ifdef LIBXML_LEGACY_ENABLED
Daniel Veillardaa6de472008-08-25 14:53:31 +0000115XMLPUBFUN const xmlChar * XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000116 xmlEncodeEntities (xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000117 const xmlChar *input);
William M. Brack21e4ef22005-01-02 09:53:13 +0000118#endif /* LIBXML_LEGACY_ENABLED */
Daniel Veillardaa6de472008-08-25 14:53:31 +0000119XMLPUBFUN xmlChar * XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000120 xmlEncodeEntitiesReentrant(xmlDocPtr doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000121 const xmlChar *input);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000122XMLPUBFUN xmlChar * XMLCALL
Kurt Roeckx95ebe532014-10-13 16:06:21 +0800123 xmlEncodeSpecialChars (const xmlDoc *doc,
Owen Taylor3473f882001-02-23 17:55:21 +0000124 const xmlChar *input);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000125XMLPUBFUN xmlEntitiesTablePtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000126 xmlCreateEntitiesTable (void);
William M. Brack21e4ef22005-01-02 09:53:13 +0000127#ifdef LIBXML_TREE_ENABLED
Daniel Veillardaa6de472008-08-25 14:53:31 +0000128XMLPUBFUN xmlEntitiesTablePtr XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000129 xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
William M. Brack21e4ef22005-01-02 09:53:13 +0000130#endif /* LIBXML_TREE_ENABLED */
Daniel Veillardaa6de472008-08-25 14:53:31 +0000131XMLPUBFUN void XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000132 xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000133#ifdef LIBXML_OUTPUT_ENABLED
Daniel Veillardaa6de472008-08-25 14:53:31 +0000134XMLPUBFUN void XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000135 xmlDumpEntitiesTable (xmlBufferPtr buf,
Owen Taylor3473f882001-02-23 17:55:21 +0000136 xmlEntitiesTablePtr table);
Daniel Veillardaa6de472008-08-25 14:53:31 +0000137XMLPUBFUN void XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000138 xmlDumpEntityDecl (xmlBufferPtr buf,
Owen Taylor3473f882001-02-23 17:55:21 +0000139 xmlEntityPtr ent);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000140#endif /* LIBXML_OUTPUT_ENABLED */
William M. Brack21e4ef22005-01-02 09:53:13 +0000141#ifdef LIBXML_LEGACY_ENABLED
Daniel Veillardaa6de472008-08-25 14:53:31 +0000142XMLPUBFUN void XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000143 xmlCleanupPredefinedEntities(void);
William M. Brack21e4ef22005-01-02 09:53:13 +0000144#endif /* LIBXML_LEGACY_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +0000145
146
147#ifdef __cplusplus
148}
149#endif
150
151# endif /* __XML_ENTITIES_H__ */