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 da...@apache.org on 2006/06/07 12:34:02 UTC

svn commit: r412360 - in /webservices/axis2/trunk/c/util: configure.ac include/axis2_string.h include/axis2_uri.h src/string.c src/uri.c test/unit/util/Makefile.am test/unit/util/util_test.c test/unit/util/util_uri_test.c test/unit/util/util_uri_test.h

Author: damitha
Date: Wed Jun  7 03:34:01 2006
New Revision: 412360

URL: http://svn.apache.org/viewvc?rev=412360&view=rev
Log:
Improved uri class to hide the axis2_uri_t structure

Modified:
    webservices/axis2/trunk/c/util/configure.ac
    webservices/axis2/trunk/c/util/include/axis2_string.h
    webservices/axis2/trunk/c/util/include/axis2_uri.h
    webservices/axis2/trunk/c/util/src/string.c
    webservices/axis2/trunk/c/util/src/uri.c
    webservices/axis2/trunk/c/util/test/unit/util/Makefile.am
    webservices/axis2/trunk/c/util/test/unit/util/util_test.c
    webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.c
    webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.h

Modified: webservices/axis2/trunk/c/util/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/configure.ac?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/configure.ac (original)
+++ webservices/axis2/trunk/c/util/configure.ac Wed Jun  7 03:34:01 2006
@@ -23,7 +23,7 @@
 AC_CHECK_LIB(z, inflate)
 
 #CFLAGS="$CFLAGS -ansi -Wall -D_LARGEFILE64_SOURCE -Wno-implicit-function-declaration"
-CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE -g"
+CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
 if test "$GCC" = "yes"; then
     CFLAGS="$CFLAGS -ansi -Wall -Wno-implicit-function-declaration"
 fi
@@ -45,6 +45,40 @@
 AC_FUNC_REALLOC
 #AC_CHECK_FUNCS([memmove])
 
