]> granicus.if.org Git - php/commitdiff
New function qdom_error which returns the error text from the last qdom operation...
authorJan Borsodi <amos@php.net>
Thu, 4 Jan 2001 12:27:39 +0000 (12:27 +0000)
committerJan Borsodi <amos@php.net>
Thu, 4 Jan 2001 12:27:39 +0000 (12:27 +0000)
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.

ext/qtdom/qtdom.c

index 6f9b96452ecf376545af95cdd500577ba7b220e6..bdddae6418ba03b7498b4ada95472168a1777972 100644 (file)
@@ -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 );
 }
 /* }}} */