/*
+----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
+ | PHP version 4.0 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
+ | Copyright (c) 1997, 1998, 1999 The PHP Group |
+----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
+ | This source file is subject to version 2.0 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_0.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Authors: Stig Sæther Bakken <ssb@guardian.no> |
+ | Authors: Stig Sæther Bakken <ssb@fast.no> |
+ | Thies C. Arntzen <thies@digicol.de> |
+----------------------------------------------------------------------+
- */
+*/
/* $Id$ */
char *externalEntityRefHandler;
char *unknownEncodingHandler;
- pval *data;
- pval *info;
+ zval *object;
+
+ zval *data;
+ zval *info;
int level;
int toffset;
int curtag;
#define XML_MAXLEVEL 255 /* XXX this should be dynamic */
PHP_FUNCTION(xml_parser_create);
+PHP_FUNCTION(xml_set_object);
PHP_FUNCTION(xml_set_element_handler);
PHP_FUNCTION(xml_set_character_data_handler);
PHP_FUNCTION(xml_set_processing_instruction_handler);
PHP_RSHUTDOWN_FUNCTION(xml);
PHP_MINFO_FUNCTION(xml);
-static void xml_destroy_parser(xml_parser *);
+static void xml_parser_dtor(xml_parser *);
static void xml_set_handler(char **, zval **);
inline static unsigned short xml_encode_iso_8859_1(unsigned char);
inline static char xml_decode_iso_8859_1(unsigned short);
function_entry xml_functions[] = {
PHP_FE(xml_parser_create, NULL)
+ PHP_FE(xml_set_object, NULL)
PHP_FE(xml_set_element_handler, NULL)
PHP_FE(xml_set_character_data_handler, NULL)
PHP_FE(xml_set_processing_instruction_handler, NULL)
ELS_FETCH();
- le_xml_parser = register_list_destructors(xml_destroy_parser, NULL);
+ le_xml_parser = register_list_destructors(xml_parser_dtor, NULL);
#ifdef ZTS
xml_globals_id = ts_allocate_id(sizeof(php_xml_globals), php_xml_init_globals, NULL);
/* }}} */
-/* {{{ xml_destroy_parser() */
+/* {{{ xml_parser_dtor() */
static void
-xml_destroy_parser(xml_parser *parser)
+xml_parser_dtor(xml_parser *parser)
{
+
+ if (parser->object) {
+/*
+ zval_del_ref(&parser->object);
+*/
+ }
+
if (parser->parser) {
XML_ParserFree(parser->parser);
}
retval->type = IS_BOOL;
retval->value.lval = 0;
- /* We cannot call internal variables from a function module as
- it breaks any chance of compiling it as a module on windows.
- Instead, we create a callback function. */
-
- result = call_user_function(EG(function_table), NULL, func, retval, argc, argv);
+ result = call_user_function(EG(function_table), parser->object, func, retval, argc, argv);
if (result == FAILURE) {
php_error(E_WARNING, "Unable to call %s()",funcName);
parser->parser = XML_ParserCreate(encoding);
parser->target_encoding = encoding;
parser->case_folding = 1;
+ parser->object = NULL;
XML_SetUserData(parser->parser, parser);
ZEND_REGISTER_RESOURCE(return_value,parser,le_xml_parser);
}
/* }}} */
+/* {{{ proto int xml_set_object(int pind,object &obj)
+ Set up object which should be used for callbacks */
+PHP_FUNCTION(xml_set_object)
+{
+ xml_parser *parser;
+ zval **pind, **mythis;
+
+ if (ARG_COUNT(ht) != 2 ||
+ getParametersEx(2, &pind, &mythis) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ if ((*mythis)->type != IS_OBJECT) {
+ php_error(E_WARNING,"arg 2 has wrong type");
+ RETURN_FALSE;
+ }
+
+ if (! ParameterPassedByReference(ht,2)) {
+ php_error(E_WARNING,"arg 2 not passed by reference");
+ RETURN_FALSE;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *,pind, -1, "XML Parser", le_xml_parser);
+
+ if (parser->object) {
+/*
+ zval_del_ref(&parser->object);
+*/
+ }
+
+ parser->object = *mythis;
+/*
+ zval_add_ref(&parser->object);
+*/
+
+ RETVAL_TRUE;
+}
+/* }}} */
+
/* {{{ proto int xml_set_element_handler(int pind, string shdl, string ehdl)
Set up start and end element handlers */
PHP_FUNCTION(xml_set_element_handler)