From: Jan Borsodi Date: Thu, 4 Jan 2001 12:27:39 +0000 (+0000) Subject: New function qdom_error which returns the error text from the last qdom operation... X-Git-Tag: php-4.0.5RC1~738 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0798a81739460b3d17791e23bee9b6ea1efe7e48;p=php New function qdom_error which returns the error text from the last qdom operation, or FALSE if none occured. Fixed the documentation for the qdom_tree function. Added init and shutdown code for some global variables. Added code for starting and stopping the Qt Message Handler in qdom_tree. --- diff --git a/ext/qtdom/qtdom.c b/ext/qtdom/qtdom.c index 6f9b96452e..bdddae6418 100644 --- a/ext/qtdom/qtdom.c +++ b/ext/qtdom/qtdom.c @@ -46,6 +46,7 @@ static int le_qtdom; */ function_entry qtdom_functions[] = { PHP_FE(qdom_tree, NULL) + PHP_FE(qdom_error, NULL) {NULL, NULL, NULL} /* Must be the last line in qtdom_functions[] */ }; @@ -83,6 +84,8 @@ PHP_MINIT_FUNCTION(qtdom) qdomdoc_class_entry_ptr = zend_register_internal_class(&qdomdoc_class_entry); qdomnode_class_entry_ptr = zend_register_internal_class(&qdomnode_class_entry); + qdom_init(); + return SUCCESS; } @@ -91,6 +94,8 @@ PHP_MSHUTDOWN_FUNCTION(qtdom) /* Remove comments if you have entries in php.ini UNREGISTER_INI_ENTRIES(); */ + qdom_shutdown(); + return SUCCESS; } @@ -222,7 +227,7 @@ int qdom_find_children( zval **children, struct qdom_node *orig_node ) return count; } -/* {{{ proto string qdom_tree( string ) +/* {{{ proto object qdom_tree( string ) creates a tree of an xml string */ PHP_FUNCTION(qdom_tree) { @@ -234,11 +239,14 @@ PHP_FUNCTION(qdom_tree) struct qdom_node *node; zval *children; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg) == FAILURE) { + if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &arg) == FAILURE) + { WRONG_PARAM_COUNT; } convert_to_string(arg); + qdom_do_install_message_handler(); + qdom_do_version( &qt_ver ); object_init_ex(return_value, qdomdoc_class_entry_ptr); @@ -259,6 +267,18 @@ PHP_FUNCTION(qdom_tree) } qdom_do_free( doc ); + qdom_do_free_message_handler(); +} +/* }}} */ + +/* {{{ proto string qdom_error() + Returns the error string from the last QDOM operation or FALSE if no errors occured.*/ +PHP_FUNCTION(qdom_error) +{ + char *error = qdom_error_log(); + if ( error == 0 ) + RETURN_FALSE; + RETURN_STRING( error, 1 ); } /* }}} */