axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r312851 - in /webservices/axis2/trunk/c: include/ modules/common/src/ modules/xml/om/src/
Date Tue, 11 Oct 2005 09:52:08 GMT
Author: samisa
Date: Tue Oct 11 02:51:49 2005
New Revision: 312851

URL: http://svn.apache.org/viewcvs?rev=312851&view=rev
Log:
Used the new environment stuff in OM text

Modified:
    webservices/axis2/trunk/c/include/axis2_allocator.h
    webservices/axis2/trunk/c/include/axis2_defines.h
    webservices/axis2/trunk/c/include/axis2_errno.h
    webservices/axis2/trunk/c/include/axis2_error.h
    webservices/axis2/trunk/c/include/axis2_log.h
    webservices/axis2/trunk/c/include/axis2_om_node.h
    webservices/axis2/trunk/c/include/axis2_om_text.h
    webservices/axis2/trunk/c/modules/common/src/axis2_allocator.c
    webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_text.c

Modified: webservices/axis2/trunk/c/include/axis2_allocator.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_allocator.h?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_allocator.h (original)
+++ webservices/axis2/trunk/c/include/axis2_allocator.h Tue Oct 11 02:51:49 2005
@@ -17,7 +17,6 @@
 #ifndef AXIS2_MEMORY_ALLOCATOR_H
 #define AXIS2_MEMORY_ALLOCATOR_H
 
-#include <stdlib.h>
 #include <axis2_defines.h>
 
 typedef struct 
@@ -25,6 +24,7 @@
     void *(*malloc)(size_t size);
     void *(*realloc)(void *ptr,size_t size);
     void (*free)(void *ptr);
+    void* (*strdup)(const void *ptr);
 }axis2_allocator_t;
 
 /**
@@ -40,5 +40,6 @@
 #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))
+#define axis2_strdup(allocator, ptr) ((allocator)->strdup(ptr))
 
 #endif /* AXIS2_MEMORY_ALLOCATOR_H */

Modified: webservices/axis2/trunk/c/include/axis2_defines.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_defines.h?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_defines.h (original)
+++ webservices/axis2/trunk/c/include/axis2_defines.h Tue Oct 11 02:51:49 2005
@@ -2,10 +2,14 @@
 #define AXIS2_H
 
 /**
- * @file axis2.h
- * @brief Axis2c specific global declarations
+ * @file axis2_defines.h
+ * @brief Useful definitions, which may have platform concerns
  */
+ 
+#include <stddef.h>
 
 typedef char axis2_char;
+#define AXIS2_TRUE 1
+#define AXIS2_FALSE 0
 
 #endif /* AXIS2_H */

Modified: webservices/axis2/trunk/c/include/axis2_errno.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_errno.h?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_errno.h (original)
+++ webservices/axis2/trunk/c/include/axis2_errno.h Tue Oct 11 02:51:49 2005
@@ -6,14 +6,14 @@
  * @brief Axis2c Error Codes
  */
 
-#include <apr_errno.h>
+//#include <apr_errno.h>
 
 /**
  * AXIS2_START_ERROR is where the AXIS2 specific error values start.
  * In apr_errno.h APR_OS_START_USERERR is defined as start of the 
  * error codes for applications using apr.
  */
-#define AXIS2_START_ERROR    APR_OS_START_USERERR
+#define AXIS2_START_ERROR    20000
 
 #define AXIS2_ERROR_SPACE    50000
 
@@ -54,7 +54,7 @@
  */
 
 #define AXIS2_SUCCESS        (AXIS2_START_STATUS + 1)
-#define AXIS2_FAILURE       (APR_OS_START_STATUS + 2)
+#define AXIS2_FAILURE       (AXIS2_START_STATUS + 2)
 
 
 /** @} */

