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 da...@apache.org on 2005/10/31 12:14:53 UTC

svn commit: r329796 - in /webservices/axis2/trunk/c: include/ modules/util/src/

Author: damitha
Date: Mon Oct 31 03:14:30 2005
New Revision: 329796

URL: http://svn.apache.org/viewcvs?rev=329796&view=rev
Log:
modules/util/src now builds with new changes

Removed:
    webservices/axis2/trunk/c/modules/util/src/axis2_allocator_default.h
Modified:
    webservices/axis2/trunk/c/include/axis2_allocator.h
    webservices/axis2/trunk/c/include/axis2_environment.h
    webservices/axis2/trunk/c/include/axis2_error.h
    webservices/axis2/trunk/c/include/axis2_log.h
    webservices/axis2/trunk/c/include/axis2_stream.h
    webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c
    webservices/axis2/trunk/c/modules/util/src/axis2_environment.c
    webservices/axis2/trunk/c/modules/util/src/axis2_error.c
    webservices/axis2/trunk/c/modules/util/src/axis2_log.c
    webservices/axis2/trunk/c/modules/util/src/axis2_log_default.h
    webservices/axis2/trunk/c/modules/util/src/axis2_stream.c
    webservices/axis2/trunk/c/modules/util/src/axis2_stream_default.h

Modified: webservices/axis2/trunk/c/include/axis2_allocator.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_allocator.h?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_allocator.h (original)
+++ webservices/axis2/trunk/c/include/axis2_allocator.h Mon Oct 31 03:14:30 2005
@@ -44,24 +44,26 @@
   */
    AXIS2_DECLARE_DATA typedef struct axis2_allocator
     {
+    
+
       /**
         * allocates memory
         * @param size size of the memory block to be allocated
         * @return pointer to the allocated memory block
         */
-         void * (*axis2_allocator_malloc) (size_t size);
+         void * (*malloc) (size_t size);
       /**
         * re-llocates memory
         * @param ptr memory block who's size to be changed
         * @param size size of the memory block to be allocated
         * @return pointer to the allocated memory block
         */
-         void * (*axis2_allocator_realloc) (void *ptr, size_t size);
+         void * (*realloc) (void *ptr, size_t size);
       /**
         * frees memory
         * @param ptr pointer to be freed
         */
-         void (*axis2_allocator_free) (void *ptr);
+         void (*free) (void *ptr);
     } axis2_allocator_t;
 
   /**
@@ -71,9 +73,9 @@
     */
     /*AXIS2_DECLARE(axis2_allocator_t *) axis2_allocator_init (axis2_allocator_t * allocator);*/
 
-#define axis2_malloc(allocator, size) ((allocator)->axis2_allocator_malloc(size))
-#define axis2_realloc(allocator, ptr, size) ((allocator)->axis2_allocator_realloc(ptr, size))
-#define axis2_free(allocator, ptr) ((allocator)->axis2_allocator_free(ptr))
+#define AXIS2_MALLOC(allocator, size) ((allocator)->malloc(size))
+#define AXIS2_REALLOC(allocator, ptr, size) ((allocator)->realloc(ptr, size))
+#define AXIS2_FREE(allocator, ptr) ((allocator)->free(ptr))
 
 /** @} */
     

Modified: webservices/axis2/trunk/c/include/axis2_environment.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_environment.h?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_environment.h (original)
+++ webservices/axis2/trunk/c/include/axis2_environment.h Mon Oct 31 03:14:30 2005
@@ -80,6 +80,17 @@
                                                    axis2_stream_t * stream,
                                                    axis2_log_t * log);
 