+AC_MSG_CHECKING(whether to build guththila xml parser library)
+AC_ARG_ENABLE(guththila, [  --enable-guththila    build guththila xml parser library wrapper. default=no],
+[ case "${enableval}" in
+  no)
+    AC_MSG_RESULT(no)
+    GUTHTHILA_DIR=""
+    ;;
+  *)
+    AC_MSG_RESULT(yes)
+    GUTHTHILA_DIR="guththila"
+
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+  GUTHTHILA_DIR=""
+)
+
+AC_MSG_CHECKING(whether to build libxml2 xml parser library)
+AC_ARG_ENABLE(libxml2, [  --enable-libxml2    build libxml2 xml parser library wrapper. default=yes],
+[ case "${enableval}" in
+  no)
+    AC_MSG_RESULT(no)
+    LIBXML2_DIR=""
+    ;;
+  *)
+    AC_MSG_RESULT(yes)
+    LIBXML2_DIR="libxml2"
+
+    ;;
+  esac ],
+  AC_MSG_RESULT(yes)
+  LIBXML2_DIR="libxml2"
+)
+
 AC_MSG_CHECKING(whether to build tests)
 AC_ARG_ENABLE(tests, [  --enable-tests    build tests. default=no],
 [ case "${enableval}" in
@@ -62,6 +96,18 @@
   TESTDIR=""
 )
 
+
+PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
+CFLAGS="$CFLAGS $LIBXML2_CFLAGS $GUTHTHILA_CFLAGS"
+
+UTILINC=$axis2_utilinc
+
+AC_SUBST(UTILINC)
+AC_SUBST(LIBXML2_CFLAGS)
+AC_SUBST(LIBXML2_LIBS)
+AC_SUBST(LIBXML2_DIR)
+AC_SUBST(GUTHTHILA_DIR)
+AC_SUBST(GUTHTHILA_LIBS)
 AC_SUBST(TESTDIR)
 
 AC_CONFIG_FILES([Makefile \

Modified: webservices/axis2/trunk/c/util/include/axis2_string.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_string.h?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_string.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_string.h Wed Jun  7 03:34:01 2006
@@ -103,7 +103,8 @@
      * @return The new string
      */
     AXIS2_DECLARE_NONSTD(axis2_char_t *) 
-    axis2_strcat(axis2_env_t *env, ...);
+    axis2_strcat(
+            const axis2_env_t *env, ...);
         
     AXIS2_EXTERN axis2_char_t * AXIS2_CALL
     axis2_strstr (const axis2_char_t *heystack,

Modified: webservices/axis2/trunk/c/util/include/axis2_uri.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_uri.h?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_uri.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_uri.h Wed Jun  7 03:34:01 2006
@@ -75,49 +75,83 @@
 #define AXIS2_URI_UNP_OMITQUERY       (1U<<5)
 
 /** @see axis2_uri_t */
-typedef struct axis2_uri_t axis2_uri_t;
 typedef  unsigned short  axis2_port_t;
+/* axis2_uri.c */
 
-/**
- * A structure to encompass all of the fields in a uri
- */
-struct axis2_uri_t 
-{
-    /** scheme ("http"/"ftp"/...) */
-    axis2_char_t *scheme;
-    /** combined [user[:password]\@]host[:port] */
-    axis2_char_t *hostinfo;
-    /** user name, as in http://user:passwd\@host:port/ */
-    axis2_char_t *user;
-    /** password, as in http://user:passwd\@host:port/ */
-    axis2_char_t *password;
-    /** hostname from URI (or from Host: header) */
-    axis2_char_t *hostname;
-    /** port string (integer representation is in "port") */
-    axis2_char_t *port_str;
-    /** the request path (or "/" if only scheme://host was given) */
-    axis2_char_t *path;
-    /** Everything after a '?' in the path, if present */
-    axis2_char_t *query;
-    /** Trailing "#fragment" string, if present */
-    axis2_char_t *fragment;
 
-    /** structure returned from gethostbyname() */
-    struct hostent *hostent;
+typedef struct axis2_uri_ops axis2_uri_ops_t;
+typedef struct axis2_uri axis2_uri_t;
 
-    /** The port number, numeric, valid only if port_str != NULL */
-    axis2_port_t port;
     
-    /** has the structure been initialized */
-    unsigned is_initialized:1;
+/** 
+ * @brief URI ops struct
+ * Encapsulator struct for ops of axis2_uri
+ */  
+AXIS2_DECLARE_DATA struct axis2_uri_ops
+{
 
-    /** has the DNS been looked up yet */
-    unsigned dns_looked_up:1;
-    /** has the dns been resolved yet */
-    unsigned dns_resolved:1;
+    axis2_status_t (AXIS2_CALL *
+    free) (
+            axis2_uri_t *uri, 
+            const axis2_env_t *env);
+ 
+    /**
+     * Unparse a axis2_uri_t structure to an URI string.  Optionally 
+     * suppress the password for security reasons.
+     * @param uptr All of the parts of the uri
+     * @param flags How to unparse the uri.  One of:
+     * <PRE>
+     *    AXIS2_URI_UNP_OMITSITEPART        Suppress "scheme://user\@site:port" 
+     *    AXIS2_URI_UNP_OMITUSER            Just omit user 
+     *    AXIS2_URI_UNP_OMITPASSWORD        Just omit password 
+     *    AXIS2_URI_UNP_OMITUSERINFO        Omit "user:password\@" part
+     *    AXIS2_URI_UNP_REVEALPASSWORD      Show plain text password (default: show XXXXXXXX)
+     *    AXIS2_URI_UNP_OMITPATHINFO        Show "scheme://user\@site:port" only 
+     *    AXIS2_URI_UNP_OMITQUERY           Omit "?queryarg" or "#fragment" 
+     * </PRE>
+     * @return The uri as a string
+     */
+    axis2_char_t* (AXIS2_CALL *
+    to_string) (
+            const axis2_uri_t *uri, 
+            const axis2_env_t *env,
+            unsigned flags);
+   
+    axis2_char_t* (AXIS2_CALL *
+    get_protocol) (
+            axis2_uri_t *uri, 
+            const axis2_env_t *env);
+   
+    axis2_char_t* (AXIS2_CALL *
+    get_server)(
+            axis2_uri_t *uri, 
+            const axis2_env_t *env);
+            
+    axis2_port_t (AXIS2_CALL *
+    get_port) (
+            axis2_uri_t *uri, 
+            const axis2_env_t *env);
+            
+    axis2_char_t* (AXIS2_CALL *
+    get_path)(
+            axis2_uri_t *uri, 
+            const axis2_env_t *env);
+
+    axis2_uri_t* (AXIS2_CALL *
+    clone) (
+            const axis2_uri_t *uri,
+            const axis2_env_t *env);
+};
+
+/** 
+ * @brief URI struct
+ *    Axis2 URI
+ */
+AXIS2_DECLARE_DATA struct axis2_uri
+{
+    axis2_uri_ops_t *ops;    
 };
 
-/* axis2_uri.c */
 /**
  * Return the default port for a given scheme.  The schemes recognized are
  * http, ftp, https, gopher, wais, nntp, snews, and prospero
@@ -129,28 +163,6 @@
         const axis2_char_t *scheme_str);
 
 /**
- * Unparse a axis2_uri_t structure to an URI string.  Optionally 
- * suppress the password for security reasons.
- * @param uptr All of the parts of the uri
- * @param flags How to unparse the uri.  One of:
- * <PRE>
- *    AXIS2_URI_UNP_OMITSITEPART        Suppress "scheme://user\@site:port" 
- *    AXIS2_URI_UNP_OMITUSER            Just omit user 
- *    AXIS2_URI_UNP_OMITPASSWORD        Just omit password 
- *    AXIS2_URI_UNP_OMITUSERINFO        Omit "user:password\@" part
- *    AXIS2_URI_UNP_REVEALPASSWORD      Show plain text password (default: show XXXXXXXX)
- *    AXIS2_URI_UNP_OMITPATHINFO        Show "scheme://user\@site:port" only 
- *    AXIS2_URI_UNP_OMITQUERY           Omit "?queryarg" or "#fragment" 
- * </PRE>
- * @return The uri as a string
- */
-AXIS2_EXTERN axis2_char_t * AXIS2_CALL
-axis2_uri_to_string(
-        const axis2_env_t *env, 
-        const axis2_uri_t *uptr,
-        unsigned flags);
-
-/**
  * Parse a given URI, fill in all supplied fields of a axis2_uri_t
  * structure. This eliminates the necessity of extracting host, port,
  * path, query info repeatedly in the modules.
@@ -199,6 +211,30 @@
         const axis2_uri_t* base,
         const char* uri);
 
+/************************** Start of function macros **************************/
+      
+#define AXIS2_URI_FREE(uri, env) \
+      ((uri)->ops->free(uri, env))
+
+#define AXIS2_URI_TO_STRING(uri, env, flags) \
+      (((axis2_uri_t *) uri)->ops->to_string(uri, env, flags))
+
+#define AXIS2_URI_GET_PROTOCOL(uri, env) \
+      ((uri)->ops->get_protocol(uri, env))
+      
+#define AXIS2_URI_GET_SERVER(uri, env) \
+      ((uri)->ops->get_server(uri, env))
+      
+#define AXIS2_URI_GET_PORT(uri, env) \
+      ((uri)->ops->get_port(uri, env))
+      
+#define AXIS2_URI_GET_PATH(uri, env) \
+      ((uri)->ops->get_path(uri, env))
+      
+#define AXIS2_URI_CLONE(uri, env) \
+      ((uri)->ops->clone(uri, env))
+
+/************************** End of function macros ****************************/    
 
 /** @} */
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/util/src/string.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/string.c?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/string.c (original)
+++ webservices/axis2/trunk/c/util/src/string.c Wed Jun  7 03:34:01 2006
@@ -114,7 +114,8 @@
 }
 
 AXIS2_DECLARE_NONSTD(axis2_char_t *) 
-axis2_strcat(axis2_env_t *env, ...)
+axis2_strcat(
+        const axis2_env_t *env, ...)
 {
     axis2_char_t *cp, *argp, *str;
     size_t saved_lengths[MAX_SAVED_LENGTHS];

Modified: webservices/axis2/trunk/c/util/src/uri.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/uri.c?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/uri.c (original)
+++ webservices/axis2/trunk/c/util/src/uri.c Wed Jun  7 03:34:01 2006
@@ -5,6 +5,7 @@
 #include <axis2_uri.h>
 
 typedef struct schemes_t schemes_t;
+typedef struct axis2_uri_impl axis2_uri_impl_t;
 
 /** Structure to store various schemes and their default ports */
 struct schemes_t 
@@ -44,122 +45,6 @@
     { NULL, 0xFFFF }     /* unknown port */
 };
 
-AXIS2_EXTERN axis2_port_t AXIS2_CALL 
-axis2_uri_port_of_scheme(
-        const axis2_char_t *scheme_str)
-{
-    schemes_t *scheme;
-
-    if (scheme_str) 
-    {
-        for (scheme = schemes; scheme->name != NULL; ++scheme) 
-        {
-            if (AXIS2_STRCASECMP(scheme_str, scheme->name) == 0) 
-            {
-                return scheme->default_port;
-            }
-        }
-    }
-    return 0;
-}
-
-/* Unparse a axis2_uri_t structure to an URI string.
- * Optionally suppress the password for security reasons.
- */
-AXIS2_EXTERN axis2_char_t * AXIS2_CALL 
-axis2_uri_to_string(
-        const axis2_env_t *env, 
-        const axis2_uri_t *uptr, 
-        unsigned flags)
-{
-    axis2_char_t *ret = "";
-
-    /* If suppressing the site part, omit both user name & scheme://hostname */
-    if (!(flags & AXIS2_URI_UNP_OMITSITEPART)) 
-    {
-
-        /* Construct a "user:password@" string, honoring the passed
-         * AXIS2_URI_UNP_ flags: */
-        if (uptr->user || uptr->password) 
-        {
-            ret = axis2_strcat(env,
-                      (uptr->user     && !(flags & AXIS2_URI_UNP_OMITUSER))
-                          ? uptr->user : "",
-                      (uptr->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD))
-                          ? ":" : "",
-                      (uptr->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD))
-                          ? ((flags & AXIS2_URI_UNP_REVEALPASSWORD)
-                              ? uptr->password : "XXXXXXXX")
-                          : "",
-                      ((uptr->user     && !(flags & AXIS2_URI_UNP_OMITUSER)) ||
-                       (uptr->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD)))
-                          ? "@" : "", 
-                      NULL);
-        }
-
-        /* Construct scheme://site string */
-        if (uptr->hostname) 
-        {
-            int is_default_port;
-            const axis2_char_t *lbrk = "", *rbrk = "";
-
-            if (strchr(uptr->hostname, ':')) 
-            { /* v6 literal */
-                lbrk = "[";
-                rbrk = "]";
-            }
-
-            is_default_port =
-                (uptr->port_str == NULL ||
-                 uptr->port == 0 ||
-                 uptr->port == axis2_uri_port_of_scheme(uptr->scheme));
-
-            if (uptr->scheme) 
-            {
-                ret = axis2_strcat(env,
-                              uptr->scheme, "://", ret,
-                              lbrk, uptr->hostname, rbrk,
-                              is_default_port ? "" : ":",
-                              is_default_port ? "" : uptr->port_str,
-                              NULL);
-            }
-            else 
-            {
-                /* A violation of RFC2396, but it is clear from section 3.2
-                 * that the : belongs above to the scheme, while // belongs
-                 * to the authority, so include the authority prefix while
-                 * omitting the "scheme:" that the user neglected to pass us.
-                 */
-                ret = axis2_strcat(env,
-                              "//", ret, lbrk, uptr->hostname, rbrk,
-                              is_default_port ? "" : ":",
-                              is_default_port ? "" : uptr->port_str,
-                              NULL);
-            }
-        }
-    }
-
-    /* Should we suppress all path info? */
-    if (!(flags & AXIS2_URI_UNP_OMITPATHINFO)) 
-    {
-        /* Append path, query and fragment strings: */
-        ret = axis2_strcat(env,
-                            ret,
-                          (uptr->path)
-                              ? uptr->path : "",
-                          (uptr->query    && !(flags & AXIS2_URI_UNP_OMITQUERY))
-                              ? "?" : "",
-                          (uptr->query    && !(flags & AXIS2_URI_UNP_OMITQUERY))
-                              ? uptr->query : "",
-                          (uptr->fragment && !(flags & AXIS2_URI_UNP_OMITQUERY))
-                              ? "#" : NULL,
-                          (uptr->fragment && !(flags & AXIS2_URI_UNP_OMITQUERY))
-                              ? uptr->fragment : NULL,
-                          NULL);
-    }
-    return ret;
-}
-
 /* Here is the hand-optimized parse_uri_components().  There are some wild
  * tricks we could pull in assembly language that we don't pull here... like we
  * can do word-at-time scans for delimiter characters using the same technique
@@ -235,6 +120,209 @@
 #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
 #define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
 
+
+/**
+ * A structure to encompass all of the fields in a uri
+ */
+struct axis2_uri_impl
+{
+    axis2_uri_t uri;
+
+    /** scheme ("http"/"ftp"/...) */
+    axis2_char_t *scheme;
+    /** combined [user[:password]\@]host[:port] */
+    axis2_char_t *hostinfo;
+    /** user name, as in http://user:passwd\@host:port/ */
+    axis2_char_t *user;
+    /** password, as in http://user:passwd\@host:port/ */
+    axis2_char_t *password;
+    /** hostname from URI (or from Host: header) */
+    axis2_char_t *hostname;
+    /** port string (integer representation is in "port") */
+    axis2_char_t *port_str;
+    /** the request path (or "/" if only scheme://host was given) */
+    axis2_char_t *path;
+    /** Everything after a '?' in the path, if present */
+    axis2_char_t *query;
+    /** Trailing "#fragment" string, if present */
+    axis2_char_t *fragment;
+
+    /** structure returned from gethostbyname() */
+    struct hostent *hostent;
+
+    /** The port number, numeric, valid only if port_str != NULL */
+    axis2_port_t port;
+    
+    /** has the structure been initialized */
+    unsigned is_initialized:1;
+
+    /** has the DNS been looked up yet */
+    unsigned dns_looked_up:1;
+    /** has the dns been resolved yet */
+    unsigned dns_resolved:1;
+};
+
+#define AXIS2_INTF_TO_IMPL(uri) ((axis2_uri_impl_t *)(uri))
+
+/***************************** Function headers *******************************/
+
+axis2_status_t AXIS2_CALL 
+axis2_uri_free (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env);
+
+/* Unparse a axis2_uri_t structure to an URI string.
+ * Optionally suppress the password for security reasons.
+ */
+AXIS2_EXTERN axis2_char_t * AXIS2_CALL 
+axis2_uri_to_string(
+        const axis2_uri_t *uri, 
+        const axis2_env_t *env, 
+        unsigned flags);
+
+AXIS2_EXTERN axis2_uri_t *AXIS2_CALL 
+axis2_uri_clone(
+        const axis2_uri_t* uri,
+        const axis2_env_t *env);
+
+axis2_char_t *AXIS2_CALL 
+axis2_uri_get_protocol (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env);
+
+axis2_char_t *AXIS2_CALL 
+axis2_uri_get_server (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env);
+
+axis2_port_t AXIS2_CALL 
+axis2_uri_get_port (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env);
+
+axis2_char_t *AXIS2_CALL 
+axis2_uri_get_path (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env);
+
+/***************************** End of function headers ************************/
+
+AXIS2_EXTERN axis2_uri_t * AXIS2_CALL 
+axis2_uri_create (
+        const axis2_env_t *env)
+{
+    axis2_uri_impl_t *uri_impl = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+   
+    uri_impl =  (axis2_uri_impl_t *)AXIS2_MALLOC (env->allocator, 
+                  sizeof(axis2_uri_impl_t));
+   
+    if(NULL == uri_impl)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+            return NULL;
+    }
+    uri_impl->scheme = NULL;
+    uri_impl->hostinfo = NULL;
+    uri_impl->user = NULL;
+    uri_impl->password = NULL;
+    uri_impl->hostname = NULL;
+    uri_impl->port_str = NULL;
+    uri_impl->path = NULL;
+    uri_impl->query = NULL;
+    uri_impl->fragment = NULL;
+    uri_impl->hostent = NULL;
+
+    uri_impl->uri.ops = AXIS2_MALLOC(env->allocator,sizeof(axis2_uri_ops_t));
+    if(NULL == uri_impl->uri.ops)
+    {
+        axis2_uri_free((axis2_uri_t*)uri_impl, env);
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+    
+    uri_impl->uri.ops->free = axis2_uri_free;
+    uri_impl->uri.ops->get_protocol = axis2_uri_get_protocol;
+    uri_impl->uri.ops->get_server = axis2_uri_get_server;
+    uri_impl->uri.ops->get_port = axis2_uri_get_port;
+    uri_impl->uri.ops->get_path = axis2_uri_get_path;
+    uri_impl->uri.ops->to_string = axis2_uri_to_string;
+    uri_impl->uri.ops->clone = axis2_uri_clone;
+                        
+    return &(uri_impl->uri);
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_uri_free (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env)
+{
+    axis2_uri_impl_t *uri_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    uri_impl = AXIS2_INTF_TO_IMPL(uri);
+
+    if(NULL != uri_impl->scheme)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->scheme);
+        uri_impl->scheme = NULL;
+    }
+
+    if(NULL != uri_impl->hostinfo)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->hostinfo);
+        uri_impl->hostinfo = NULL;
+    }
+
+    if(NULL != uri_impl->user)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->user);
+        uri_impl->user = NULL;
+    }
+
+    if(NULL != uri_impl->password)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->password);
+        uri_impl->password = NULL;
+    }
+
+    if(NULL != uri_impl->hostname)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->hostname);
+        uri_impl->hostname = NULL;
+    }
+
+    if(NULL != uri_impl->port_str)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->port_str);
+        uri_impl->port_str = NULL;
+    }
+
+    if(NULL != uri_impl->path)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->path);
+        uri_impl->path = NULL;
+    }
+
+    if(NULL != uri_impl->query)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->query);
+        uri_impl->query = NULL;
+    }
+
+    if(NULL != uri_impl->fragment)
+    {
+        AXIS2_FREE(env->allocator, uri_impl->fragment);
+        uri_impl->fragment = NULL;
+    }
+
+    if(NULL != uri->ops)
+        AXIS2_FREE(env->allocator, uri->ops);
+    
+    AXIS2_FREE(env->allocator, uri_impl);
+
+   return AXIS2_SUCCESS;
+}
+
 /* parse_uri_components():
  * Parse a given URI, fill in all supplied fields of a uri_components
  * structure. This eliminates the necessity of extracting host, port,
@@ -243,33 +331,30 @@
  *  - fills in fields of uri_components *uptr
  *  - none on any of the r->* fields
  */
