You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2005/10/13 10:15:02 UTC

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

Author: samisa
Date: Thu Oct 13 01:14:30 2005
New Revision: 320687

URL: http://svn.apache.org/viewcvs?rev=320687&view=rev
Log:
Added axis2_string

Added:
    webservices/axis2/trunk/c/include/axis2_string.h
    webservices/axis2/trunk/c/modules/util/src/axis2_string.c
Modified:
    webservices/axis2/trunk/c/include/axis2_allocator.h
    webservices/axis2/trunk/c/include/axis2_environment.h
    webservices/axis2/trunk/c/include/axis2_om_namespace.h
    webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c
    webservices/axis2/trunk/c/modules/util/src/axis2_environment.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=320687&r1=320686&r2=320687&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_allocator.h (original)
+++ webservices/axis2/trunk/c/include/axis2_allocator.h Thu Oct 13 01:14:30 2005
@@ -24,7 +24,6 @@
     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,6 +39,5 @@
 #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_ALLOCATOR_H */

Modified: webservices/axis2/trunk/c/include/axis2_environment.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_environment.h?rev=320687&r1=320686&r2=320687&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_environment.h (original)
+++ webservices/axis2/trunk/c/include/axis2_environment.h Thu Oct 13 01:14:30 2005
@@ -21,6 +21,7 @@
 #include <axis2_error.h>
 #include <axis2_stream.h>
 #include <axis2_log.h>
+#include <axis2_string.h>
 
 struct axis2_environment;
 struct axis2_environment_ops;
@@ -34,8 +35,9 @@
     axis2_error_t *error;           /* error handling */
     axis2_stream_t *stream;         /* IO routines */
     axis2_log_t *log;               /* logging routines */
+    axis2_string_t *string;         /* string routines */
 } axis2_environment_t;
 
-axis2_environment_t *axis2_environment_create(axis2_allocator_t *allocator, axis2_error_t *error, axis2_stream_t *stream, axis2_log_t *log);
+axis2_environment_t *axis2_environment_create(axis2_allocator_t *allocator, axis2_error_t *error, axis2_stream_t *stream, axis2_log_t *log, axis2_string_t *string);
 
 #endif /* AXIS2_ENVIRONMENT_H */

Modified: webservices/axis2/trunk/c/include/axis2_om_namespace.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_om_namespace.h?rev=320687&r1=320686&r2=320687&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_namespace.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_namespace.h Thu Oct 13 01:14:30 2005
@@ -35,6 +35,27 @@
 */
 typedef struct axis2_om_namespace_ops
 {
+  /**
+    * Free an om_namespcae
+    * @return Status code    
+    */
+    axis2_status_t (*free)(axis2_environment_t *environment, struct axis2_om_namespace *om_namespace);
+
+  /**
+    * Compares two namepsaces
+    * @param om_namespace1 first namespase
+    * @param om_namespace2 second namespace to be compared
+    * @return true if the two namespaces are equal, false otherwise	
+    */
+    axis2_bool_t (*equals)(axis2_environment_t *environment, axis2_om_namespace_t *om_namespace1, axis2_om_namespace_t *om_namespace2);
+
+  /**
+    * Serialize operation
+    * @param om_output OM output handler to be used in serializing
+    * @return Status code
+    */
+    axis2_status_t (*serialize)(axis2_environment_t *environment, axis2_om_namespace_t *om_namespace, axis2_om_output_t* om_output);
+
 } axis2_om_namespace_ops_t;
 
 /** \struct axis2_om_namespace_t
@@ -43,30 +64,21 @@
     Handles the XML namespace in OM
 */
 typedef struct axis2_om_namespace {
-    char *uri;
-    char *prefix;
+    axis2_char_t *uri;
+    axis2_char_t *prefix;
 } axis2_om_namespace_t;
 
 /**
- *	creates an axis2_om_namespace
- *  @param axis2_om_namesapce_t pointer to axis2_om_namespace_t struct
- */
-
-axis2_om_namespace_t *axis2_om_namespace_create(const char *uri,  const char *prefix);
-
-/**
- * free an om_namespcae
- *
- */
-void axis2_om_namespace_free(axis2_om_namespace_t * om_namespace);
-/**
- *	compares two namepsaces
- * @param ns1 ,ns2 namespace to be compared
- * @return true if ns1 equals ns2 , false otherwise	
+ *	Creates an axis2_om_namespace_t struct
+ *  @param uri namespace URI
+ *  @param prefix namespace prefix
+ *  @return a pointer to newly created axis2_om_namespace_t struct
  */
 
-int axis2_om_namespace_equals(axis2_om_namespace_t *om_namespace1, axis2_om_namespace_t *om_namespace2);
+axis2_om_namespace_t *axis2_om_namespace_create(axis2_environment_t *environment, const axis2_char_t *uri,  const axis2_char_t *prefix);
 
