entityreference.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Authors: Christian Stocker <chregu@php.net> |
  14. | Rob Richards <rrichards@php.net> |
  15. +----------------------------------------------------------------------+
  16. */
  17. #ifdef HAVE_CONFIG_H
  18. #include "config.h"
  19. #endif
  20. #include "php.h"
  21. #if defined(HAVE_LIBXML) && defined(HAVE_DOM)
  22. #include "php_dom.h"
  23. /*
  24. * class DOMEntityReference extends DOMNode
  25. *
  26. * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-11C98490
  27. * Since:
  28. */
  29. /* {{{ */
  30. PHP_METHOD(DOMEntityReference, __construct)
  31. {
  32. xmlNode *node;
  33. xmlNodePtr oldnode = NULL;
  34. dom_object *intern;
  35. char *name;
  36. size_t name_len, name_valid;
  37. if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
  38. RETURN_THROWS();
  39. }
  40. name_valid = xmlValidateName((xmlChar *) name, 0);
  41. if (name_valid != 0) {
  42. php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
  43. RETURN_THROWS();
  44. }
  45. node = xmlNewReference(NULL, (xmlChar *) name);
  46. if (!node) {
  47. php_dom_throw_error(INVALID_STATE_ERR, 1);
  48. RETURN_THROWS();
  49. }
  50. intern = Z_DOMOBJ_P(ZEND_THIS);
  51. if (intern != NULL) {
  52. oldnode = dom_object_get_node(intern);
  53. if (oldnode != NULL) {
  54. php_libxml_node_free_resource(oldnode );
  55. }
  56. php_libxml_increment_node_ptr((php_libxml_node_object *)intern, node, (void *)intern);
  57. }
  58. }
  59. /* }}} end DOMEntityReference::__construct */
  60. #endif