+
 AXIS2_EXTERN axis2_uri_t *AXIS2_CALL
 axis2_uri_parse_string(
         const axis2_env_t *env, 
         const axis2_char_t *uri)
 {
-    axis2_uri_t *uptr = NULL;
-
+    axis2_uri_impl_t *uri_impl = NULL;
     const axis2_char_t *s;
     const axis2_char_t *s1;
     const axis2_char_t *hostinfo;
     axis2_char_t *endstr;
     int port;
     int v6_offset1 = 0, v6_offset2 = 0;
-    
-    uptr = AXIS2_MALLOC(env->allocator, sizeof(struct axis2_uri_t));
 
-    if (!uptr)
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_PARAM_CHECK(env->error, uri, NULL);
 
+    uri_impl = (axis2_uri_impl_t *) axis2_uri_create(env);
+    
     /* Initialize the structure. parse_uri() and parse_uri_components()
      * can be called more than once per request.
      */
-    memset (uptr, '\0', sizeof(*uptr));
-    uptr->is_initialized = 1;
+    /*memset (uri_impl, '\0', sizeof(*uri_impl));*/
+    uri_impl->is_initialized = 1;
 
     /* We assume the processor has a branch predictor like most --
      * it assumes forward branches are untaken and backwards are taken.  That's
@@ -303,29 +388,30 @@
         }
         if (s != uri) 
         {
-            uptr->path = AXIS2_STRMEMDUP(uri, s - uri, env);
+            uri_impl->path = AXIS2_STRMEMDUP(uri, s - uri, env);
         }
         if (*s == 0) 
         {
-            return uptr;
+            return &(uri_impl->uri);
         }
         if (*s == '?') 
         {
             ++s;
             s1 = strchr(s, '#');
             if (s1) {
-                uptr->fragment = AXIS2_STRDUP(s1 + 1, env);
-                uptr->query = AXIS2_STRMEMDUP(s, s1 - s, env);
+                uri_impl->fragment = AXIS2_STRDUP(s1 + 1, env);
+                uri_impl->query = AXIS2_STRMEMDUP(s, s1 - s, env);
             }
             else 
             {
-                uptr->query = AXIS2_STRDUP(s, env);
+                uri_impl->query = AXIS2_STRDUP(s, env);
             }
-            return uptr;
+            return &(uri_impl->uri);
         }
         /* otherwise it's a fragment */
-        uptr->fragment = AXIS2_STRDUP(s + 1, env);
-        return uptr;
+        uri_impl->fragment = AXIS2_STRDUP(s + 1, env);
+
+        return &(uri_impl->uri);
     }
 
     /* find the scheme: */