Modified: webservices/axis2/trunk/c/include/axis2_error.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_error.h?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_error.h (original)
+++ webservices/axis2/trunk/c/include/axis2_error.h Tue Oct 11 02:51:49 2005
@@ -42,7 +42,8 @@
 
 typedef enum axis2_error_codes {
     AXIS2_ERROR_NONE = 0,
-    AXIS2_ERROR_NO_MEMORY
+    AXIS2_ERROR_NO_MEMORY,
+    AXIS2_ERROR_INVALID_NULL_PARAMETER
 } axis2_error_codes_t;
 
 

Modified: webservices/axis2/trunk/c/include/axis2_log.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_log.h?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_log.h (original)
+++ webservices/axis2/trunk/c/include/axis2_log.h Tue Oct 11 02:51:49 2005
@@ -31,17 +31,20 @@
 struct axis2_log;
 struct axis2_log_ops;
 
-typedef struct axis2_log_ops {
-    int (*write)(const void *buffer, size_t count);
+typedef struct axis2_log_ops
+{
+    int (*write) (const void *buffer, size_t count);
 } axis2_log_ops_t;
 
-typedef struct axis2_log {
+typedef struct axis2_log
+{
     struct axis2_log_ops *ops;
     axis2_log_levels_t level;
-    int enabled; /*boolean*/
+    int enabled;                /*boolean */
 } axis2_log_t;
 
-axis2_log_t *axis2_log_create(axis2_allocator_t* allocator, axis2_log_ops_t* operations);
+axis2_log_t *axis2_log_create (axis2_allocator_t * allocator,
+                               axis2_log_ops_t * operations);
 
 #define axis2_log_write(log, buffer, count) ((log)->ops->write(buffer, count))
 

Modified: webservices/axis2/trunk/c/include/axis2_om_node.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_om_node.h?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_node.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_node.h Tue Oct 11 02:51:49 2005
@@ -26,9 +26,9 @@
 
 #include <axis2.h>
 #include <axis2_errno.h>
-#include <apr.h>
-#include <apr_pools.h>
-#include <xmlpullparser.h>
+//#include <apr.h>
+//#include <apr_pools.h>
+
 
 typedef struct axis2_stax_om_builder_s axis2_stax_om_builder_t;
 typedef struct axis2_om_output_s axis2_om_output_t;

Modified: webservices/axis2/trunk/c/include/axis2_om_text.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_om_text.h?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_text.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_text.h Tue Oct 11 02:51:49 2005
@@ -19,59 +19,80 @@
 
 /**
  * @file axis2_om_attribute.h
- * @brief  represents xml text element
+ * @brief Represents XML text element
  */
 
+#include <axis2_environment.h>
+#include <axis2_om_node.h>
 
-#include <axis2_om_attribute.h>
-
-typedef struct axis2_om_text_t
+struct axis2_om_text;
+struct axis2_om_text_ops;
+    
+/** \struct axis2_om_text_ops_t
+    \brief OM Text operations struct
+
+    Encapsulator struct for operations of axis2_om_text_t
+*/
+typedef struct axis2_om_text_ops
 {
-	char *value;
-    // The following fields are for MTOM
-	axis2_om_namespace_t *ns;
-
+  /**
+    * Free an axis2_om_text_t structure
+    * @return Status code
+    */
+    int (*free)(axis2_environment_t *environment, struct axis2_om_text *om_text);
+    
+  /**
+    * Serialize operation
+    * @param om_output OM output handler to be used in serializing
+    * @return Status code
+    */
+    int (*serialize)(axis2_environment_t *environment, const struct axis2_om_text *om_text,
axis2_om_output_t* om_output);
+} axis2_om_text_ops_t;
+    
+/** \struct axis2_om_text_t
+    \brief OM Text struct
+
+    Handles the XML text in OM
+*/
+typedef struct axis2_om_text
+{
+  /**
+    * OM text related operations
+    */
+    axis2_om_text_ops_t* ops;
+    
+   /**
+	* Text value
+	*/	
+	char *value; 
+	
+   /**
+    * The following fields are for MTOM
+    */
+	//axis2_om_namespace_t *ns;
 	char *mime_type;
 	int optimize;
 	char *localname;
 	int is_binary;
 	char *content_id;
-	axis2_om_attribute_t *attribute;
-}axis2_om_text_t;
-
-
-/**
- * Create a text struct and stores in in a node struct and returns a pointer
- * to the axis2_om_text_t struct
- * the data_element field of node struct points to the acctual axis2_text_t struct
- * The element type of axis2_om_node_t struct will be of type AXIS2_OM_TEXT
- * @param parent This can be null The parent element should be of type AXIS2_OM_ELEMENT
- * @return pointer to a axis2_om_text_t struct 
- */
-
-axis2_om_text_t *axis2_om_text_create(axis2_om_node_t *parent,const char *value
-						,axis2_om_node_t *node);
+	//axis2_om_attribute_t *attribute;
+} axis2_om_text_t;
 
 
 /**
- * access the value of the text struct
- * @param textnode node
- * @return char * to the value
+ * Create a text struct and stores it in a node struct and returns a pointer
+ * to the newly created text struct
+ * @param parent Parent of the new node. If null newly created node becomes a root node
+ *          The parent element must be of type AXIS2_OM_ELEMENT
+ * @param value Text value 
+ * @param node Out parameter to store the newly created node
+ * @return pointer to newly created text struct 
  */
-char* axis2_om_text_get_text(axis2_om_text_t *textnode);
-
-/**
- *	free an axis2_om_text_t structure
- */
-
-void axis2_om_text_free(axis2_om_text_t *text);
-/**
- *	axis2
- *
- */
-
 
-int axis2_om_text_serialize(axis2_om_text_t *om_text, axis2_om_output_t* om_output);
+axis2_om_text_t *axis2_om_text_create(axis2_environment_t *environment, axis2_om_node_t *parent,const
char *value
+						,axis2_om_node_t **node);
 
+#define axis2_om_text_serialize(environment, om_text, om_output) ((om_text)->ops->serialize(environment,
om_text, om_output))
+#define axis2_om_text_free(environment, om_text) ((om_text)->ops->free(environment,
om_text))
 
