1 /* 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. 5 * 6 * Copy: See Copyright for the status of this software. 7 * 8 * Author: Daniel Veillard 9 */ 10 11 #ifndef __XML_ENTITIES_H__ 12 #define __XML_ENTITIES_H__ 13 14 /** DOC_DISABLE */ 15 #include <libxml/xmlversion.h> 16 #define XML_TREE_INTERNALS 17 #include <libxml/tree.h> 18 #undef XML_TREE_INTERNALS 19 /** DOC_ENABLE */ 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /* 26 * The different valid entity types. 27 */ 28 typedef enum { 29 XML_INTERNAL_GENERAL_ENTITY = 1, 30 XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, 31 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, 32 XML_INTERNAL_PARAMETER_ENTITY = 4, 33 XML_EXTERNAL_PARAMETER_ENTITY = 5, 34 XML_INTERNAL_PREDEFINED_ENTITY = 6 35 } xmlEntityType; 36 37 /* 38 * An unit of storage for an entity, contains the string, the value 39 * and the linkind data needed for the linking in the hash table. 40 */ 41 42 struct _xmlEntity { 43 void *_private; /* application data */ 44 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ 45 const xmlChar *name; /* Entity name */ 46 struct _xmlNode *children; /* First child link */ 47 struct _xmlNode *last; /* Last child link */ 48 struct _xmlDtd *parent; /* -> DTD */ 49 struct _xmlNode *next; /* next sibling link */ 50 struct _xmlNode *prev; /* previous sibling link */ 51 struct _xmlDoc *doc; /* the containing document */ 52 53 xmlChar *orig; /* content without ref substitution */ 54 xmlChar *content; /* content or ndata if unparsed */ 55 int length; /* the content length */ 56 xmlEntityType etype; /* The entity type */ 57 const xmlChar *ExternalID; /* External identifier for PUBLIC */ 58 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */ 59 60 struct _xmlEntity *nexte; /* unused */ 61 const xmlChar *URI; /* the full URI as computed */ 62 int owner; /* unused */ 63 int flags; /* various flags */ 64 unsigned long expandedSize; /* expanded size */ 65 }; 66 67 /* 68 * All entities are stored in an hash table. 69 * There is 2 separate hash tables for global and parameter entities. 70 */ 71 72 typedef struct _xmlHashTable xmlEntitiesTable; 73 typedef xmlEntitiesTable *xmlEntitiesTablePtr; 74 75 /* 76 * External functions: 77 */ 78 79 XMLPUBFUN xmlEntityPtr 80 xmlNewEntity (xmlDocPtr doc, 81 const xmlChar *name, 82 int type, 83 const xmlChar *ExternalID, 84 const xmlChar *SystemID, 85 const xmlChar *content); 86 XMLPUBFUN void 87 xmlFreeEntity (xmlEntityPtr entity); 88 XMLPUBFUN int 89 xmlAddEntity (xmlDocPtr doc, 90 int extSubset, 91 const xmlChar *name, 92 int type, 93 const xmlChar *ExternalID, 94 const xmlChar *SystemID, 95 const xmlChar *content, 96 xmlEntityPtr *out); 97 XMLPUBFUN xmlEntityPtr 98 xmlAddDocEntity (xmlDocPtr doc, 99 const xmlChar *name, 100 int type, 101 const xmlChar *ExternalID, 102 const xmlChar *SystemID, 103 const xmlChar *content); 104 XMLPUBFUN xmlEntityPtr 105 xmlAddDtdEntity (xmlDocPtr doc, 106 const xmlChar *name, 107 int type, 108 const xmlChar *ExternalID, 109 const xmlChar *SystemID, 110 const xmlChar *content); 111 XMLPUBFUN xmlEntityPtr 112 xmlGetPredefinedEntity (const xmlChar *name); 113 XMLPUBFUN xmlEntityPtr 114 xmlGetDocEntity (const xmlDoc *doc, 115 const xmlChar *name); 116 XMLPUBFUN xmlEntityPtr 117 xmlGetDtdEntity (xmlDocPtr doc, 118 const xmlChar *name); 119 XMLPUBFUN xmlEntityPtr 120 xmlGetParameterEntity (xmlDocPtr doc, 121 const xmlChar *name); 122 XMLPUBFUN xmlChar * 123 xmlEncodeEntitiesReentrant(xmlDocPtr doc, 124 const xmlChar *input); 125 XMLPUBFUN xmlChar * 126 xmlEncodeSpecialChars (const xmlDoc *doc, 127 const xmlChar *input); 128 XMLPUBFUN xmlEntitiesTablePtr 129 xmlCreateEntitiesTable (void); 130 XMLPUBFUN xmlEntitiesTablePtr 131 xmlCopyEntitiesTable (xmlEntitiesTablePtr table); 132 XMLPUBFUN void 133 xmlFreeEntitiesTable (xmlEntitiesTablePtr table); 134 #ifdef LIBXML_OUTPUT_ENABLED 135 XMLPUBFUN void 136 xmlDumpEntitiesTable (xmlBufferPtr buf, 137 xmlEntitiesTablePtr table); 138 XMLPUBFUN void 139 xmlDumpEntityDecl (xmlBufferPtr buf, 140 xmlEntityPtr ent); 141 #endif /* LIBXML_OUTPUT_ENABLED */ 142 143 #ifdef __cplusplus 144 } 145 #endif 146 147 # endif /* __XML_ENTITIES_H__ */ 148