@@ -340,7 +426,7 @@
         goto deal_with_path;        /* backwards predicted taken! */
     }
 
-    uptr->scheme = AXIS2_STRMEMDUP(uri, s - uri, env);
+    uri_impl->scheme = AXIS2_STRMEMDUP(uri, s - uri, env);
     s += 3;
 
 deal_with_authority:
@@ -350,7 +436,7 @@
         ++s;
     }
     uri = s;        /* whatever follows hostinfo is start of uri */
-    uptr->hostinfo = AXIS2_STRMEMDUP(hostinfo, uri - hostinfo, env);
+    uri_impl->hostinfo = AXIS2_STRMEMDUP(hostinfo, uri - hostinfo, env);
 
     /* If there's a username:password@host:port, the @ we want is the last @...
      * too bad there's no memrchr()... For the C purists, note that hostinfo
@@ -387,27 +473,27 @@
         }
         if (s == NULL) {
             /* we expect the common case to have no port */
-            uptr->hostname = AXIS2_STRMEMDUP(
+            uri_impl->hostname = AXIS2_STRMEMDUP(
                                             hostinfo + v6_offset1,
                                             uri - hostinfo - v6_offset2, env);
             goto deal_with_path;
         }
-        uptr->hostname = AXIS2_STRMEMDUP(
+        uri_impl->hostname = AXIS2_STRMEMDUP(
                                         hostinfo + v6_offset1,
                                         s - hostinfo - v6_offset2, env);
         ++s;
-        uptr->port_str = AXIS2_STRMEMDUP(s, uri - s, env);
+        uri_impl->port_str = AXIS2_STRMEMDUP(s, uri - s, env);
         if (uri != s) 
         {
-            port = strtol(uptr->port_str, &endstr, 10);
-            uptr->port = port;
+            port = strtol(uri_impl->port_str, &endstr, 10);
+            uri_impl->port = port;
             if (*endstr == '\0') {
                 goto deal_with_path;
             }
             /* Invalid characters after ':' found */
             return AXIS2_FAILURE;
         }
-        uptr->port = axis2_uri_port_of_scheme(uptr->scheme);
+        uri_impl->port = axis2_uri_port_of_scheme(uri_impl->scheme);
         goto deal_with_path;
     }
 
