rrichards               Sun Oct 19 19:34:40 2003 EDT

  Modified files:              
    /php-src/ext/libxml libxml.c 
  Log:
  add generic default error handling rather than the default stderr
  
Index: php-src/ext/libxml/libxml.c
diff -u php-src/ext/libxml/libxml.c:1.3 php-src/ext/libxml/libxml.c:1.4
--- php-src/ext/libxml/libxml.c:1.3     Sun Oct 19 19:25:48 2003
+++ php-src/ext/libxml/libxml.c Sun Oct 19 19:34:39 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: libxml.c,v 1.3 2003/10/19 23:25:48 rrichards Exp $ */
+/* $Id: libxml.c,v 1.4 2003/10/19 23:34:39 rrichards Exp $ */
 
 #define IS_EXT_MODULE
 
@@ -146,6 +146,25 @@
        return php_stream_close((php_stream*)context);
 }
 
+static void php_libxml_error_handler(void *ctx, const char *msg, ...)
+{
+       va_list ap;
+       char *buf;
+       int len;
+
+       va_start(ap, msg);
+       len = vspprintf(&buf, 0, msg, ap);
+       va_end(ap);
+       
+       /* remove any trailing \n */
+       while (len && buf[--len] == '\n') {
+               buf[len] = '\0';
+       }
+
+       php_error(E_WARNING, "%s", buf);
+       efree(buf);
+}
+
 PHP_LIBXML_API void php_libxml_initialize() {
        if (!_php_libxml_initialized) {
                /* we should be the only one's to ever init!! */
@@ -167,12 +186,17 @@
                        php_libxml_streams_IO_write, 
                        php_libxml_streams_IO_close);
 
+               /* report errors via handler rather than stderr */
+               xmlSetGenericErrorFunc(NULL, php_libxml_error_handler);
+
                _php_libxml_initialized = 1;
        }
 }
 
 PHP_LIBXML_API void php_libxml_shutdown() {
        if (_php_libxml_initialized) {
+               /* reset libxml generic error handling */
+               xmlSetGenericErrorFunc(NULL, NULL);
                xmlCleanupParser();
                _php_libxml_initialized = 0;
        }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to