-#endif // AXIS2_OM_TEXT_H
+#endif /* AXIS2_OM_TEXT_H */

Modified: webservices/axis2/trunk/c/modules/common/src/axis2_allocator.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/common/src/axis2_allocator.c?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/common/src/axis2_allocator.c (original)
+++ webservices/axis2/trunk/c/modules/common/src/axis2_allocator.c Tue Oct 11 02:51:49 2005
@@ -15,6 +15,16 @@
  */
 
 #include <axis2_allocator.h>
+#include <stdlib.h>
+#include <string.h>
+
+void* axis2_allocator_strdup(void* ptr)
+{
+    if (ptr)
+        return strdup(ptr);
+    else
+        return NULL;
+}
 
 axis2_allocator_t *axis2_allocator_init(
                 axis2_allocator_t *allocator)
@@ -30,7 +40,7 @@
             allocator->malloc = malloc;
             allocator->realloc = realloc;
             allocator->free = free;
-            
+            allocator->strdup = axis2_allocator_strdup;
             return allocator;
         }
      }

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_text.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_text.c?rev=312851&r1=312850&r2=312851&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_text.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_text.c Tue Oct 11 02:51:49 2005
@@ -15,64 +15,102 @@
  */
 
 #include <axis2_om_text.h>
-#include <string.h>
+/*#include <string.h>
 #include <axis2_om_node.h>
 #include <axis2_errno.h>
+*/
 
