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/03/13 03:01:49 UTC

svn commit: r385405 - in /webservices/axis/trunk/c: include/axis/Axis.h src/cbindings/AxisC.cpp

Author: nadiramra
Date: Sun Mar 12 18:01:47 2006
New Revision: 385405

URL: http://svn.apache.org/viewcvs?rev=385405&view=rev
Log:
C support fixes/enhancements. Redefine typedef for exception handler.

Modified:
    webservices/axis/trunk/c/include/axis/Axis.h
    webservices/axis/trunk/c/src/cbindings/AxisC.cpp

Modified: webservices/axis/trunk/c/include/axis/Axis.h
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/include/axis/Axis.h?rev=385405&r1=385404&r2=385405&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/Axis.h (original)
+++ webservices/axis/trunk/c/include/axis/Axis.h Sun Mar 12 18:01:47 2006
@@ -81,12 +81,11 @@
   * 
   * @param fp - pointer to exception handler function.
   */
+  
+typedef void (* AXIS_EXCEPTION_HANDLER_FUNCT)(int errorCode, const char *errorString);
 
-// Create prototype for globalExceptionHandler.  This is to get round the
-// problems introduced by trace which cannot handle in-line prototyping.
-typedef void * AXISCALL GlobalExceptionHandlerPrototype( int errorCode, const char * errorString);
-
-AXISC_STORAGE_CLASS_INFO void axiscRegisterExceptionHandler( void * fp);
+AXISC_STORAGE_CLASS_INFO 
+void axiscRegisterExceptionHandler(AXIS_EXCEPTION_HANDLER_FUNCT);
 
 /**
   * Invokes the registered exception handler. If an exception handler was not

Modified: webservices/axis/trunk/c/src/cbindings/AxisC.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/cbindings/AxisC.cpp?rev=385405&r1=385404&r2=385405&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/AxisC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/AxisC.cpp Sun Mar 12 18:01:47 2006
@@ -16,101 +16,104 @@
  */
  
 #include <iostream>
+
 #include <axis/Axis.hpp>
 #include <axis/AxisException.hpp>
 
 AXIS_CPP_NAMESPACE_USE
 
 extern "C" {
-	#include <axis/GDefine.h>
-	#include <axis/AxisUserAPI.h>
-	#include <axis/TypeMapping.h>
-	#include <axis/Axis.h>
-
-// Create an object using the GlobalExceptionHandlerPrototype prototype.
-	static GlobalExceptionHandlerPrototype * global_exceptionHandler = NULL;
-
-	STORAGE_CLASS_INFO int axiscInitializeAxis( AxiscBool bIsServer) 
-	{
-		int rc = AXISC_SUCCESS;
-	    
-		try 
-		{
-			Axis::initialize( 0 == bIsServer);
-		}
-		catch( AxisException& e)
-		{
-			axiscInvokeExceptionHandler( e.getExceptionCode(), e.what());
-
-			rc = AXISC_FAIL;    
-		}
-		catch( ...)
-		{
-			rc = AXISC_FAIL;
-		}
-	    
-		return rc;
-	} 
-
-	STORAGE_CLASS_INFO int axiscTerminate() 
-	{
-		int rc = AXISC_SUCCESS;
-	    
-		try 
-		{
-			Axis::terminate();
-		}
-		catch( AxisException& e)
-		{
-			axiscInvokeExceptionHandler( e.getExceptionCode(), e.what());
-
-			rc = AXISC_FAIL;    
-		}
-		catch( ...)
-		{
-			rc = AXISC_FAIL;
-		}
-	    
-		return rc;
-	}
-
-	AXISC_STORAGE_CLASS_INFO int axiscAxisDelete( void * pValue, AXISC_XSDTYPE type)
-	{
-		int rc = AXISC_SUCCESS;
-	    
-		try 
-		{
-			Axis::AxisDelete(pValue, (XSDTYPE) type);
-		}
-		catch( AxisException& e)
-		{
-			axiscInvokeExceptionHandler( e.getExceptionCode(), e.what());
-
-			rc = AXISC_FAIL;    
-		}
-		catch( ...)
-		{
-			rc = AXISC_FAIL;
-		}    
-	    
-		return rc;
-	}
-
-	AXISC_STORAGE_CLASS_INFO void axiscRegisterExceptionHandler( void * fp)
-	{
-		global_exceptionHandler = (GlobalExceptionHandlerPrototype *) fp;
-	}
-
-	AXISC_STORAGE_CLASS_INFO void axiscInvokeExceptionHandler( int errorCode, const char * errorString)
-	{
-		if( global_exceptionHandler)
-		{
-			(global_exceptionHandler) (errorCode, errorString);
-// Try?			(*global_exceptionHandler) (errorCode, errorString);
-		}
-		else
-		{
-			cerr <<  "AXIS EXCEPTION: (" << errorCode << ") " << errorString << endl;
-		}
-	}
+#include <axis/GDefine.h>
+#include <axis/AxisUserAPI.h>
+#include <axis/TypeMapping.h>
+#include <axis/Axis.h>
+
+static void (*global_exceptionHandler)(int errorCode, const char *errorString) = NULL;
+
+STORAGE_CLASS_INFO 
+int axiscInitializeAxis(AxiscBool bIsServer) 
+{
+    int rc = AXISC_SUCCESS;
+    
+    try 
+    {
+        Axis::initialize(0==bIsServer);
+    }
+    catch ( AxisException& e  )
+    {
+        axiscInvokeExceptionHandler(e.getExceptionCode(), e.what());
+        rc = AXISC_FAIL;    
+    }
+    catch ( ... )
+    {
+        axiscInvokeExceptionHandler(-1, "Unrecognized exception thrown.");
+        rc = AXISC_FAIL;
+    }
+    
+    return rc;
+} 
+
+STORAGE_CLASS_INFO 
+int axiscTerminate() 
+{
+    int rc = AXISC_SUCCESS;
+    
+    try 
+    {
+        Axis::terminate();
+    }
+    catch ( AxisException& e  )
+    {
+        axiscInvokeExceptionHandler(e.getExceptionCode(), e.what());
+        rc = AXISC_FAIL;    
+    }
+    catch ( ... )
+    {
+        axiscInvokeExceptionHandler(-1, "Unrecognized exception thrown.");
+        rc = AXISC_FAIL;
+    }
+    
+    return rc;
+}
+
+AXISC_STORAGE_CLASS_INFO 
+int axiscAxisDelete(void * pValue,  
+                    AXISC_XSDTYPE type)
+{
+    int rc = AXISC_SUCCESS;
+    
+    try 
+    {
+        Axis::AxisDelete(pValue, (XSDTYPE) type);
+    }
+    catch ( AxisException& e  )
+    {
+        axiscInvokeExceptionHandler(e.getExceptionCode(), e.what());
+        rc = AXISC_FAIL;    
+    }
+    catch ( ... )
+    {
+        axiscInvokeExceptionHandler(-1, "Unrecognized exception thrown.");
+        rc = AXISC_FAIL;
+    }    
+    
+    return rc;
+}
+
+AXISC_STORAGE_CLASS_INFO 
+void axiscRegisterExceptionHandler( AXIS_EXCEPTION_HANDLER_FUNCT fp )
+{
+    global_exceptionHandler = fp;
+}
+
+
+AXISC_STORAGE_CLASS_INFO 
+void axiscInvokeExceptionHandler(int errorCode, const char *errorString)
+{
+    if (global_exceptionHandler)
+        global_exceptionHandler(errorCode, errorString);
+    else
+        cerr <<  "AXIS EXCEPTION: (" << errorCode << ") " << errorString << endl;
+}
+
 }