entities.h 4.8 KB

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