-axis2_om_text_t *axis2_om_text_create(axis2_om_node_t *parent,const char *value
-						,axis2_om_node_t *text_node)
+/* operations */
+int axis2_om_text_ops_free(axis2_environment_t *environment, axis2_om_text_t *om_text);
+int axis2_om_text_ops_serialize(axis2_environment_t *environment, const axis2_om_text_t *om_text,
axis2_om_output_t* om_output);
+
+axis2_om_text_t *axis2_om_text_create(axis2_environment_t *environment, axis2_om_node_t *parent,const
char *value
+						,axis2_om_node_t **node)
 {
-    axis2_om_text_t *text;
-    axis2_om_node_t *node = axis2_om_node_create();
+    axis2_om_text_t *om_text = NULL;
+    
     if (!node)
     {
-		fprintf(stderr,"%d Error",AXIS2_ERROR_OM_MEMORY_ALLOCATION);
+        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAMETER;
+        return NULL;
+    }
+    
+    *node = axis2_om_node_create();
+    
+    if (!(*node))
+    {
+        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;        
 		return NULL;
     }
-    text = (axis2_om_text_t *) malloc(sizeof(axis2_om_text_t));
-    if (!text)
+    
+    om_text = (axis2_om_text_t*) axis2_malloc(environment->allocator, sizeof(axis2_om_text_t));
+    
+    if (!om_text)
     {
-		fprintf(stderr,"%d Error",AXIS2_ERROR_OM_MEMORY_ALLOCATION);
+        axis2_free(environment->allocator, *node);
+		environment->error->errorno = AXIS2_ERROR_NO_MEMORY;        
 		return NULL;
     }
-    text->value = strdup(value);
-    text->attribute = NULL;
-    text->content_id = NULL;
-    text->mime_type = NULL;
-    node->data_element = text;
-    node->element_type = AXIS2_OM_TEXT;
+    
+    om_text->value = NULL;
+    if (value)
+        om_text->value = (char*) axis2_strdup(environment->allocator, value);
+    
+    //om_text->attribute = NULL;
+    om_text->content_id = NULL;
+    om_text->mime_type = NULL;
+    
+    (*node)->data_element = om_text;
+    (*node)->element_type = AXIS2_OM_TEXT;
 
+    (*node)->done = AXIS2_FALSE;
+    
 	if(parent && parent->element_type == AXIS2_OM_ELEMENT)
 	{
-		node->done = TRUE;
-		node->parent = parent;
-		axis2_om_node_add_child(parent,node);
+		(*node)->parent = parent;
+		axis2_om_node_add_child(parent,*node);
 	}
-	text_node = node;
-    return text;
-}
+    
+    /* operations */
+    om_text->ops = NULL;
+    om_text->ops = (axis2_om_text_ops_t*) axis2_malloc(environment->allocator, sizeof(axis2_om_text_ops_t));
+    
+    if (!om_text->ops)
+    {
+        axis2_free(environment->allocator, *node);
+        axis2_free(environment->allocator, om_text);
+		environment->error->errorno = AXIS2_ERROR_NO_MEMORY;        
+		return NULL;
+    }
+    
+    om_text->ops->free = axis2_om_text_ops_free;
+    om_text->ops->serialize = axis2_om_text_ops_serialize;
 
+    return om_text;
+}
 
 
-char *axis2_om_text_get_text(axis2_om_text_t * text)
+int axis2_om_text_ops_free(axis2_environment_t *environment, axis2_om_text_t *om_text)
 {
-    if (!text)
+    if (!om_text)
     {
-		return NULL;
-    }
-    if (text->value)
-	{
-		return text->value;
-	}
-    else
-    {
-	//MTOM handling logic should go hear
-
+        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAMETER;
+        return AXIS2_FAILURE;
     }
-    return NULL;
+    
+    if (om_text->value)
+        axis2_free(environment->allocator, om_text->value);
+    
+    if (om_text->ops)
+        axis2_free(environment->allocator, om_text->ops);
+    
+    if (om_text)
+        axis2_free(environment->allocator, om_text);
+    
+    return AXIS2_SUCCESS;
 }
 
-int axis2_om_text_serialize(axis2_om_text_t *om_text, axis2_om_output_t* om_output)
+int axis2_om_text_ops_serialize(axis2_environment_t *environment, const axis2_om_text_t *om_text,
axis2_om_output_t* om_output)
 {
     int status = AXIS2_SUCCESS;
     // TODO : handle null pointer errors
@@ -80,4 +118,4 @@
         status = axis2_om_output_write (om_output, AXIS2_OM_TEXT, 1,
                                         om_text->value);
     return status;
-}
\ No newline at end of file
+}



Mime
View raw message