axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@apache.org
Subject svn commit: r389468 - in /webservices/axis2/trunk/c: include/axis2_qname.h modules/util/qname.c
Date Tue, 28 Mar 2006 10:23:20 GMT
Author: nandika
Date: Tue Mar 28 02:23:17 2006
New Revision: 389468

URL: http://svn.apache.org/viewcvs?rev=389468&view=rev
Log:
axis2_qname_create_from_string and axis2_qname_to_string functions added 

Modified:
    webservices/axis2/trunk/c/include/axis2_qname.h
    webservices/axis2/trunk/c/modules/util/qname.c

Modified: webservices/axis2/trunk/c/include/axis2_qname.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_qname.h?rev=389468&r1=389467&r2=389468&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_qname.h (original)
+++ webservices/axis2/trunk/c/include/axis2_qname.h Tue Mar 28 02:23:17 2006
@@ -102,7 +102,8 @@
     axis2_char_t* (AXIS2_CALL *
 	to_string)(struct axis2_qname *qname,
                axis2_env_t **env); 
-	
+               
+   
                                               
 } axis2_qname_ops_t;
 
@@ -131,6 +132,17 @@
                     const axis2_char_t * namespace_uri,
                     const axis2_char_t * prefix);
 
+
+/**
+ * returns a newly created qname using a string genarated form 
+ * axis2_qname_to_string method 
+ * freeing the returned qname is users responsibility
+ */           
+
+AXIS2_DECLARE(axis2_qname_t*) 
+axis2_qname_create_from_string(axis2_env_t **env,
+                               axis2_char_t *string);
+	
 
 #define AXIS2_QNAME_FREE(qname, env) \
         ((qname)->ops->free(qname,env))

Modified: webservices/axis2/trunk/c/modules/util/qname.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/qname.c?rev=389468&r1=389467&r2=389468&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/qname.c (original)
+++ webservices/axis2/trunk/c/modules/util/qname.c Tue Mar 28 02:23:17 2006
@@ -18,6 +18,7 @@
 #include <axis2_env.h>
 #include <axis2.h>
 #include <axis2_defines.h>
+#include <string.h>
 
 /********************************** Function prototypes *****************/
 
@@ -321,11 +322,91 @@
     }
     if(!(qname_impl->namespace_uri) || AXIS2_STRCMP(qname_impl->namespace_uri,"") ==
0)
     {
+        /** prefix url both null */
         qname_impl->qname_string = AXIS2_STRDUP(qname_impl->localpart, env);
     }
-    else 
+    else if(!(qname_impl->prefix) || AXIS2_STRCMP(qname_impl->prefix, "") == 0)
     {
-        qname_impl->qname_string = AXIS2_STRACAT( qname_impl->namespace_uri, qname_impl->localpart,
env);
+        /** prefix null */
+        
+        axis2_char_t *temp_string1 = NULL;
+        temp_string1 = AXIS2_STRACAT(qname_impl->localpart, "|", env);
+        qname_impl->qname_string = AXIS2_STRACAT(temp_string1, qname_impl->namespace_uri,
env);
+        if(NULL != temp_string1)
+        {
+            AXIS2_FREE((*env)->allocator, temp_string1);
+            temp_string1 = NULL;
+        }            
     }
+    else
+    {
+        /** both uri and prefix exist */
+        axis2_char_t *temp_string1 = NULL;
+        axis2_char_t *temp_string2 = NULL;
+        axis2_char_t *temp_string3 = NULL;
+        
+        temp_string1 = AXIS2_STRACAT(qname_impl->localpart, "|", env);
+        temp_string2 = AXIS2_STRACAT(temp_string1, qname_impl->namespace_uri, env);
+        temp_string3 = AXIS2_STRACAT(temp_string2, "|", env);
+        qname_impl->qname_string = AXIS2_STRACAT(temp_string3, qname_impl->prefix,
env);
+        
+        if(NULL != temp_string1)
+        {
+            AXIS2_FREE((*env)->allocator, temp_string1);
+            temp_string1 = NULL;
+        }
+        if(NULL != temp_string2)
+        {
+            AXIS2_FREE((*env)->allocator, temp_string2);
+            temp_string2 = NULL;
+        }
+        if(NULL != temp_string3)
+        {
+            AXIS2_FREE((*env)->allocator, temp_string2);
+            temp_string2 = NULL;
+        }
+    }     
     return qname_impl->qname_string;        
 }
+
+AXIS2_DECLARE(axis2_qname_t*) 
+axis2_qname_create_from_string(axis2_env_t **env,
+                               axis2_char_t *qstring)
+{
+    axis2_char_t *localpart = NULL;
+    axis2_char_t *namespace_uri = NULL;
+    axis2_char_t *prefix = NULL;
+    axis2_char_t *index = NULL;
+    axis2_char_t *next = NULL;
+    if(!qstring || AXIS2_STRCMP(qstring, "") == 0)
+        return NULL;
+
+    index = strchr(qstring,'|');
+    if(index != NULL)
+    {
+        
+        next = index+1;
+        qstring[index - qstring] = '\0';
+        
+        localpart = qstring;
+        
+        index = strchr(next, '|');
+        if(NULL != index)
+        {
+            prefix = index+1;
+            next[index - next] = '\0';
+            namespace_uri = next;
+            return axis2_qname_create(env, localpart, namespace_uri, prefix);           
       
+        }
+        else
+        {
+            /** only uri and localpart is available */
+            return axis2_qname_create(env, localpart, next, NULL);
+        }    
+    }
+    else
+    {
+        /** only localpart is there in this qname */
+        return axis2_qname_create(env, qstring, NULL, NULL);
+    }
+}                                
\ No newline at end of file



Mime
View raw message