axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r331197 - in /webservices/axis2/trunk/c: include/axis2_qname.h modules/util/src/qname.c
Date Mon, 07 Nov 2005 04:26:42 GMT
Author: samisa
Date: Sun Nov  6 20:26:36 2005
New Revision: 331197

URL: http://svn.apache.org/viewcvs?rev=331197&view=rev
Log:
patch applied , axis2_qname modified to have a clone method and using new coding style

Modified:
    webservices/axis2/trunk/c/include/axis2_qname.h
    webservices/axis2/trunk/c/modules/util/src/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=331197&r1=331196&r2=331197&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_qname.h (original)
+++ webservices/axis2/trunk/c/include/axis2_qname.h Sun Nov  6 20:26:36 2005
@@ -1,4 +1,4 @@
-/*
+    /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -51,9 +51,9 @@
      *  Free a qname struct
      *  @return Status code
      */
-    axis2_status_t (AXIS2_CALL *axis2_qname_ops_free) (axis2_env_t * environment,
-                                            struct axis2_qname * qname);
-
+    axis2_status_t (AXIS2_CALL *free) (struct axis2_qname * qname,
+                                       axis2_env_t **env);
+                                       
      /** 
       * Compare two qnames
       * prefix is ignored when comparing
@@ -61,27 +61,47 @@
       * @return true if qname1 equals qname2, false otherwise 
       */
 
-    axis2_bool_t (AXIS2_CALL *axis2_qname_ops_equals) (axis2_env_t * environment,
-                                            struct axis2_qname * qname1,
-                                            struct axis2_qname * qname2);
-
+    axis2_bool_t (AXIS2_CALL *equals) (struct axis2_qname * qname,
+                                       axis2_env_t **env,
+                                       struct axis2_qname * qname1);
+      /** 
+      * clones a given qname
+      * @param qname , qname struct instance to be cloned
+      * @env   environment , double pointer to environment
+      * @returns the newly cloned qname struct instance
+      */                                       
+       
+    struct axis2_qname* (AXIS2_CALL *clone)(struct axis2_qname *qname,
+                                            axis2_env_t **env);
+                                       
+    axis2_char_t* (AXIS2_CALL *get_uri)(struct axis2_qname *qname,
+                                        axis2_env_t **env);
+                                        
+    axis2_char_t* (AXIS2_CALL *get_prefix)(struct axis2_qname *qname,
+                                           axis2_env_t **env);
+
+    axis2_char_t* (AXIS2_CALL *get_localpart)(struct axis2_qname *qname,
+                                              axis2_env_t **env);
+                                              
+    axis2_status_t* (AXIS2_CALL *set_uri)(struct axis2_qname *qname,
+                                          axis2_env_t **env,
+                                          const axis2_char_t *uri);
+    
+    axis2_status_t* (AXIS2_CALL *set_prefix)(struct axis2_qname *qname,
+                                             axis2_env_t **env,
+                                             const axis2_char_t *prefix);
+
+    axis2_status_t* (AXIS2_CALL *set_localpart)(struct axis2_qname *qname,              
                                                                                         
                                                                       
+                                                axis2_env_t **env,
+                                                const axis2_char_t *localpart);
+                                                
+    
 } axis2_qname_ops_t;
 
 typedef struct axis2_qname
 {
     /** operations related to qname */
     axis2_qname_ops_t *ops;
-
-    /** localpart of qname is mandatory */
-
-    axis2_char_t *localpart;
-
-    /** namespace uri is optional */
-    axis2_char_t *namespace_uri;
-
-    /**  prefix mandatory */
-    axis2_char_t *prefix;
-
 } axis2_qname_t;
 
 /**
@@ -95,14 +115,39 @@
  * @return a pointer to newly created qname struct
  */
 
