Guest User

Keisial

a guest
Sep 22nd, 2008
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- php5.3-200809221430a\ext\xmlreader\php_xmlreader.c  2008-08-23 20:35:12.000000000 +0200
  2. +++ php5.3-200809221430\ext\xmlreader\php_xmlreader.c   2008-09-22 23:52:08.000000000 +0200
  3. @@ -55,6 +55,18 @@
  4.  #define XMLREADER_LOAD_STRING 0
  5.  #define XMLREADER_LOAD_FILE 1
  6.  
  7. +static int php_libxml_streams_IO_read(void *context, char *buffer, int len)
  8. +{
  9. +   TSRMLS_FETCH();
  10. +   return php_stream_read((php_stream*)context, buffer, len);
  11. +}
  12. +
  13. +static int php_libxml_streams_IO_close(void *context)
  14. +{
  15. +   TSRMLS_FETCH();
  16. +   return php_stream_close((php_stream*)context);
  17. +}
  18. +
  19.  /* {{{ xmlreader_register_prop_handler */
  20.  static void xmlreader_register_prop_handler(HashTable *prop_handler, char *name, xmlreader_read_int_t read_int_func, xmlreader_read_const_char_t read_char_func, int rettype TSRMLS_DC)
  21.  {
  22. @@ -916,6 +928,72 @@
  23.  }
  24.  /* }}} */
  25.  
  26. +/* {{{ proto boolean XMLReader::open_stream(resource stream [, string URI [, string encoding [, int options]]])
  27. +Set XMLReader to work on an open stream  */
  28. +PHP_METHOD(xmlreader, open_stream)
  29. +{
  30. +   zval *id;
  31. +   int uri_len = 0, encoding_len = 0;
  32. +   long options = 0;
  33. +   xmlreader_object *intern = NULL;
  34. +   char *uri;
  35. +   char *encoding = NULL;
  36. +   xmlParserInputBufferPtr parser_input_buffer;
  37. +   xmlTextReaderPtr reader = NULL;
  38. +   zval *arg1;
  39. +   php_stream *stream;
  40. +  
  41. +   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ss!l", &arg1, &uri, &uri_len, &encoding, &encoding_len, &options) == FAILURE) {
  42. +       return;
  43. +   }
  44. +
  45. +   php_stream_from_zval_no_verify(stream, &arg1);
  46. +   if (stream == NULL) {
  47. +       php_error_docref(NULL TSRMLS_CC, E_WARNING, "First parameter is not a valid stream");
  48. +       RETURN_FALSE;
  49. +   }
  50. +      
  51. +   id = getThis();
  52. +   if (id != NULL) {
  53. +       if (! instanceof_function(Z_OBJCE_P(id), xmlreader_class_entry TSRMLS_CC)) {
  54. +           id = NULL;
  55. +       } else {
  56. +           intern = (xmlreader_object *)zend_object_store_get_object(id TSRMLS_CC);
  57. +           xmlreader_free_resources(intern);
  58. +       }
  59. +   }
  60. +
  61. +   /* Allocate the Input buffer front-end. */
  62. +   parser_input_buffer = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
  63. +   if (parser_input_buffer != NULL) {
  64. +       parser_input_buffer->context = stream;
  65. +       parser_input_buffer->readcallback = php_libxml_streams_IO_read;
  66. +       parser_input_buffer->closecallback = php_libxml_streams_IO_close;
  67. +      
  68. +       if (encoding != NULL)
  69. +         parser_input_buffer->encoder = xmlFindCharEncodingHandler(encoding);
  70. +   }  
  71. +
  72. +    reader = xmlNewTextReader(parser_input_buffer, uri);
  73. +   if (reader == NULL) {
  74. +       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open");
  75. +       RETURN_FALSE;
  76. +   }
  77. +
  78. +   if (id == NULL) {
  79. +       object_init_ex(return_value, xmlreader_class_entry);
  80. +       intern = (xmlreader_object *)zend_objects_get_address(return_value TSRMLS_CC);
  81. +       intern->ptr = reader;
  82. +       return;
  83. +   }
  84. +
  85. +   intern->ptr = reader;
  86. +
  87. +   RETURN_TRUE;
  88. +
  89. +}
  90. +/* }}} */
  91. +
  92.  /* Not Yet Implemented in libxml - functions exist just not coded
  93.  PHP_METHOD(xmlreader, resetState)
  94.  {
  95. @@ -1249,6 +1327,14 @@
  96.  ZEND_END_ARG_INFO()
  97.  
  98.  static
  99. +ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlreader_open_stream, 0, 0, 1)
  100. +   ZEND_ARG_INFO(0, stream)   
  101. +   ZEND_ARG_INFO(0, URI)
  102. +   ZEND_ARG_INFO(0, encoding)
  103. +   ZEND_ARG_INFO(0, options)
  104. +ZEND_END_ARG_INFO()
  105. +
  106. +static
  107.  ZEND_BEGIN_ARG_INFO(arginfo_xmlreader_readInnerXml, 0)
  108.  ZEND_END_ARG_INFO()
  109.  
  110. @@ -1308,6 +1394,7 @@
  111.     PHP_ME(xmlreader, moveToFirstAttribute, arginfo_xmlreader_moveToFirstAttribute, ZEND_ACC_PUBLIC)
  112.     PHP_ME(xmlreader, moveToNextAttribute, arginfo_xmlreader_moveToNextAttribute, ZEND_ACC_PUBLIC)
  113.     PHP_ME(xmlreader, open, arginfo_xmlreader_open, ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
  114. +   PHP_ME(xmlreader, open_stream, arginfo_xmlreader_open_stream, ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
  115.     PHP_ME(xmlreader, read, arginfo_xmlreader_read, ZEND_ACC_PUBLIC)
  116.     PHP_ME(xmlreader, next, arginfo_xmlreader_next, ZEND_ACC_PUBLIC)
  117.  #if LIBXML_VERSION >= 20620
  118.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×