+  /**
+    * Creates an environment struct
+    * @param allocator pointer to an instance of allocator struct. Mandatory, cannot be NULL
+    * @param error pointer to an instance of error struct. Optional, can be NULL. If NULL default error handler would be used.
+    * @param stream pointer to an instance of stream struct. Optional, can be NULL. If NULL default stream handler would be used.
+    * @param log pointer to an instance of log struct. Optional, can be NULL. If NULL default log handler would be used.
+    * @param string pointer to an instance of string struct. Optional, can be NULL. If NULL default string handler would be used.
+    * @return pointer to the newly created environment struct 
+    */
+    AXIS2_DECLARE(axis2_status_t) axis2_environment_free (axis2_environment_t *env);
+
 /** @} */
 
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/include/axis2_error.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_error.h?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_error.h (original)
+++ webservices/axis2/trunk/c/include/axis2_error.h Mon Oct 31 03:14:30 2005
@@ -41,11 +41,19 @@
     */
    AXIS2_DECLARE_DATA typedef struct axis2_error_ops
     {
+
+      /**
+        * deallocate memory of a error struct
+        * @return axis2_status_t status code
+        */
+
+        axis2_status_t (AXIS2_CALL *free)(struct axis2_error *error);
+        
       /**
         * get error message for the last error
         * @return error message for the last error. NULL on error.
         */
-         axis2_char_t * (AXIS2_CALL *axis2_error_ops_get_message) (int error_number);
+         axis2_char_t * (AXIS2_CALL *get_message) (int error_number);
     } axis2_error_ops_t;
 
   /** 
@@ -61,14 +69,9 @@
         int error_number;
     } axis2_error_t;
 
-  /**
-    * Creates an error struct
-    * @param allocator allocator to be used. Mandatory, cannot be NULL    
-    * @return pointer to the newly created error struct 
-    */
-    AXIS2_DECLARE(axis2_error_t *) axis2_error_create (axis2_allocator_t * allocator);
 