-AXIS2_DECLARE(axis2_qname_t *) axis2_qname_create (axis2_env_t * environment,
-                                   const axis2_char_t * localpart,
-                                   const axis2_char_t * namespace_uri,
-                                   const axis2_char_t * prefix);
-
-
-#define AXIS2_QNAME_FREE(environment,qname) ((qname)->ops->axis2_qname_ops_free(environment,qname))
-#define AXIS2_QNAME_EQUALS(environment,qname1,qname2) ((qname1)->ops->axis2_qname_ops_equals(environment,qname1,qname2))
+AXIS2_DECLARE(axis2_qname_t *)
+axis2_qname_create (axis2_env_t **env,
+                    const axis2_char_t * localpart,
+                    const axis2_char_t * namespace_uri,
+                    const axis2_char_t * prefix);
+
+
+#define AXIS2_QNAME_FREE(qname, env) \
+        ((qname)->ops->free(qname,env))
+        
+#define AXIS2_QNAME_EQUALS(qname, env, qname1) \
+        ((qname)->ops->equals(qname, env, qname1))
+
+#define AXIS2_QNAME_CLONE(qname, env) \
+        ((qname)->ops->clone(qname, env))        
+        
+#define AXIS2_QNAME_GET_URI(qname, env) \
+        ((qname)->ops->get_uri(qname, env))
+        
+#define AXIS2_QNAME_GET_PREFIX(qname, env) \
+        ((qname)->ops->get_prefix(qname, env))
+        
+#define AXIS2_QNAME_GET_LOCALPART(qname, env) \
+        ((qname)->ops->get_localpart(qname, env))
+        
+#define AXIS2_QNAME_SET_PREFIX(qname, env, prefix) \
+        ((qname)->ops->set_prefix(qname, env, prefix)) 
+               
+#define AXIS2_QNAME_SET_URI(qname, env, prefix) \
+        ((qname)->ops->set_uri(qname, env, uri))
+        
+#define AXIS2_QNAME_SET_LOCALPART(qname, env,localpart) \
+        ((qname)->ops->set_localpart(qname, env, localpart))                      
                  
 
 /** @} */
 

Modified: webservices/axis2/trunk/c/modules/util/src/qname.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/qname.c?rev=331197&r1=331196&r2=331197&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/qname.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/qname.c Sun Nov  6 20:26:36 2005
@@ -16,64 +16,222 @@
 
 #include <axis2_qname.h>
 #include <axis2_env.h>
+#include <axis2.h>
 #include <axis2_defines.h>
 
+/********************************** Function prototypes *****************/
 