@@ -415,17 +501,18 @@
     s1 = AXIS2_MEMCHR(hostinfo, ':', s - hostinfo);
     if (s1) 
     {
-        uptr->user = AXIS2_STRMEMDUP(hostinfo, s1 - hostinfo, env);
+        uri_impl->user = AXIS2_STRMEMDUP(hostinfo, s1 - hostinfo, env);
         ++s1;
-        uptr->password = AXIS2_STRMEMDUP(s1, s - s1, env);
+        uri_impl->password = AXIS2_STRMEMDUP(s1, s - s1, env);
     }
     else 
     {
-        uptr->user = AXIS2_STRMEMDUP(hostinfo, s - hostinfo, env);
+        uri_impl->user = AXIS2_STRMEMDUP(hostinfo, s - hostinfo, env);
     }
     hostinfo = s + 1;
     goto deal_with_host;
-    return uptr;
+
+    return &(uri_impl->uri);
 }
 
 /* Special case for CONNECT parsing: it comes with the hostinfo part only */
@@ -438,20 +525,23 @@
         const axis2_env_t *env, 
         const axis2_char_t *hostinfo)
 {
-    axis2_uri_t *uptr = NULL;
+    axis2_uri_impl_t *uri_impl = NULL;
     const axis2_char_t *s;
     axis2_char_t *endstr;
     const axis2_char_t *rsb;
     int v6_offset1 = 0;
 
-    uptr = AXIS2_MALLOC(env->allocator, sizeof(struct axis2_uri_t));
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_PARAM_CHECK(env->error, hostinfo, NULL);
+
+    uri_impl = (axis2_uri_impl_t *) axis2_uri_create(env);
     
     /* Initialize the structure. parse_uri() and parse_uri_components()
      * can be called more than once per request.
      */
-    memset(uptr, '\0', sizeof(*uptr));
-    uptr->is_initialized = 1;
-    uptr->hostinfo = AXIS2_STRDUP(hostinfo, env);
+    memset(uri_impl, '\0', sizeof(*uri_impl));
+    uri_impl->is_initialized = 1;
+    uri_impl->hostinfo = AXIS2_STRDUP(hostinfo, env);
 
     /* We expect hostinfo to point to the first character of
      * the hostname.  There must be a port, separated by a colon
@@ -475,15 +565,15 @@
     {
         return NULL;
     }
-    uptr->hostname = AXIS2_STRNDUP(hostinfo, s - hostinfo - v6_offset1, env);
+    uri_impl->hostname = AXIS2_STRNDUP(hostinfo, s - hostinfo - v6_offset1, env);
     ++s;
-    uptr->port_str = AXIS2_STRDUP(s, env);
+    uri_impl->port_str = AXIS2_STRDUP(s, env);
     if (*s != '\0') 
     {
-        uptr->port = (unsigned short) strtol(uptr->port_str, &endstr, 10);
+        uri_impl->port = (unsigned short) strtol(uri_impl->port_str, &endstr, 10);
         if (*endstr == '\0') 
         {
-            return uptr;
+            return &(uri_impl->uri);
         }
         /* Invalid characters after ':' found */
     }
