PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/ext/dom/entity.c

http://github.com/infusion/PHP
C | 195 lines | 91 code | 35 blank | 69 comment | 16 complexity | cc2048d4ff66508166635af7a7e5ee3f MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2011 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. /* $Id: entity.c 306939 2011-01-01 02:19:59Z felipe $ */
  20. #ifdef HAVE_CONFIG_H
  21. #include "config.h"
  22. #endif
  23. #include "php.h"
  24. #if HAVE_LIBXML && HAVE_DOM
  25. #include "php_dom.h"
  26. /*
  27. * class DOMEntity extends DOMNode
  28. *
  29. * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-527DCFF2
  30. * Since:
  31. */
  32. const zend_function_entry php_dom_entity_class_functions[] = {
  33. {NULL, NULL, NULL}
  34. };
  35. /* {{{ publicId string
  36. readonly=yes
  37. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025
  38. Since:
  39. */
  40. int dom_entity_public_id_read(dom_object *obj, zval **retval TSRMLS_DC)
  41. {
  42. xmlEntity *nodep;
  43. nodep = (xmlEntity *) dom_object_get_node(obj);
  44. if (nodep == NULL) {
  45. php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
  46. return FAILURE;
  47. }
  48. ALLOC_ZVAL(*retval);
  49. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  50. ZVAL_NULL(*retval);
  51. } else {
  52. ZVAL_STRING(*retval, (char *) (nodep->ExternalID), 1);
  53. }
  54. return SUCCESS;
  55. }
  56. /* }}} */
  57. /* {{{ systemId string
  58. readonly=yes
  59. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7C29F3E
  60. Since:
  61. */
  62. int dom_entity_system_id_read(dom_object *obj, zval **retval TSRMLS_DC)
  63. {
  64. xmlEntity *nodep;
  65. nodep = (xmlEntity *) dom_object_get_node(obj);
  66. if (nodep == NULL) {
  67. php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
  68. return FAILURE;
  69. }
  70. ALLOC_ZVAL(*retval);
  71. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  72. ZVAL_NULL(*retval);
  73. } else {
  74. ZVAL_STRING(*retval, (char *) (nodep->SystemID), 1);
  75. }
  76. return SUCCESS;
  77. }
  78. /* }}} */
  79. /* {{{ notationName string
  80. readonly=yes
  81. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-6ABAEB38
  82. Since:
  83. */
  84. int dom_entity_notation_name_read(dom_object *obj, zval **retval TSRMLS_DC)
  85. {
  86. xmlEntity *nodep;
  87. char *content;
  88. nodep = (xmlEntity *) dom_object_get_node(obj);
  89. if (nodep == NULL) {
  90. php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
  91. return FAILURE;
  92. }
  93. ALLOC_ZVAL(*retval);
  94. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  95. ZVAL_NULL(*retval);
  96. } else {
  97. content = xmlNodeGetContent((xmlNodePtr) nodep);
  98. ZVAL_STRING(*retval, content, 1);
  99. xmlFree(content);
  100. }
  101. return SUCCESS;
  102. }
  103. /* }}} */
  104. /* {{{ actualEncoding string
  105. readonly=no
  106. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-actualEncoding
  107. Since: DOM Level 3
  108. */
  109. int dom_entity_actual_encoding_read(dom_object *obj, zval **retval TSRMLS_DC)
  110. {
  111. ALLOC_ZVAL(*retval);
  112. ZVAL_NULL(*retval);
  113. return SUCCESS;
  114. }
  115. int dom_entity_actual_encoding_write(dom_object *obj, zval *newval TSRMLS_DC)
  116. {
  117. return SUCCESS;
  118. }
  119. /* }}} */
  120. /* {{{ encoding string
  121. readonly=no
  122. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding
  123. Since: DOM Level 3
  124. */
  125. int dom_entity_encoding_read(dom_object *obj, zval **retval TSRMLS_DC)
  126. {
  127. ALLOC_ZVAL(*retval);
  128. ZVAL_NULL(*retval);
  129. return SUCCESS;
  130. }
  131. int dom_entity_encoding_write(dom_object *obj, zval *newval TSRMLS_DC)
  132. {
  133. return SUCCESS;
  134. }
  135. /* }}} */
  136. /* {{{ version string
  137. readonly=no
  138. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version
  139. Since: DOM Level 3
  140. */
  141. int dom_entity_version_read(dom_object *obj, zval **retval TSRMLS_DC)
  142. {
  143. ALLOC_ZVAL(*retval);
  144. ZVAL_NULL(*retval);
  145. return SUCCESS;
  146. }
  147. int dom_entity_version_write(dom_object *obj, zval *newval TSRMLS_DC)
  148. {
  149. return SUCCESS;
  150. }
  151. /* }}} */
  152. #endif
  153. /*
  154. * Local variables:
  155. * tab-width: 4
  156. * c-basic-offset: 4
  157. * End:
  158. * vim600: noet sw=4 ts=4 fdm=marker
  159. * vim<600: noet sw=4 ts=4
  160. */