axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@apache.org
Subject svn commit: r439280 - in /webservices/axis2/trunk/c/util: include/axis2_date_time.h include/axis2_string.h src/Makefile.am src/date_time.c src/string.c test/unit/util/Makefile.am test/unit/util/util_test.c test/unit/util/util_test.h
Date Fri, 01 Sep 2006 11:58:01 GMT
Author: nandika
Date: Fri Sep  1 04:58:01 2006
New Revision: 439280

URL: http://svn.apache.org/viewvc?rev=439280&view=rev
Log:
jira issue 231, Thanks to dimuthu  

Modified:
    webservices/axis2/trunk/c/util/include/axis2_date_time.h
    webservices/axis2/trunk/c/util/include/axis2_string.h
    webservices/axis2/trunk/c/util/src/Makefile.am
    webservices/axis2/trunk/c/util/src/date_time.c
    webservices/axis2/trunk/c/util/src/string.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_test.h

Modified: webservices/axis2/trunk/c/util/include/axis2_date_time.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_date_time.h?rev=439280&r1=439279&r2=439280&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_date_time.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_date_time.h Fri Sep  1 04:58:01 2006
@@ -218,7 +218,7 @@
         ((date_time)->ops->free (date_time, env))
 
 #define AXIS2_DATE_TIME_DESERIALIZE_TIME(date_time, env, time ) \
-        ((date_time)->ops->deserialize_time (date_time, env, time_str))
+        ((date_time)->ops->deserialize_time (date_time, env, time))
 
 #define AXIS2_DATE_TIME_DESERIALIZE_DATE(date_time, env, date) \
         ((date_time)->ops->deserialize_date (date_time, env, date_str))

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=439280&r1=439279&r2=439280&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_string.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_string.h Fri Sep  1 04:58:01 2006
@@ -141,6 +141,62 @@
            const axis2_env_t *env,
            const axis2_char_t *_s,
            const axis2_char_t *_trim);
+   
+   /**
+    * replace given axis2_character with a new one.
+    * @param str       string operation apply
+    * @param old_char  the old axis2_character which would be replaced
+    * @param new_char  new axis2_char_tacter
+    * @return      replaced string
+    */
+   AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+   axis2_string_replace(
+           axis2_char_t *str,
+           axis2_char_t old_char,
+           axis2_char_t new_char);
+
+   /**
+    * gives a sub string starting with given index.
+    * @param str       string operation apply
+    * @param c     starting index
+    * @return      substring
+    */
+   AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+   axis2_string_substring_starting_at(
+           axis2_char_t *str,
+           int s );
+   
+   /**
+    * gives a sub string ending with given index.
+    * @param str       string operation apply
+    * @param c     ending index
+    * @return      substring
+    */
+   AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+   axis2_string_substring_ending_at(
+           axis2_char_t *str,
+           int e );
+   
+   /**
+    * set a string to lowercase.
+    * @param str   string
+    * @return string with lowercase
+    */
+   AXIS2_EXTERN axis2_char_t*
+   axis2_string_tolower(
+           axis2_char_t *str );
+    
+   /**
+    * set a string to uppercase.
+    * @param str   string
+    * @return string with uppercase
+    */
+   AXIS2_EXTERN axis2_char_t*
+   axis2_string_toupper(
+           axis2_char_t *str );
+   
+     
+   
 
 #define AXIS2_STRDUP(pts, env) \
         axis2_strdup(pts, env)

Modified: webservices/axis2/trunk/c/util/src/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/Makefile.am?rev=439280&r1=439279&r2=439280&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/Makefile.am (original)
+++ webservices/axis2/trunk/c/util/src/Makefile.am Fri Sep  1 04:58:01 2006
@@ -32,7 +32,8 @@
                         base64.c \
                         uri.c \
                         date_time.c \
-                        base64_binary.c
+                        base64_binary.c \
+                        properties.c 
                         
 libaxis2_util_la_LIBADD =  \
                     $(top_builddir)/src/platforms/unix/libaxis2_unix.la \