@@ -495,34 +585,43 @@
 axis2_uri_resolve_relative(
         const axis2_env_t *env,
         const axis2_uri_t* base,
-        axis2_uri_t* uptr)
+        axis2_uri_t* uri)
 {
-    if ( uptr == NULL || base == NULL || ! base->is_initialized
-               || ! uptr->is_initialized ) 
+    axis2_uri_impl_t *uri_impl = NULL;
+    axis2_uri_impl_t *base_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_PARAM_CHECK(env->error, base, NULL);
+    AXIS2_PARAM_CHECK(env->error, uri, NULL);
+    uri_impl = AXIS2_INTF_TO_IMPL(uri);
+    base_impl = AXIS2_INTF_TO_IMPL(base);
+
+    if ( uri_impl == NULL || base_impl == NULL || ! base_impl->is_initialized
+               || ! uri_impl->is_initialized ) 
     {
         return NULL;
     }
     /* The interesting bit is the path.  */
-    if ( uptr->path == NULL ) 
+    if ( uri_impl->path == NULL ) 
     {
-        if ( uptr->hostname == NULL ) 
+        if ( uri_impl->hostname == NULL ) 
         {
             /* is this compatible with is_initialised?  Harmless in any case */
-            uptr->path = base->path ? base->path : AXIS2_STRDUP("/", env) ;
+            uri_impl->path = base_impl->path ? base_impl->path : AXIS2_STRDUP("/", env) ;
         }
         else 
         {
             /* deal with the idiosyncracy of APR allowing path==NULL
              * without risk of breaking back-compatibility
              */
-             uptr->path = AXIS2_STRDUP("/", env) ;
+             uri_impl->path = AXIS2_STRDUP("/", env) ;
         }
     }
-    else if ( uptr->path[0] != '/' ) 
+    else if ( uri_impl->path[0] != '/' ) 
     {
         size_t baselen ;
-        const char* basepath = base->path ? base->path :"/" ;
-        const char* path = uptr->path ;
+        const char* basepath = base_impl->path ? base_impl->path :"/" ;
+        const char* path = uri_impl->path ;
         const char* base_end = strrchr(basepath, '/') ;
 
         /* if base is nonsensical, bail out */
@@ -548,46 +647,46 @@
               path += 2 ;
         }
         baselen = base_end-basepath+1 ;
-        uptr->path = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * baselen + strlen(path) + 1 ) ;
-        memcpy(uptr->path, basepath, baselen) ;
-        strcpy(uptr->path+baselen, path) ;
+        uri_impl->path = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * baselen + strlen(path) + 1 ) ;
+        memcpy(uri_impl->path, basepath, baselen) ;
+        strcpy(uri_impl->path+baselen, path) ;
     }
         
     /* The trivial bits are everything-but-path */
-    if ( uptr->scheme == NULL ) 
+    if ( uri_impl->scheme == NULL ) 
     {
-        uptr->scheme = base->scheme ;
+        uri_impl->scheme = base_impl->scheme ;
     }
-    if ( uptr->hostinfo == NULL ) 
+    if ( uri_impl->hostinfo == NULL ) 
     {
-        uptr->hostinfo = base->hostinfo ;
+        uri_impl->hostinfo = base_impl->hostinfo ;
     }
-    if ( uptr->user == NULL ) 
+    if ( uri_impl->user == NULL ) 
     {
-        uptr->user = base->user ;
+        uri_impl->user = base_impl->user ;
     }
-    if ( uptr->password == NULL ) 
+    if ( uri_impl->password == NULL ) 
     {
-        uptr->password = base->password ;
+        uri_impl->password = base_impl->password ;
     }
-    if ( uptr->hostname == NULL ) 
+    if ( uri_impl->hostname == NULL ) 
     {
-        uptr->hostname = base->hostname ;
+        uri_impl->hostname = base_impl->hostname ;
     } 
-    if ( uptr->port_str == NULL ) 
+    if ( uri_impl->port_str == NULL ) 
     {
-        uptr->port_str = base->port_str ;
+        uri_impl->port_str = base_impl->port_str ;
     }
-    if ( uptr->hostent == NULL ) 
+    if ( uri_impl->hostent == NULL ) 
     {
-        uptr->hostent = base->hostent ;
+        uri_impl->hostent = base_impl->hostent ;
     }
-    if ( ! uptr->port ) 
+    if ( ! uri_impl->port ) 
     {
-        uptr->port = base->port ;
+        uri_impl->port = base_impl->port ;
     }
     
-    return uptr ;
+    return &(uri_impl->uri);
 }
 
 AXIS2_EXTERN axis2_uri_t *AXIS2_CALL 
@@ -606,5 +705,191 @@
     uptr = axis2_uri_resolve_relative(env, base, uptr) ;
 
     return uptr;