-axis2_status_t AXIS2_CALL  axis2_qname_impl_free (axis2_env_t * environment,
-                                      axis2_qname_t * qname);
-axis2_bool_t AXIS2_CALL  axis2_qname_impl_equals (axis2_env_t * environment,
-                                      axis2_qname_t * qn1,
-                                      axis2_qname_t * qn2);
-/*AXIS2_DECLARE(axis2_qname_t*) axis2_qname_create (axis2_env_t * environment,
-                                   const axis2_char_t * localpart,
-                                   const axis2_char_t * namespace_uri,
-                                   const axis2_char_t * prefix);
-*/
+axis2_status_t AXIS2_CALL 
+axis2_qname_free ( axis2_qname_t * qname,
+                   axis2_env_t **env);
+
+
+axis2_bool_t AXIS2_CALL 
+axis2_qname_equals (axis2_qname_t * qname,
+                    axis2_env_t **env,
+                    axis2_qname_t * qname1);
+
+axis2_qname_t* AXIS2_CALL
+axis2_qname_clone(axis2_qname_t *qname,
+                  axis2_env_t **env);
+                                      
+axis2_char_t* AXIS2_CALL
+axis2_qname_get_uri(axis2_qname_t *qname,
+                    axis2_env_t **env);
+                                        
+axis2_char_t* AXIS2_CALL 
+axis2_qname_get_prefix(axis2_qname_t *qname,
+                        axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL 
+axis2_qname_get_localname(axis2_qname_t *qname,
+                          axis2_env_t **env);
+                                            
+axis2_status_t AXIS2_CALL 
+axis2_qname_set_uri(axis2_qname_t *qname,
+                     axis2_env_t **env,
+                     const axis2_char_t *uri);
 
 axis2_status_t AXIS2_CALL
-axis2_qname_impl_free (axis2_env_t * environment,
-                       axis2_qname_t * qname)
+axis2_qname_set_prefix(axis2_qname_t *qname,
+                        axis2_env_t **env,
+                        const axis2_char_t *prefix);
+
+axis2_status_t AXIS2_CALL
+axis2_qname_set_localpart(axis2_qname_t *qname,                                         
                                                                                         
                                            
+                          axis2_env_t **env,
+                          const axis2_char_t *localname);                   
+
+
+
+/*************************************** qname struct *********************/
+
+typedef struct axis2_qname_impl_t
+{
+    /* this should be first member */
+    axis2_qname_t qname;
+    /** localpart of qname is mandatory */
+
+    axis2_char_t *localpart;
+
+    /** namespace uri is optional */
+    axis2_char_t *namespace_uri;
+
+    /**  prefix mandatory */
+    axis2_char_t *prefix;
+
+}axis2_qname_impl_t;
+
+
+/************************* Macro ****************************************/
+
+#define AXIS2_INTF_TO_IMPL(qname) ((axis2_qname_impl_t*)qname)
+
+/************************************************************************/
+
+AXIS2_DECLARE(axis2_qname_t *)
+axis2_qname_create (axis2_env_t **env,
+                    const axis2_char_t * localpart,
+                    const axis2_char_t * namespace_uri,
+                    const axis2_char_t * prefix)
 {
-    if (!qname)
+
+    axis2_qname_impl_t *qn = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+   
+    /* localpart or prefix can't be null */
+    if (!localpart)
     {
-        environment->error->error_number = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return AXIS2_FAILURE;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return NULL;
+    }
+
+    qn = (axis2_qname_impl_t *) AXIS2_MALLOC ((*env)->allocator,
+                                             sizeof (axis2_qname_t));
+    if (!qn)
+    {
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return NULL;
+    }
+    /* set properties */
+
+    qn->localpart = (axis2_char_t *)axis2_strdup (localpart);
+    if (!(qn->localpart))
+    {
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        AXIS2_FREE ((*env)->allocator, qn);
+        return NULL;
+    }
+
+    if (!prefix)
+    {
+        qn->prefix = (axis2_char_t*)axis2_strdup("");
+    }
+    else
+    {
+        qn->prefix =(axis2_char_t*)axis2_strdup (prefix);
+    }
+    if (!(qn->prefix))
+    {
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        AXIS2_FREE ((*env)->allocator, qn->localpart);
+        AXIS2_FREE ((*env)->allocator, qn);
+        return NULL;
+    }
+    if (!namespace_uri)
+    {
+        qn->namespace_uri = (axis2_char_t*)axis2_strdup ("");
+    }
+    else
+    {
+        qn->namespace_uri = (axis2_char_t*)axis2_strdup (namespace_uri);
+    }
+    if (!(qn->namespace_uri))
+    {
+        AXIS2_FREE ((*env)->allocator, qn->localpart);
+        AXIS2_FREE ((*env)->allocator, qn->prefix);
+        AXIS2_FREE ((*env)->allocator, qn);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return NULL;
     }
-    if (qname->localpart)
+
+   
+    qn->qname.ops = NULL;
+    qn->qname.ops = (axis2_qname_ops_t*)AXIS2_MALLOC ((*env)->allocator,
+                                                      sizeof (axis2_qname_ops_t));
+ 
+    if (!qn->qname.ops)
     {
-        AXIS2_FREE (environment->allocator, qname->localpart);
+        AXIS2_FREE ((*env)->allocator, qn->localpart);
+        if (qn->namespace_uri)
+            AXIS2_FREE ((*env)->allocator, qn->namespace_uri);
+        AXIS2_FREE ((*env)->allocator, qn->prefix);
+        AXIS2_FREE ((*env)->allocator, qn);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return NULL;
     }
-    if (qname->namespace_uri)
+
+    //qn->qname.ops->free = axis2_qname_impl_free;
+    //qn->qname.ops->equals = axis2_qname_impl_equals;
+    return &(qn->qname);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_qname_free ( axis2_qname_t * qname,
+                   axis2_env_t **env)
+{   
+    AXIS2_FUNC_PARAM_CHECK(qname, env, AXIS2_FAILURE);
+    
+    if (AXIS2_INTF_TO_IMPL(qname)->localpart)
     {
-        AXIS2_FREE (environment->allocator, qname->namespace_uri);
+        AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(qname)->localpart);
     }
-    if (qname->prefix)
+    if (AXIS2_INTF_TO_IMPL(qname)->namespace_uri)
     {
-        AXIS2_FREE (environment->allocator, qname->prefix);
+        AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(qname)->namespace_uri);
+    }
+    if (AXIS2_INTF_TO_IMPL(qname)->prefix)
+    {
+        AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(qname)->prefix);
     }
     if (qname->ops)
     {
-        AXIS2_FREE (environment->allocator, qname->ops);
+        AXIS2_FREE ((*env)->allocator, qname->ops);
     }
