You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2006/01/26 08:16:05 UTC

svn commit: r372469 - /webservices/axis2/trunk/c/modules/xml/parser/libxml2/axis2_libxml2_reader_wrapper.c

Author: nandika
Date: Wed Jan 25 23:15:58 2006
New Revision: 372469

URL: http://svn.apache.org/viewcvs?rev=372469&view=rev
Log:
 error handler added 

Modified:
    webservices/axis2/trunk/c/modules/xml/parser/libxml2/axis2_libxml2_reader_wrapper.c

Modified: webservices/axis2/trunk/c/modules/xml/parser/libxml2/axis2_libxml2_reader_wrapper.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/parser/libxml2/axis2_libxml2_reader_wrapper.c?rev=372469&r1=372468&r2=372469&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/parser/libxml2/axis2_libxml2_reader_wrapper.c (original)
+++ webservices/axis2/trunk/c/modules/xml/parser/libxml2/axis2_libxml2_reader_wrapper.c Wed Jan 25 23:15:58 2006
@@ -105,7 +105,18 @@
 axis2_status_t axis2_libxml2_reader_wrapper_fill_maps(axis2_xml_reader_t *parser,
                                             axis2_env_t **env);
                                             
-static int axis2_libxml2_reader_wrapper_read_input_callback(void *ctx,char *buffer,int size);                                            
+void 
+axis2_libxml2_reader_wrapper_error_handler(void *arg, 
+                                           char *msg, 
+                                           int severities, 
+                                           void *locator_ptr);                                            
+                                            
+static int 
+axis2_libxml2_reader_wrapper_read_input_callback(void *ctx,
+                                                 char *buffer,
+                                                 int size);                                           
+                                                 
+
                                    
 /************* End function parameters , axis2_libxml2_reader_wrapper_impl_t struct ***/
 
@@ -129,8 +140,7 @@
     /* read callback function */
     int (*read_input_callback)(char *buffer, int size,void* ctx);
     
-    
-}axis2_libxml2_reader_wrapper_impl_t;
+} axis2_libxml2_reader_wrapper_impl_t;
 
 /****************** End struct , Macro *****************************************/
 
@@ -140,8 +150,8 @@
 
 /********************* End Macro  , event_map init function **********************/
 
-static axis2_status_t axis2_libxml2_reader_wrapper_init_map(
-                                      axis2_libxml2_reader_wrapper_impl_t *parser)
+static axis2_status_t 
+axis2_libxml2_reader_wrapper_init_map(axis2_libxml2_reader_wrapper_impl_t *parser)
 {   
     int i=0;
     if(parser)
@@ -217,8 +227,9 @@
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_CREATING_XML_STREAM_READER, AXIS2_FAILURE);
         return NULL;
     }
-	
-    
+
+    xmlTextReaderSetErrorHandler(wrapper_impl->reader, 
+        axis2_libxml2_reader_wrapper_error_handler, (*env));
     wrapper_impl->current_event = -1;
     
     axis2_libxml2_reader_wrapper_init_map(wrapper_impl);
@@ -313,8 +324,9 @@
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_CREATING_XML_STREAM_READER, AXIS2_FAILURE);
         return NULL;
     }
-	
-    
+
+    xmlTextReaderSetErrorHandler(wrapper_impl->reader, axis2_libxml2_reader_wrapper_error_handler, (*env));
+
     wrapper_impl->current_event = -1;
     
     axis2_libxml2_reader_wrapper_init_map(wrapper_impl);
@@ -333,7 +345,7 @@
     }
 
 	
-		wrapper_impl->parser.ops->free = axis2_libxml2_reader_wrapper_free;
+	wrapper_impl->parser.ops->free = axis2_libxml2_reader_wrapper_free;
     wrapper_impl->parser.ops->next = axis2_libxml2_reader_wrapper_next;
     wrapper_impl->parser.ops->xml_free = axis2_libxml2_reader_wrapper_xml_free;
     
@@ -428,9 +440,12 @@
                            axis2_env_t **env)
 {
     AXIS2_FUNC_PARAM_CHECK(parser,env, AXIS2_FAILURE);
-    
     if(AXIS2_INTF_TO_IMPL(parser)->reader)
+    {
+        xmlTextReaderClose(AXIS2_INTF_TO_IMPL(parser)->reader);
         xmlFreeTextReader(AXIS2_INTF_TO_IMPL(parser)->reader);
+        xmlCleanupParser();
+    }
     if(parser->ops)
         AXIS2_FREE((*env)->allocator, parser->ops);
     AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(parser));
@@ -763,4 +778,14 @@
 {
  return  ((axis2_libxml2_reader_wrapper_impl_t*)ctx)->read_input_callback(
         buffer, size,((axis2_libxml2_reader_wrapper_impl_t*)ctx)->ctx);
+}
+
+void
+axis2_libxml2_reader_wrapper_error_handler(void *arg,
+                                           char *msg,
+                                           int severities,
+                                           void *locator_ptr)
+{
+    printf("%s", msg);
+    
 }