+}
+AXIS2_EXTERN axis2_port_t AXIS2_CALL 
+axis2_uri_port_of_scheme(
+        const axis2_char_t *scheme_str)
+{
+    schemes_t *scheme;
+
+    if (scheme_str) 
+    {
+        for (scheme = schemes; scheme->name != NULL; ++scheme) 
+        {
+            if (AXIS2_STRCASECMP(scheme_str, scheme->name) == 0) 
+            {
+                return scheme->default_port;
+            }
+        }
+    }
+    return 0;
+}
+
+AXIS2_EXTERN axis2_uri_t *AXIS2_CALL 
+axis2_uri_clone(
+        const axis2_uri_t* uri,
+        const axis2_env_t *env)
+{
+    axis2_uri_impl_t *uri_impl = NULL;
+    axis2_uri_impl_t *new_uri_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
+    uri_impl = AXIS2_INTF_TO_IMPL(uri);
+    new_uri_impl = (axis2_uri_impl_t *) axis2_uri_create(env);
+
+    new_uri_impl->scheme = AXIS2_STRDUP(uri_impl->scheme, env);
+    new_uri_impl->hostinfo = AXIS2_STRDUP(uri_impl->hostinfo, env);
+    new_uri_impl->user = AXIS2_STRDUP(uri_impl->user, env);
+    new_uri_impl->password = AXIS2_STRDUP(uri_impl->password, env);
+    new_uri_impl->hostname = AXIS2_STRDUP(uri_impl->hostname, env);
+    new_uri_impl->port_str = AXIS2_STRDUP(uri_impl->port_str, env);
+    new_uri_impl->path = AXIS2_STRDUP(uri_impl->path, env);
+    new_uri_impl->query = AXIS2_STRDUP(uri_impl->query, env);
+    new_uri_impl->fragment = AXIS2_STRDUP(uri_impl->fragment, env);
+    new_uri_impl->hostent = uri_impl->hostent;
+    new_uri_impl->port = uri_impl->port;
+    new_uri_impl->is_initialized = uri_impl->is_initialized;
+    new_uri_impl->dns_looked_up = uri_impl->dns_looked_up;
+    new_uri_impl->dns_resolved = uri_impl->dns_resolved;
+
+    return &(new_uri_impl->uri);
+}
+
+/* Unparse a axis2_uri_t structure to an URI string.
+ * Optionally suppress the password for security reasons.
+ */
+AXIS2_EXTERN axis2_char_t * AXIS2_CALL 
+axis2_uri_to_string(
+        const axis2_uri_t *uri, 
+        const axis2_env_t *env, 
+        unsigned flags)
+{
+    axis2_uri_impl_t *uri_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
+    uri_impl = AXIS2_INTF_TO_IMPL(uri);
+
+    axis2_char_t *ret = "";
+
+    /* If suppressing the site part, omit both user name & scheme://hostname */
+    if (!(flags & AXIS2_URI_UNP_OMITSITEPART)) 
+    {
+
+        /* Construct a "user:password@" string, honoring the passed
+         * AXIS2_URI_UNP_ flags: */
+        if (uri_impl->user || uri_impl->password) 
+        {
+            ret = axis2_strcat(env,
+                  (uri_impl->user     && !(flags & AXIS2_URI_UNP_OMITUSER))
+                      ? uri_impl->user : "",
+                  (uri_impl->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD))
+                      ? ":" : "",
+                  (uri_impl->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD))
+                      ? ((flags & AXIS2_URI_UNP_REVEALPASSWORD)
+                          ? uri_impl->password : "XXXXXXXX")
+                      : "",
+                  ((uri_impl->user     && !(flags & AXIS2_URI_UNP_OMITUSER)) ||
+                   (uri_impl->password && !(flags & AXIS2_URI_UNP_OMITPASSWORD)))
+                      ? "@" : "", 
+                  NULL);
+        }
+
+        /* Construct scheme://site string */
+        if (uri_impl->hostname) 
+        {
+            int is_default_port;
+            const axis2_char_t *lbrk = "", *rbrk = "";
+
+            if (strchr(uri_impl->hostname, ':')) 
+            { /* v6 literal */
+                lbrk = "[";
+                rbrk = "]";
+            }
+
+            is_default_port =
+                (uri_impl->port_str == NULL ||
+                 uri_impl->port == 0 ||
+                 uri_impl->port == axis2_uri_port_of_scheme(uri_impl->scheme));
+
+            if (uri_impl->scheme) 
+            {
+                ret = axis2_strcat(env,
+                              uri_impl->scheme, "://", ret,
+                              lbrk, uri_impl->hostname, rbrk,
+                              is_default_port ? "" : ":",
+                              is_default_port ? "" : uri_impl->port_str,
+                              NULL);
+            }
+            else 
+            {
+                /* A violation of RFC2396, but it is clear from section 3.2
+                 * that the : belongs above to the scheme, while // belongs
+                 * to the authority, so include the authority prefix while
+                 * omitting the "scheme:" that the user neglected to pass us.
+                 */
+                ret = axis2_strcat(env,
+                              "//", ret, lbrk, uri_impl->hostname, rbrk,
+                              is_default_port ? "" : ":",
+                              is_default_port ? "" : uri_impl->port_str,
+                              NULL);
+            }
+        }
+    }
+
+    /* Should we suppress all path info? */
+    if (!(flags & AXIS2_URI_UNP_OMITPATHINFO)) 
+    {
+        /* Append path, query and fragment strings: */
+        ret = axis2_strcat(env,
+                ret,
+              (uri_impl->path)
+                  ? uri_impl->path : "",
+              (uri_impl->query    && !(flags & AXIS2_URI_UNP_OMITQUERY))
+                  ? "?" : "",
+              (uri_impl->query    && !(flags & AXIS2_URI_UNP_OMITQUERY))
+                  ? uri_impl->query : "",
+              (uri_impl->fragment && !(flags & AXIS2_URI_UNP_OMITQUERY))
+                  ? "#" : NULL,
+              (uri_impl->fragment && !(flags & AXIS2_URI_UNP_OMITQUERY))
+                  ? uri_impl->fragment : NULL,
+              NULL);
+    }
+    return ret;
+}
+
+axis2_char_t *AXIS2_CALL 
+axis2_uri_get_protocol (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    return AXIS2_INTF_TO_IMPL(uri)->scheme;
+}
+
+axis2_char_t *AXIS2_CALL 
+axis2_uri_get_server (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    return AXIS2_INTF_TO_IMPL(uri)->hostinfo;
+}
+
+axis2_port_t AXIS2_CALL 
+axis2_uri_get_port (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_CRTICAL_FAILURE);
+    return AXIS2_INTF_TO_IMPL(uri)->port;
+}
+
+axis2_char_t *AXIS2_CALL 
+axis2_uri_get_path (
+        axis2_uri_t *uri, 
+        const axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+    return AXIS2_INTF_TO_IMPL(uri)->path;
 }
 

Modified: webservices/axis2/trunk/c/util/test/unit/util/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/test/unit/util/Makefile.am?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/test/unit/util/Makefile.am (original)
+++ webservices/axis2/trunk/c/util/test/unit/util/Makefile.am Wed Jun  7 03:34:01 2006
@@ -1,8 +1,8 @@
-TESTS =  util_test
-prgbindir=$(prefix)/bin/unit_test
+TESTS = util_test
 prglibdir=$(prefix)/lib/unit_test
