entityreference.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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$ */
  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. /* {{{ arginfo */
  27. ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_entityreference_construct, 0, 0, 1)
  28. ZEND_ARG_INFO(0, name)
  29. ZEND_END_ARG_INFO();
  30. /* }}} */
  31. /*
  32. * class DOMEntityReference extends DOMNode
  33. *
  34. * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-11C98490
  35. * Since:
  36. */
  37. const zend_function_entry php_dom_entityreference_class_functions[] = {
  38. PHP_ME(domentityreference, __construct, arginfo_dom_entityreference_construct, ZEND_ACC_PUBLIC)
  39. PHP_FE_END
  40. };
  41. /* {{{ proto void DOMEntityReference::__construct(string name); */
  42. PHP_METHOD(domentityreference, __construct)
  43. {
  44. zval *id;
  45. xmlNode *node;
  46. xmlNodePtr oldnode = NULL;
  47. dom_object *intern;
  48. char *name;
  49. int name_len, name_valid;
  50. zend_error_handling error_handling;
  51. zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
  52. if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) {
  53. zend_restore_error_handling(&error_handling TSRMLS_CC);
  54. return;
  55. }
  56. zend_restore_error_handling(&error_handling TSRMLS_CC);
  57. name_valid = xmlValidateName((xmlChar *) name, 0);
  58. if (name_valid != 0) {
  59. php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
  60. RETURN_FALSE;
  61. }
  62. node = xmlNewReference(NULL, name);
  63. if (!node) {
  64. php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
  65. RETURN_FALSE;
  66. }
  67. intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
  68. if (intern != NULL) {
  69. oldnode = dom_object_get_node(intern);
  70. if (oldnode != NULL) {
  71. php_libxml_node_free_resource(oldnode TSRMLS_CC);
  72. }
  73. php_libxml_increment_node_ptr((php_libxml_node_object *)intern, node, (void *)intern TSRMLS_CC);
  74. }
  75. }
  76. /* }}} end DOMEntityReference::__construct */
  77. #endif
  78. /*
  79. * Local variables:
  80. * tab-width: 4
  81. * c-basic-offset: 4
  82. * End:
  83. * vim600: noet sw=4 ts=4 fdm=marker
  84. * vim<600: noet sw=4 ts=4
  85. */