Modified: webservices/axis2/trunk/c/util/src/date_time.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/date_time.c?rev=439280&r1=439279&r2=439280&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/date_time.c (original)
+++ webservices/axis2/trunk/c/util/src/date_time.c Fri Sep  1 04:58:01 2006
@@ -28,7 +28,12 @@
 {
     axis2_date_time_t date_time;
     
-    struct tm* utcTime;
+    int year;
+    int mon;
+    int day;
+    int hour;
+    int min;
+    int sec;
 
 } axis2_date_time_impl_t;
 
@@ -105,6 +110,7 @@
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
     time_t now;
+    struct tm* utc_time = NULL;
    
     AXIS2_ENV_CHECK(env, NULL);
 
@@ -118,7 +124,13 @@
     }
     
     now = time (NULL );
-    date_time_impl-> utcTime = gmtime ( &now);
+    utc_time = gmtime ( &now);
+    date_time_impl-> year= utc_time-> tm_year;
+    date_time_impl-> mon= utc_time-> tm_mon;
+    date_time_impl-> day= utc_time-> tm_mday;
+    date_time_impl-> hour= utc_time-> tm_hour;
+    date_time_impl-> min= utc_time-> tm_min;
+    date_time_impl-> sec= utc_time-> tm_sec;
 
     date_time_impl->date_time.ops = 
         AXIS2_MALLOC (env->allocator, sizeof(axis2_date_time_ops_t));
@@ -165,12 +177,6 @@
         AXIS2_FREE(env->allocator, date_time->ops);
         date_time->ops = NULL;
     }
-
-    if(date_time_impl->utcTime)
-    {
-        free ( date_time_impl->utcTime);
-        date_time_impl->utcTime = NULL;
-    }
     
     if(date_time_impl)
     {
@@ -187,15 +193,13 @@
                         const char* time_str)
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    sscanf (time_str, "%d:%d:%dZ" , &time-> tm_hour, &time-> tm_min,
-            &time-> tm_sec );
+    sscanf (time_str, "%d:%d:%dZ" , &date_time_impl-> hour, &date_time_impl->
min,
+            &date_time_impl-> sec );
     return AXIS2_SUCCESS;
 }
 
@@ -205,16 +209,14 @@
                         const char* date_str)
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    sscanf (date_str, "%d-%d-%d" , &time-> tm_year, &time -> tm_mon,
-            &time-> tm_mday );
-    time-> tm_year -= 1900;
+    sscanf (date_str, "%d-%d-%d" , &date_time_impl-> year, &date_time_impl->
mon,
+            &date_time_impl-> day );
+    date_time_impl-> year -= 1900;
     return AXIS2_SUCCESS;
 }
     
@@ -224,17 +226,15 @@
                         const char* date_time_str)
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    sscanf (date_time_str, "%d-%d-%dT%d:%d:%dZ", &time-> tm_year, &time ->
tm_mon,
-            &time-> tm_mday, &time-> tm_hour, &time-> tm_min,
-            &time-> tm_sec );
-    time-> tm_year -= 1900;
+    sscanf (date_time_str, "%d-%d-%dT%d:%d:%dZ", &date_time_impl-> year, &date_time_impl->
mon,
+            &date_time_impl-> day, &date_time_impl-> hour, &date_time_impl->
min,
+            &date_time_impl-> sec );
+    date_time_impl-> year -= 1900;
     return AXIS2_SUCCESS;
 }
     
@@ -245,19 +245,17 @@
                         int hour, int min, int second )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    if ( year > -1 )time-> tm_year = year - 1900;