+prgbindir=$(prefix)/bin/unit_test
+noinst_HEADERS = $(top_builddir)/test/unit/util/*.h
 prglib_LTLIBRARIES = libtest_util.la
-
 libtest_util_la_SOURCES = \
 						  	util_hash_test.c \
                             util_stream_test.c \
@@ -17,21 +17,18 @@
                             util_url_test.c \
                             util_uri_test.c
 
-noinst_HEADERS=$(top_builddir)/test/unit/util/*.h
-
 INCLUDES = -I$(top_builddir)/include \
             -I${CUTEST_HOME}/include \
-            -I$(top_builddir)/src \
-            -I$(top_builddir)/src/platforms
+            -I$(top_builddir)/src/util \
+			@UTILINC@ 
 
-prgbin_PROGRAMS = util_test
 check_PROGRAMS = util_test
+prgbin_PROGRAMS = util_test
 util_test_SOURCES = main.c
-util_test_LDADD   =   libtest_util.la \
-                     -L$(CUTEST_HOME)/lib \
-                     -lcutest \
-                    -lpthread \
-                    $(top_builddir)/src/libaxis2_util.la \
-                    $(GUTHTHILA_LIBS) \
-                    $(LIBXML2_LIBS)
-
+util_test_LDADD   =   libtest_util.la  \
+                    -L$(CUTEST_HOME)/lib \
+                    -lcutest \
+					$(top_builddir)/src/libaxis2_util.la \
+                    $(LIBXML2_LIBS) \
+                    $(GUTHTHILA_LIBS)
+                    

Modified: webservices/axis2/trunk/c/util/test/unit/util/util_test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/test/unit/util/util_test.c?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/test/unit/util/util_test.c (original)
+++ webservices/axis2/trunk/c/util/test/unit/util/util_test.c Wed Jun  7 03:34:01 2006
@@ -21,6 +21,7 @@
     SUITE_ADD_TEST(suite, Testaxis2_url_parse_string);
     SUITE_ADD_TEST(suite, Testaxis2_uri_parse_string);
     SUITE_ADD_TEST(suite, Testaxis2_uri_parse_relative);
+    SUITE_ADD_TEST(suite, Testaxis2_uri_clone);
     /* Samisa - need to remove this as we run make check before make install
     SUITE_ADD_TEST(suite, Testaxis2_dir_handler_list_dir); */
     return suite;

Modified: webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.c?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.c (original)
+++ webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.c Wed Jun  7 03:34:01 2006
@@ -7,7 +7,7 @@
 void Testaxis2_uri_parse_string(CuTest *tc)
 {
     axis2_char_t *actual = NULL;
-    axis2_char_t *expected = "/home/damitha/temp/checkout.sh";
+    axis2_char_t *expected = "temp/checkout.sh";
     axis2_uri_t *uri = NULL;
     axis2_char_t *uri_str = NULL;
 
@@ -20,20 +20,15 @@
     /*uri_str = "http://myserver:80/home/damitha/temp/checkout.sh";*/
     /*uri_str = "../temp/checkout.sh";*/
     uri_str = "temp/checkout.sh";
-    printf("came1\n");
     uri = axis2_uri_parse_string(env, uri_str);
     CuAssertPtrNotNull(tc, uri);
-    if(uri->ops)
-        printf("came11\n");
-    CuAssertPtrNotNull(tc, uri->ops);
-    printf("came2\n");
 
-    actual = AXIS2_URI_TO_STRING(uri, env, AXIS2_URI_UNP_OMITSITEPART);
-    printf("came3\n");
+    actual = AXIS2_URI_TO_STRING(uri, env, AXIS2_URI_UNP_OMITUSERINFO);
    
     printf("actual:%s\n", actual);
     
     CuAssertStrEquals(tc, expected, actual);
+    AXIS2_URI_FREE(uri, env);
 }
 
 void Testaxis2_uri_parse_relative(CuTest *tc)
@@ -55,10 +50,39 @@
     uri_str = "../../temp/checkout.sh";
     base = axis2_uri_parse_string(env, base_str);
     new_uri = axis2_uri_parse_relative(env, base, uri_str);
-    actual = AXIS2_URI_TO_STRING(new_uri, env, AXIS2_URI_UNP_OMITPASSWORD);
+    actual = AXIS2_URI_TO_STRING(new_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
    
     printf("actual:%s\n", actual);
     
     CuAssertStrEquals(tc, expected, actual);
+    AXIS2_URI_FREE(new_uri, env);
+}
+
+void Testaxis2_uri_clone(CuTest *tc)
+{
+    axis2_char_t *actual = NULL;
+    axis2_char_t *expected = "http://myserver/home/damitha/temp";
+    axis2_uri_t *uri = NULL;
+    axis2_uri_t *new_uri = NULL;
+    axis2_char_t *uri_str = NULL;
+
+    printf("******************************************\n");
+    printf("testing axis2_uri_clone\n");
+    printf("******************************************\n");
+    axis2_allocator_t *allocator = axis2_allocator_init (NULL);
+    const axis2_env_t *env = axis2_env_create (allocator);
+
+    uri_str = "http://myserver:80/home/damitha/temp";
+    uri = axis2_uri_parse_string(env, uri_str);
+    new_uri = AXIS2_URI_CLONE(uri, env);
+    CuAssertPtrNotNull(tc, new_uri);
+
+    actual = AXIS2_URI_TO_STRING(new_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
+   
+    printf("actual:%s\n", actual);
+    
+    CuAssertStrEquals(tc, expected, actual);
+    AXIS2_URI_FREE(uri, env);
+
 }
 

Modified: webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.h?rev=412360&r1=412359&r2=412360&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.h (original)
+++ webservices/axis2/trunk/c/util/test/unit/util/util_uri_test.h Wed Jun  7 03:34:01 2006
@@ -8,4 +8,6 @@
 
 void Testaxis2_uri_parse_relative(CuTest *tc);
 
+void Testaxis2_uri_clone(CuTest *tc);
+
 #endif /* UTIL_URI_TEST_H*/



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org