entity.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Christian Stocker <chregu@php.net> |
  16. | Rob Richards <rrichards@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include "php.h"
  23. #if HAVE_LIBXML && HAVE_DOM
  24. #include "php_dom.h"
  25. /*
  26. * class DOMEntity extends DOMNode
  27. *
  28. * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-527DCFF2
  29. * Since:
  30. */
  31. const zend_function_entry php_dom_entity_class_functions[] = {
  32. PHP_FE_END
  33. };
  34. /* {{{ publicId string
  35. readonly=yes
  36. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025
  37. Since:
  38. */
  39. int dom_entity_public_id_read(dom_object *obj, zval *retval)
  40. {
  41. xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
  42. if (nodep == NULL) {
  43. php_dom_throw_error(INVALID_STATE_ERR, 0);
  44. return FAILURE;
  45. }
  46. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  47. ZVAL_NULL(retval);
  48. } else {
  49. ZVAL_STRING(retval, (char *) (nodep->ExternalID));
  50. }
  51. return SUCCESS;
  52. }
  53. /* }}} */
  54. /* {{{ systemId string
  55. readonly=yes
  56. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7C29F3E
  57. Since:
  58. */
  59. int dom_entity_system_id_read(dom_object *obj, zval *retval)
  60. {
  61. xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
  62. if (nodep == NULL) {
  63. php_dom_throw_error(INVALID_STATE_ERR, 0);
  64. return FAILURE;
  65. }
  66. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  67. ZVAL_NULL(retval);
  68. } else {
  69. ZVAL_STRING(retval, (char *) (nodep->SystemID));
  70. }
  71. return SUCCESS;
  72. }
  73. /* }}} */
  74. /* {{{ notationName string
  75. readonly=yes
  76. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-6ABAEB38
  77. Since:
  78. */
  79. int dom_entity_notation_name_read(dom_object *obj, zval *retval)
  80. {
  81. xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
  82. char *content;
  83. if (nodep == NULL) {
  84. php_dom_throw_error(INVALID_STATE_ERR, 0);
  85. return FAILURE;
  86. }
  87. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  88. ZVAL_NULL(retval);
  89. } else {
  90. content = (char *) xmlNodeGetContent((xmlNodePtr) nodep);
  91. ZVAL_STRING(retval, content);
  92. xmlFree(content);
  93. }
  94. return SUCCESS;
  95. }
  96. /* }}} */
  97. /* {{{ actualEncoding string
  98. readonly=no
  99. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-actualEncoding
  100. Since: DOM Level 3
  101. */
  102. int dom_entity_actual_encoding_read(dom_object *obj, zval *retval)
  103. {
  104. ZVAL_NULL(retval);
  105. return SUCCESS;
  106. }
  107. int dom_entity_actual_encoding_write(dom_object *obj, zval *newval)
  108. {
  109. return SUCCESS;
  110. }
  111. /* }}} */
  112. /* {{{ encoding string
  113. readonly=no
  114. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding
  115. Since: DOM Level 3
  116. */
  117. int dom_entity_encoding_read(dom_object *obj, zval *retval)
  118. {
  119. ZVAL_NULL(retval);
  120. return SUCCESS;
  121. }
  122. int dom_entity_encoding_write(dom_object *obj, zval *newval)
  123. {
  124. return SUCCESS;
  125. }
  126. /* }}} */
  127. /* {{{ version string
  128. readonly=no
  129. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version
  130. Since: DOM Level 3
  131. */
  132. int dom_entity_version_read(dom_object *obj, zval *retval)
  133. {
  134. ZVAL_NULL(retval);
  135. return SUCCESS;
  136. }
  137. int dom_entity_version_write(dom_object *obj, zval *newval)
  138. {
  139. return SUCCESS;
  140. }
  141. /* }}} */
  142. #endif
  143. /*
  144. * Local variables:
  145. * tab-width: 4
  146. * c-basic-offset: 4
  147. * End:
  148. * vim600: noet sw=4 ts=4 fdm=marker
  149. * vim<600: noet sw=4 ts=4
  150. */