-    if ( month > -1 )time-> tm_mon = month;
-    if ( day > -1 )time-> tm_mday = day;
-    if ( hour > -1 )time -> tm_hour = hour;
-    if ( min > -1 )time -> tm_min = min;
-    if ( second > -1 )time -> tm_sec = second;
+    if ( year > -1 )date_time_impl-> year = year - 1900;
+    if ( month > -1 )date_time_impl-> mon = month;
+    if ( day > -1 )date_time_impl-> day = day;
+    if ( hour > -1 )date_time_impl-> hour = hour;
+    if ( min > -1 )date_time_impl-> min = min;
+    if ( second > -1 )date_time_impl-> sec = second;
     return AXIS2_SUCCESS;
 }
  
@@ -266,37 +264,34 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     char* time_str = NULL;
     
     AXIS2_ENV_CHECK(env, NULL);
     
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    time_str = malloc ( sizeof (char) * 32 );
+    time_str = (char*)AXIS2_MALLOC( env->allocator, sizeof (char) * 32 );
         
-    sprintf (time_str, "%d:%d:%dZ" , time-> tm_hour, time-> tm_min, time-> tm_sec
);
+    sprintf (time_str, "%d:%d:%dZ" , date_time_impl-> hour, date_time_impl-> min, date_time_impl->
sec );
     return time_str;
 }
+
 char* AXIS2_CALL
 axis2_date_time_serialize_date (axis2_date_time_t *date_time,
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time= NULL;
     char* date_str = NULL;
     
     AXIS2_ENV_CHECK(env, NULL);
     
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    date_str = malloc ( sizeof (char) * 32 );
+    date_str = (char*)AXIS2_MALLOC( env-> allocator, sizeof (char) * 32 );
         
-    sprintf (date_str, "%d-%d-%d" , time-> tm_year + 1900,
-            time -> tm_mon,
-            time-> tm_mday );
+    sprintf (date_str, "%d-%d-%d" , date_time_impl-> year + 1900,
+            date_time_impl-> mon,
+            date_time_impl-> day );
     return date_str;  
 }
 char* AXIS2_CALL
@@ -304,19 +299,17 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     char* date_time_str = NULL;
     
     AXIS2_ENV_CHECK(env, NULL);
     
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    date_time_str = malloc ( sizeof (char) * 32 );
+    date_time_str = AXIS2_MALLOC( env-> allocator, sizeof (char) * 32 );
         
-    sprintf (date_time_str, "%d-%d-%dT%d:%d:%dZ" , time-> tm_year+1900,
-            time -> tm_mon, time-> tm_mday, time-> tm_hour, time-> tm_min,
-            time-> tm_sec );
+    sprintf (date_time_str, "%d-%d-%dT%d:%d:%dZ" , date_time_impl-> year+1900,
+            date_time_impl-> mon, date_time_impl-> day, date_time_impl-> hour, date_time_impl->
min,
+            date_time_impl-> sec );
     return date_time_str;
 }
 
@@ -325,13 +318,11 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    return (time-> tm_year+1900);
+    return (date_time_impl-> year+1900);
 }
 
 int AXIS2_CALL 
@@ -339,13 +330,11 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    return (time-> tm_mon);
+    return (date_time_impl-> mon);
 }
 
 int AXIS2_CALL 
@@ -353,13 +342,11 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    return (time-> tm_mday);
+    return (date_time_impl-> day);
 }
 
 int AXIS2_CALL 
@@ -367,13 +354,11 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    return (time-> tm_hour);
+    return (date_time_impl-> hour);
 }
 
 int AXIS2_CALL 
@@ -381,13 +366,11 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    return (time-> tm_min);
+    return (date_time_impl-> min);
 }
 
 int AXIS2_CALL 
@@ -395,12 +378,10 @@
                         const axis2_env_t *env )
 {
     axis2_date_time_impl_t *date_time_impl = NULL;
-    struct tm* time = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     date_time_impl = AXIS2_INTF_TO_IMPL(date_time);
-    time = date_time_impl->utcTime;
 
-    return (time-> tm_sec);
+    return (date_time_impl-> sec);
 }
 

