Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 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. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 5 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 6 | * Copy: See Copyright for the status of this software. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 7 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 8 | * Author: Daniel Veillard |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef __XML_ENTITIES_H__ |
| 12 | #define __XML_ENTITIES_H__ |
| 13 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 14 | #include <libxml/xmlversion.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 15 | #include <libxml/tree.h> |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 22 | * The different valid entity types. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 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 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 38 | struct _xmlEntity { |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 39 | void *_private; /* application data */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 40 | xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ |
Daniel Veillard | e4301c8 | 2002-02-13 13:32:35 +0000 | [diff] [blame] | 41 | const xmlChar *name; /* Entity name */ |
Daniel Veillard | 8ee9c8f | 2002-01-26 21:42:58 +0000 | [diff] [blame] | 42 | struct _xmlNode *children; /* First child link */ |
| 43 | struct _xmlNode *last; /* Last child link */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 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 */ |
Daniel Veillard | 2d84a89 | 2002-12-30 00:01:08 +0000 | [diff] [blame] | 58 | int owner; /* does the entity own the childrens */ |
Daniel Veillard | a37a6ad | 2006-10-10 20:05:45 +0000 | [diff] [blame] | 59 | int checked; /* was the entity content checked */ |
Jan Pokorný | 9a85d40 | 2013-11-29 23:26:25 +0100 | [diff] [blame] | 60 | /* this is also used to count entities |
Daniel Veillard | cff2546 | 2013-03-11 15:57:55 +0800 | [diff] [blame] | 61 | * references done from that entity |
| 62 | * and if it contains '<' */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 66 | * All entities are stored in an hash table. |
| 67 | * There is 2 separate hash tables for global and parameter entities. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 68 | */ |
| 69 | |
| 70 | typedef struct _xmlHashTable xmlEntitiesTable; |
| 71 | typedef xmlEntitiesTable *xmlEntitiesTablePtr; |
| 72 | |
| 73 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 74 | * External functions: |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 75 | */ |
| 76 | |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 77 | #ifdef LIBXML_LEGACY_ENABLED |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 78 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 79 | xmlInitializePredefinedEntities (void); |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 80 | #endif /* LIBXML_LEGACY_ENABLED */ |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 81 | |
| 82 | XMLPUBFUN 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 Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 89 | XMLPUBFUN xmlEntityPtr XMLCALL |
| 90 | xmlAddDocEntity (xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 91 | const xmlChar *name, |
| 92 | int type, |
| 93 | const xmlChar *ExternalID, |
| 94 | const xmlChar *SystemID, |
| 95 | const xmlChar *content); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 96 | XMLPUBFUN xmlEntityPtr XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 97 | xmlAddDtdEntity (xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 98 | const xmlChar *name, |
| 99 | int type, |
| 100 | const xmlChar *ExternalID, |
| 101 | const xmlChar *SystemID, |
| 102 | const xmlChar *content); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 103 | XMLPUBFUN xmlEntityPtr XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 104 | xmlGetPredefinedEntity (const xmlChar *name); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 105 | XMLPUBFUN xmlEntityPtr XMLCALL |
Kurt Roeckx | 95ebe53 | 2014-10-13 16:06:21 +0800 | [diff] [blame] | 106 | xmlGetDocEntity (const xmlDoc *doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 107 | const xmlChar *name); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 108 | XMLPUBFUN xmlEntityPtr XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 109 | xmlGetDtdEntity (xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 110 | const xmlChar *name); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 111 | XMLPUBFUN xmlEntityPtr XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 112 | xmlGetParameterEntity (xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 113 | const xmlChar *name); |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 114 | #ifdef LIBXML_LEGACY_ENABLED |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 115 | XMLPUBFUN const xmlChar * XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 116 | xmlEncodeEntities (xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 117 | const xmlChar *input); |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 118 | #endif /* LIBXML_LEGACY_ENABLED */ |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 119 | XMLPUBFUN xmlChar * XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 120 | xmlEncodeEntitiesReentrant(xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 121 | const xmlChar *input); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 122 | XMLPUBFUN xmlChar * XMLCALL |
Kurt Roeckx | 95ebe53 | 2014-10-13 16:06:21 +0800 | [diff] [blame] | 123 | xmlEncodeSpecialChars (const xmlDoc *doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 124 | const xmlChar *input); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 125 | XMLPUBFUN xmlEntitiesTablePtr XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 126 | xmlCreateEntitiesTable (void); |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 127 | #ifdef LIBXML_TREE_ENABLED |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 128 | XMLPUBFUN xmlEntitiesTablePtr XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 129 | xmlCopyEntitiesTable (xmlEntitiesTablePtr table); |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 130 | #endif /* LIBXML_TREE_ENABLED */ |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 131 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 132 | xmlFreeEntitiesTable (xmlEntitiesTablePtr table); |
Daniel Veillard | a9cce9c | 2003-09-29 13:20:24 +0000 | [diff] [blame] | 133 | #ifdef LIBXML_OUTPUT_ENABLED |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 134 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 135 | xmlDumpEntitiesTable (xmlBufferPtr buf, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 136 | xmlEntitiesTablePtr table); |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 137 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 138 | xmlDumpEntityDecl (xmlBufferPtr buf, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 139 | xmlEntityPtr ent); |
Daniel Veillard | a9cce9c | 2003-09-29 13:20:24 +0000 | [diff] [blame] | 140 | #endif /* LIBXML_OUTPUT_ENABLED */ |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 141 | #ifdef LIBXML_LEGACY_ENABLED |
Daniel Veillard | aa6de47 | 2008-08-25 14:53:31 +0000 | [diff] [blame] | 142 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 143 | xmlCleanupPredefinedEntities(void); |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 144 | #endif /* LIBXML_LEGACY_ENABLED */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 145 | |
| 146 | |
| 147 | #ifdef __cplusplus |
| 148 | } |
| 149 | #endif |
| 150 | |
| 151 | # endif /* __XML_ENTITIES_H__ */ |