-    AXIS2_FREE (environment->allocator, qname);
+    AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(qname));
     return AXIS2_SUCCESS;
 
 }
 
+
 axis2_bool_t AXIS2_CALL
-axis2_qname_impl_equals (axis2_env_t * environment,
-                         axis2_qname_t * qn1, axis2_qname_t * qn2)
+axis2_qname_equals (axis2_qname_t *qname,
+                    axis2_env_t **env, 
+                    axis2_qname_t * qname1)
 {
-
+    axis2_qname_impl_t *qn1 = NULL;
+    axis2_qname_impl_t *qn2 = NULL;
     int uris_differ = 0;
     int localparts_differ = 0;
 
-    if (!qn1 || !qn2)
+    AXIS2_FUNC_PARAM_CHECK(qname ,env, AXIS2_FALSE);
+    
+    if (!qname1)
     {
-        environment->error->error_number = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return AXIS2_FALSE;
     }
 
+    qn1 = AXIS2_INTF_TO_IMPL(qname);
+    qn2 = AXIS2_INTF_TO_IMPL(qname1);
 
     if (qn1->localpart && qn2->localpart)
     {
@@ -100,87 +258,90 @@
 }
 
 
-AXIS2_DECLARE(axis2_qname_t *)
-axis2_qname_create (axis2_env_t * environment,
-                    const axis2_char_t * localpart,
-                    const axis2_char_t * namespace_uri,
-                    const axis2_char_t * prefix)
+axis2_qname_t* AXIS2_CALL
+axis2_qname_clone(axis2_qname_t *qname,
+                  axis2_env_t **env)
 {
+    axis2_qname_impl_t *qname_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(qname, env, NULL);
+    qname_impl = AXIS2_INTF_TO_IMPL(qname);
+    return axis2_qname_create(env, qname_impl->localpart,
+                              qname_impl->namespace_uri,
+                              qname_impl->prefix);
+}
 
-    axis2_qname_t *qn = NULL;
-    /* localpart or prefix can't be null */
-    if (!localpart)
-    {
-        environment->error->error_number = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return NULL;
-    }
 
-    qn = (axis2_qname_t *) AXIS2_MALLOC (environment->allocator,
-                                         sizeof (axis2_qname_t));
-    if (!qn)
-    {
-        environment->error->error_number = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return NULL;
-    }
-    /* set properties */
+                  
+axis2_char_t* AXIS2_CALL
+axis2_qname_get_uri(axis2_qname_t *qname,
+                    axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(qname, env,NULL);
+    return AXIS2_INTF_TO_IMPL(qname)->namespace_uri;
+}                    
+                                        
+axis2_char_t* AXIS2_CALL 
+axis2_qname_get_prefix(axis2_qname_t *qname,
+                        axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(qname, env,NULL);
+    return AXIS2_INTF_TO_IMPL(qname)->prefix;
+}
 
-    qn->localpart = axis2_strdup (localpart);
-    if (!(qn->localpart))
-    {
-        AXIS2_FREE (environment->allocator, qn);
-        environment->error->error_number = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
-    }
 
-    if (!prefix)
-    {
-        qn->prefix = axis2_strdup ("");
-    }
-    else
-    {
-        qn->prefix = axis2_strdup (prefix);
-    }
-    if (!(qn->prefix))
-    {
-        AXIS2_FREE (environment->allocator, qn->localpart);
-        AXIS2_FREE (environment->allocator, qn);
-        environment->error->error_number = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
-    }
-    if (!namespace_uri)
-    {
-        qn->namespace_uri = axis2_strdup ("");
-    }
-    else
-    {
-        qn->namespace_uri = axis2_strdup (namespace_uri);
-    }
-    if (!(qn->namespace_uri))
+axis2_char_t* AXIS2_CALL 
+axis2_qname_get_localpart(axis2_qname_t *qname,
+                          axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(qname, env,NULL);
+    return AXIS2_INTF_TO_IMPL(qname)->localpart;
+}                          
+                                            
+axis2_status_t AXIS2_CALL 
+axis2_qname_set_uri(axis2_qname_t *qname,
+                     axis2_env_t **env,
+                     const axis2_char_t *uri)
+{
+    AXIS2_FUNC_PARAM_CHECK(qname, env,AXIS2_FAILURE);
+    if(!uri)
     {
-        AXIS2_FREE (environment->allocator, qn->localpart);
-        AXIS2_FREE (environment->allocator, qn->prefix);
-        AXIS2_FREE (environment->allocator, qn);
-        environment->error->error_number = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
     }
+    AXIS2_INTF_TO_IMPL(qname)->namespace_uri = (axis2_char_t*)axis2_strdup(uri);
+    return AXIS2_SUCCESS;
+}
 
 
-    qn->ops = NULL;
-    qn->ops =
-        AXIS2_MALLOC (environment->allocator, sizeof (axis2_qname_ops_t));
-    /* operations */
-    if (!qn->ops)
+axis2_status_t AXIS2_CALL
+axis2_qname_set_prefix(axis2_qname_t *qname,
+                        axis2_env_t **env,
+                        const axis2_char_t *prefix)
+{
+    AXIS2_FUNC_PARAM_CHECK(qname, env,AXIS2_FAILURE);
+    if(!prefix)
     {
-        AXIS2_FREE (environment->allocator, qn->localpart);
-        if (qn->namespace_uri)
-            AXIS2_FREE (environment->allocator, qn->namespace_uri);
-        AXIS2_FREE (environment->allocator, qn->prefix);
-        AXIS2_FREE (environment->allocator, qn);
-        environment->error->error_number = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
     }
-
-    qn->ops->axis2_qname_ops_free = axis2_qname_impl_free;
-    qn->ops->axis2_qname_ops_equals = axis2_qname_impl_equals;
-    return qn;
+    AXIS2_INTF_TO_IMPL(qname)->prefix = (axis2_char_t*)axis2_strdup(prefix);
+    return AXIS2_SUCCESS;
 }
+
+axis2_status_t AXIS2_CALL
+axis2_qname_set_localpart(axis2_qname_t *qname,                                         
                                                                                         
                                            
+                          axis2_env_t **env,
+                          const axis2_char_t *localpart)
+{
+    AXIS2_FUNC_PARAM_CHECK(qname, env,AXIS2_FAILURE);
+    if(!localpart)
+    {
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    AXIS2_INTF_TO_IMPL(qname)->localpart = (axis2_char_t*)axis2_strdup(localpart);
+    return AXIS2_SUCCESS;
+}                          
\ No newline at end of file



Mime
View raw message