Modified: webservices/axis2/trunk/c/util/src/string.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/string.c?rev=439280&r1=439279&r2=439280&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/string.c (original)
+++ webservices/axis2/trunk/c/util/src/string.c Fri Sep  1 04:58:01 2006
@@ -369,3 +369,75 @@
     return _q;
 }
 
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_string_replace( axis2_char_t* str, axis2_char_t old, axis2_char_t new )
+{
+    axis2_char_t* str_returns = str;
+    for (  ; *str != '\0' ; str ++ )
+    {
+        if ( *str == old )
+        {
+            *str = new;
+        }
+    }
+    return str_returns;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_string_substring_starting_at( axis2_char_t* str, int s )
+{
+    int len;
+    int pos_to_shift;
+
+    len = strlen ( str );
+    pos_to_shift = len - s +1;
+
+    if ( len <= s )
+    {
+        return NULL;
+    }
+    memmove (str , str + s, pos_to_shift );
+    return str;
+}
+
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_string_substring_ending_at( axis2_char_t* str, int e )
+{
+    axis2_char_t* ptr = NULL;
+    int length = 0;
+
+    length = strlen( str );
+    ptr = str;
+    if( length <=  e )
+    {
+        return NULL;
+    }
+    ptr += e;
+    *ptr = '\0';
+    return str;
+}
+
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_string_tolower( axis2_char_t* str )
+{
+    axis2_char_t* temp_str = NULL;
+    for ( temp_str = str; *temp_str != '\0' ; temp_str ++ )
+    {
+       *temp_str= tolower(*temp_str );
+    }
+    return str;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_string_toupper( axis2_char_t* str )
+{
+    axis2_char_t* temp_str = NULL;
+    for ( temp_str = str; *temp_str != '\0' ; temp_str ++ )
+    {
+       *temp_str= toupper(*temp_str );
+    }
+    return str;
+}
+

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=439280&r1=439279&r2=439280&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/test/unit/util/Makefile.am (original)
+++ webservices/axis2/trunk/c/util/test/unit/util/Makefile.am Fri Sep  1 04:58:01 2006
@@ -15,7 +15,9 @@
                             util_class_loader_test.c \
                             util_string_test.c \
                             util_url_test.c \
-                            util_uri_test.c
+                            util_uri_test.c \
+                            util_properties_test.c \
+                            util_date_time_test.c
 
 INCLUDES = -I$(top_builddir)/include \
             -I${CUTEST_HOME}/include \

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=439280&r1=439279&r2=439280&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 Fri Sep  1 04:58:01 2006
@@ -38,8 +38,11 @@
     SUITE_ADD_TEST(suite, Testaxis2_uri_parse_string);
     SUITE_ADD_TEST(suite, Testaxis2_uri_parse_relative);
     SUITE_ADD_TEST(suite, Testaxis2_uri_clone);
-    SUITE_ADD_TEST(suite, Testaxis2_uri_get_path);
+    SUITE_ADD_TEST(suite, Testaxis2_uri_get_path); 
     /* Samisa - need to remove this as we run make check before make install
     SUITE_ADD_TEST(suite, Testaxis2_dir_handler_list_dir); */
+    SUITE_ADD_TEST(suite, Test_properties); 
+    SUITE_ADD_TEST(suite, Test_date_time); 
+
     return suite;
 }

Modified: webservices/axis2/trunk/c/util/test/unit/util/util_test.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/test/unit/util/util_test.h?rev=439280&r1=439279&r2=439280&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/test/unit/util/util_test.h (original)
+++ webservices/axis2/trunk/c/util/test/unit/util/util_test.h Fri Sep  1 04:58:01 2006
@@ -29,6 +29,8 @@
 #include "util_url_test.h"
 #include "util_string_test.h"
 #include "util_uri_test.h"
+#include "util_properties_test.h"
+#include "util_date_time_test.h"
 
 CuSuite* axis2_utilGetSuite();
 



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


Mime
View raw message