cdatasection.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 DOMCdataSection extends DOMText
  25. *
  26. * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-667469212
  27. * Since:
  28. */
  29. /* {{{ */
  30. PHP_METHOD(DOMCdataSection, __construct)
  31. {
  32. xmlNodePtr nodep = NULL, oldnode = NULL;
  33. dom_object *intern;
  34. char *value = NULL;
  35. size_t value_len;
  36. if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &value, &value_len) == FAILURE) {
  37. RETURN_THROWS();
  38. }
  39. nodep = xmlNewCDataBlock(NULL, (xmlChar *) value, value_len);
  40. if (!nodep) {
  41. php_dom_throw_error(INVALID_STATE_ERR, 1);
  42. RETURN_THROWS();
  43. }
  44. intern = Z_DOMOBJ_P(ZEND_THIS);
  45. oldnode = dom_object_get_node(intern);
  46. if (oldnode != NULL) {
  47. php_libxml_node_free_resource(oldnode );
  48. }
  49. php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern);
  50. }
  51. /* }}} end DOMCdataSection::__construct */
  52. #endif