-int axis2_om_namespace_serialize(axis2_om_namespace_t *om_namespace, axis2_om_output_t* om_output);
+#define axis2_om_namespace_free(environment, om_namespace) ((om_namespace)->ops->free(environment, om_namespace))
+#define axis2_om_namespace_equals(environment, om_namespace1, om_namespace2) ((om_namespace1)->ops->equals(environment, om_namespace1, om_namespace2))
+#define axis2_om_namespace_serialize(environment, om_namespace,om_output) ((om_namespace)->ops->serialize(environment, om_namespace, om_output))
 
 #endif	// AXIS2_OM_NAMESPACE

Added: webservices/axis2/trunk/c/include/axis2_string.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_string.h?rev=320687&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_string.h (added)
+++ webservices/axis2/trunk/c/include/axis2_string.h Thu Oct 13 01:14:30 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_STRING_H
+#define AXIS2_STRING_H
+
+#include <axis2_defines.h>
+#include <axis2_allocator.h>
+
+typedef struct axis2_string
+{
+    void* (*strdup)(const void *ptr);
+    int (*strcmp)(const axis2_char_t *s1, const axis2_char_t *s2);
+}axis2_string_t;
+
+/**
+*   if the parsed string is null a default string is created
+*   otherwise the parsed string is returned. If there isn't enough 
+*   memory for allocation NULL is returned.
+*   @param string user defined allcator
+*/
+
+axis2_string_t *
+    axis2_string_create(axis2_allocator_t *allocator, axis2_string_t *string);
+    
+#define axis2_strdup(string, ptr) ((string)->strdup(ptr))
+#define axis2_strcmp(string, s1, s2) ((string)->strcmp(s1, s2))
+
+#endif /* AXIS2_STRING_H */

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=320687&r1=320686&r2=320687&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_allocator.c Thu Oct 13 01:14:30 2005
@@ -18,16 +18,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-void* axis2_allocator_strdup(const void* ptr);
-
-void* axis2_allocator_strdup(const void* ptr)
-{
-    if (ptr)
-        return (void*)strdup(ptr);
-    else
-        return NULL;
-}
-
 axis2_allocator_t *axis2_allocator_init(
                 axis2_allocator_t *allocator)
 {
@@ -42,7 +32,6 @@
             allocator->malloc = malloc;
             allocator->realloc = realloc;
             allocator->free = free;
-            allocator->strdup = axis2_allocator_strdup;
             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=320687&r1=320686&r2=320687&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_environment.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_environment.c Thu Oct 13 01:14:30 2005
@@ -16,7 +16,7 @@
 
 #include <axis2_environment.h>
 
-axis2_environment_t *axis2_environment_create(axis2_allocator_t *allocator, axis2_error_t *error, axis2_stream_t *stream, axis2_log_t *log)
+axis2_environment_t *axis2_environment_create(axis2_allocator_t *allocator, axis2_error_t *error, axis2_stream_t *stream, axis2_log_t *log, axis2_string_t *string)
 {
     if (!allocator)
         return NULL;
@@ -30,12 +30,23 @@
 
     if (!error)
         environment->error = axis2_error_create(allocator);
+    else
+        environment->error = error;
 
     if (!stream)
         environment->stream = axis2_stream_create(allocator, NULL);
+    else
+        environment->stream = stream;
 
     if (!log)
         environment->log = axis2_log_create(allocator, NULL);
+    else
+        environment->log = log;
+
+    if (!string)
+        environment->string = axis2_string_create(allocator, NULL);
+    else
+        environment->string = string;
 
     return environment;
 }

Added: webservices/axis2/trunk/c/modules/util/src/axis2_string.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_string.c?rev=320687&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_string.c (added)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_string.c Thu Oct 13 01:14:30 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <axis2_string.h>
+#include <stdlib.h>
+#include <string.h>
+
+void* axis2_string_strdup(const void* ptr)
+{
+    if (ptr)
+        return (void*)strdup(ptr);
+    else
+        return NULL;
+}
+
+int axis2_string_strcmp(const axis2_char_t *s1, const axis2_char_t *s2)
+{
+    if (s1 && s2)
+        return strcmp(s1, s2);
+    else
+        return -1;
+}
+
+axis2_string_t *axis2_string_create(axis2_allocator_t *allocator,
+                axis2_string_t *string)
+{
+    if(string)
+        return string;
+
+    if (!allocator)
+        return NULL;
+        
+    else
+    {
+        string = (axis2_string_t*)axis2_malloc(allocator, sizeof(axis2_string_t));
+        if(string)
+        {
+            string->strdup = axis2_string_strdup;
+            string->strcmp = axis2_string_strcmp;
+            return string;
+        }
+     }
+    return NULL;
+}