-#define axis2_error_get_message(error) ((error)->ops->axis2_error_ops_get_message())
+#define AXIS2_ERROR_FREE(error) ((error->ops)->free(error))
+#define AXIS2_ERROR_GET_MESSAGE(error) ((error)->ops->axis2_error_ops_get_message())
 
   /** 
     * \brief Axis2 status codes

Modified: webservices/axis2/trunk/c/include/axis2_log.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_log.h?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_log.h (original)
+++ webservices/axis2/trunk/c/include/axis2_log.h Mon Oct 31 03:14:30 2005
@@ -57,6 +57,14 @@
     */
     typedef struct axis2_log_ops
     {
+    
+      /**
+       * deletes the log
+       * @return axis2_status_t AXIS2_SUCCESS on success else AXIS2_FAILURE
+       */
+
+       axis2_status_t (AXIS2_CALL *free) (struct axis2_log *log);
+
       /**
         * writes to the log
         * @param buffer buffer to be written to log
@@ -89,7 +97,8 @@
    /* AXIS2_DECLARE(axis2_log_t *) axis2_log_create (axis2_allocator_t * allocator,
                                    axis2_log_ops_t * operations);*/
 
-#define axis2_log_write(log, buffer, count) ((log)->ops->axis2_log_ops_write(buffer, count))
+#define AXIS2_LOG_FREE(log) ((log->ops)->free(log))
+#define AXIS22_LOG_WRITE(log, buffer, count) ((log)->ops->axis2_log_ops_write(buffer, count))
 
 /** @} */
     

Modified: webservices/axis2/trunk/c/include/axis2_stream.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_stream.h?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_stream.h (original)
+++ webservices/axis2/trunk/c/include/axis2_stream.h Mon Oct 31 03:14:30 2005
@@ -40,6 +40,14 @@
     */
   AXIS2_DECLARE_DATA  typedef struct axis2_stream_ops
     {
+
+      /**
+       * deletes the stream
+       * @return axis2_status_t AXIS2_SUCCESS on success else AXIS2_FAILURE
+       */
+
+       axis2_status_t (AXIS2_CALL *free) (struct axis2_stream *stream);
+       
       /**
         * reads from stream
         * @param buffer buffer into which the content is to be read
@@ -104,26 +112,19 @@
 		int axis2_eof;
     } axis2_stream_t;
 
-  /**
-    * Creates a stream struct
-    * @param allocator allocator to be used. Mandatory, cannot be NULL
-    * @param operations operations struct. Optional, can be NULL. If null default operations would be assigned.
-    * @return pointer to the newly created log struct 
-    */
-/*    AXIS2_DECLARE(axis2_stream_t *) axis2_stream_create (axis2_allocator_t * allocator,
-                                         axis2_stream_t * stream);*/
+#define AXIS2_STREAM_FREE(stream) ((stream->ops)->free(stream))
 
-#define axis2_stream_read(stream, buffer, count) \
+#define AXIS2_STREAM_READ(stream, buffer, count) \
 		((stream)->ops->axis2_stream_ops_read(buffer, count))
-#define axis2_stream_write(stream, buffer, count) \
+#define AXIS2_STREAM_WRITE(stream, buffer, count) \
 		((stream)->ops->axis2_stream_ops_write(buffer, count))
-#define axis2_stream_file_open(stream, file_name, options) \
+#define AXIS2_STREAM_FILE_OPEN(stream, file_name, options) \
 		((stream)->ops->axis2_stream_ops_file_open(file_name, options))
-#define axis2_stream_file_close(stream, file_ptr) \
+#define AXIS2_STREAM_FILE_CLOSE(stream, file_ptr) \
 		((stream)->ops->axis2_stream_ops_file_close(file_ptr))
-#define axis2_stream_file_get_char(stream, file_ptr) \
+#define AXIS2_STREAM_FILE_GET_CHAR(stream, file_ptr) \
 		((stream)->ops->axis2_stream_ops_file_get_char(file_ptr))
-#define axis2_stream_file_unget_char(stream, chr, file_ptr) \
+#define AXIS2_STREAM_FILE_UNGET_CHAR(stream, chr, file_ptr) \
 		((stream)->ops->axis2_stream_ops_file_unget_char(chr, file_ptr))	
 
 /** @} */

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c Mon Oct 31 03:14:30 2005
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <axis2_allocator_default.h>
+#include <axis2_allocator.h>
 #include <stdlib.h>
 
 AXIS2_DECLARE(axis2_allocator_t *)
@@ -28,9 +28,9 @@
         allocator = (axis2_allocator_t *) malloc (sizeof (axis2_allocator_t));
         if (allocator)
         {
-            allocator->axis2_allocator_malloc = malloc;
-            allocator->axis2_allocator_realloc = realloc;
-            allocator->axis2_allocator_free = free;
+            allocator->malloc = malloc;
+            allocator->realloc = realloc;
+            allocator->free = free;
             return allocator;
         }
     }

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_environment.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_environment.c?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_environment.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_environment.c Mon Oct 31 03:14:30 2005
@@ -16,6 +16,32 @@
 
 #include <axis2_environment.h>
 
+#include <axis2_error_default.h>
+#include <axis2_stream_default.h>
+#include <axis2_log_default.h>
+
+
+AXIS2_DECLARE(axis2_status_t )
+axis2_environment_free (axis2_environment_t *env)
+{
+    if(NULL != env && NULL != env->allocator)
+        free (env->allocator);
+
+    if(NULL != env && NULL != env->stream)
+		AXIS2_STREAM_FREE(env->stream);
+
+    if(NULL != env && NULL != env->log)
+        AXIS2_LOG_FREE(env->log);
+	
+	if(NULL != env && NULL != env->error)
+        AXIS2_ERROR_FREE(env->error);
+    
+    if(NULL != env)
+        free (env);
+	
+	return 0;  
+}
+
 AXIS2_DECLARE(axis2_environment_t *)
 axis2_environment_create (axis2_allocator_t * allocator,
                           axis2_error_t * error, axis2_stream_t * stream,
@@ -26,7 +52,7 @@
         return NULL;
 
     environment =
-        (axis2_environment_t *) axis2_malloc (allocator,
+        (axis2_environment_t *) AXIS2_MALLOC (allocator,
                                               sizeof (axis2_environment_t));
 
     if (!environment)

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_error.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_error.c?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_error.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_error.c Mon Oct 31 03:14:30 2005
@@ -14,9 +14,24 @@
  * limitations under the License.
  */
 
-#include <axis2_error.h>
+#include <stdlib.h>
+#include "axis2_error_default.h"
 
-axis2_char_t * AXIS2_CALL axis2_error_impl_get_message ();
+axis2_char_t * AXIS2_CALL axis2_error_impl_get_message (int error_number);
+
+axis2_status_t AXIS2_CALL
+axis2_error_impl_free (axis2_error_t *error)
+{
+    if (NULL != error && NULL != error->ops)
+    {
+        free (error->ops);
+    }
+    if (NULL != error)
+    {
+        free (error); 
+    }
+    return AXIS2_SUCCESS;
+}
 
 AXIS2_DECLARE(axis2_error_t*)
 axis2_error_create (axis2_allocator_t * allocator)
@@ -26,28 +41,28 @@
         return NULL;
 
     error =
-        (axis2_error_t *) axis2_malloc (allocator, sizeof (axis2_error_t));
+        (axis2_error_t *) AXIS2_MALLOC (allocator, sizeof (axis2_error_t));
 
     if (!error)
         return NULL;
 
     error->ops =
-        (axis2_error_ops_t *) axis2_malloc (allocator,
+        (axis2_error_ops_t *) AXIS2_MALLOC (allocator,
                                             sizeof (axis2_error_ops_t));
 
     if (!error->ops)
     {
-        axis2_free (allocator, error);
+        AXIS2_FREE (allocator, error);
         return NULL;
     }
 
-    error->ops->axis2_error_ops_get_message = axis2_error_impl_get_message;
+    error->ops->get_message = axis2_error_impl_get_message;
 
     return error;
 }
 
 axis2_char_t * AXIS2_CALL
-axis2_error_impl_get_message ()
+axis2_error_impl_get_message (int error_number)
 {
     /** TODO: Need to fill in the error message list and get the error from that list */
     return "This is the default error code";

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_log.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_log.c?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_log.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_log.c Mon Oct 31 03:14:30 2005
@@ -17,6 +17,20 @@
 #include <axis2_log_default.h>
 #include <stdio.h>
 
+axis2_status_t AXIS2_CALL
+axis2_log_impl_free (axis2_log_t *log)
+{
+    if (NULL != log && NULL != log->ops)
+    {
+        free (log->ops);
+    }
+    if (NULL != log)
+    {
+        free (log); 
+    }
+    return 0;
+}
+
 axis2_status_t AXIS2_CALL axis2_log_impl_write (const void *buffer, size_t count);
 
 AXIS2_DECLARE(axis2_log_t *)
@@ -26,7 +40,7 @@
     if (!allocator)
         return NULL;
 
-    log = (axis2_log_t *) axis2_malloc (allocator, sizeof (axis2_log_t));
+    log = (axis2_log_t *) AXIS2_MALLOC (allocator, sizeof (axis2_log_t));
 
     if (!log)
         return NULL;
@@ -36,12 +50,12 @@
     else
     {
         log->ops =
-            (axis2_log_ops_t *) axis2_malloc (allocator,
+            (axis2_log_ops_t *) AXIS2_MALLOC (allocator,
                                               sizeof (axis2_log_ops_t));
 
         if (!log->ops)
         {
-            axis2_free (allocator, log);
+            AXIS2_FREE (allocator, log);
             return NULL;
         }
 

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_log_default.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_log_default.h?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_log_default.h (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_log_default.h Mon Oct 31 03:14:30 2005
@@ -18,8 +18,9 @@
 #define AXIS2_LOG_DEFAULT_H
 
 #include <axis2_log.h>
+#include <axis2_allocator.h>
 
-#include "axis2_allocator_default.h"
+#include <stdlib.h>
 
 #ifdef __cplusplus
 extern "C"

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_stream.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_stream.c?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_stream.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_stream.c Mon Oct 31 03:14:30 2005
@@ -20,7 +20,10 @@
 
 #include <axis2_stream_default.h>
 
+axis2_status_t AXIS2_CALL axis2_stream_impl_free ();
+
 axis2_status_t AXIS2_CALL axis2_stream_impl_write (const void *buffer, size_t count);
+
 axis2_status_t AXIS2_CALL axis2_stream_impl_read (void *buffer, size_t count);
 
 void* AXIS2_CALL axis2_stream_impl_file_open(const char *file_name, const char *options);
@@ -39,6 +42,8 @@
 	{
 		if(stream->ops)
 		{
+            if(!stream->ops->free)
+                (stream->ops)->free = axis2_stream_impl_free;
 			if(!stream->ops->axis2_stream_ops_read)
 				stream->ops->axis2_stream_ops_read = axis2_stream_impl_read;
 			if(!stream->ops->axis2_stream_ops_write)
@@ -57,15 +62,17 @@
 		else if (allocator)
 		{
 			stream->ops =
-            (axis2_stream_ops_t *) axis2_malloc (allocator,
+            (axis2_stream_ops_t *) AXIS2_MALLOC (allocator,
                                                  sizeof (axis2_stream_ops_t));
 
 			if (!stream->ops)
 			{
-				axis2_free (allocator, stream->ops);
+				AXIS2_FREE (allocator, stream->ops);
 				return NULL;
 			}
-
+            
+            if(!stream->ops->free)
+                (stream->ops)->free = axis2_stream_impl_free;
 			stream->ops->axis2_stream_ops_read = axis2_stream_impl_read;
 			stream->ops->axis2_stream_ops_write = axis2_stream_impl_write;
 			stream->ops->axis2_stream_ops_file_open = axis2_stream_impl_file_open;
@@ -86,17 +93,17 @@
 	else if(allocator)
 	{
 		stream =
-        (axis2_stream_t *) axis2_malloc (allocator, sizeof (axis2_stream_t));
+        (axis2_stream_t *) AXIS2_MALLOC (allocator, sizeof (axis2_stream_t));
 
 		if (!stream)
 			return NULL;
 		stream->ops =
-            (axis2_stream_ops_t *) axis2_malloc (allocator,
+            (axis2_stream_ops_t *) AXIS2_MALLOC (allocator,
                                                  sizeof (axis2_stream_ops_t));
 
         if (!stream->ops)
         {
-            axis2_free (allocator, stream);
+            AXIS2_FREE (allocator, stream);
             return NULL;
         }
 		stream->ops->axis2_stream_ops_read = axis2_stream_impl_read;
@@ -113,6 +120,20 @@
 	}
 	
     return NULL;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_stream_impl_free (axis2_stream_t *stream)
+{
+    if (NULL != stream && NULL != stream->ops)
+    {
+        free (stream->ops);
+    }
+    if (NULL != stream)
+    {
+        free (stream); 
+    }
+    return 0;
 }
 
 axis2_status_t AXIS2_CALL

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_stream_default.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_stream_default.h?rev=329796&r1=329795&r2=329796&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_stream_default.h (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_stream_default.h Mon Oct 31 03:14:30 2005
@@ -18,7 +18,10 @@
 #define AXIS2_STREAM_DEFAULT_H
 
 #include <axis2_stream.h>
-#include "axis2_allocator_default.h"
+#include <axis2_allocator.h>
+#include <axis2_defines.h>
+
+#include <string.h>
 
 #ifdef __cplusplus
 extern "C"