You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ka...@apache.org on 2006/09/11 09:05:16 UTC
svn commit: r442114 - in /webservices/axis2/trunk/c:
rampart/src/util/rampart_util.c util/include/axis2_date_time.h
util/src/date_time.c
Author: kaushalye
Date: Mon Sep 11 00:05:15 2006
New Revision: 442114
URL: http://svn.apache.org/viewvc?view=rev&rev=442114
Log:
Modified the axis2_date_time_* to support generating time structs other than the current time.
Rampart now uses axis2_date_time_* instead of its own implementation.
JIRA AXIS2C-274
Modified:
webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
webservices/axis2/trunk/c/util/include/axis2_date_time.h
webservices/axis2/trunk/c/util/src/date_time.c
Modified: webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_util.c?view=diff&rev=442114&r1=442113&r2=442114
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_util.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_util.c Mon Sep 11 00:05:15 2006
@@ -54,6 +54,7 @@
AXIS2_EXTERN axis2_char_t* AXIS2_CALL rampart_generate_time(const axis2_env_t *env, int ttl)
{
+#if 0
char buffer[SIZE];
time_t curtime;
struct tm *loctime;
@@ -65,6 +66,14 @@
created_str = AXIS2_STRDUP(buffer, env);
return created_str;
+#else
+ axis2_date_time_t *dt = NULL;
+ axis2_char_t *dt_str = NULL;
+
+ dt = axis2_date_time_create_with_offset(env, ttl);
+ dt_str = AXIS2_DATE_TIME_SERIALIZE_DATE_TIME(dt, env);
+ return dt_str;
+#endif
}
/**
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?view=diff&rev=442114&r1=442113&r2=442114
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_date_time.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_date_time.h Mon Sep 11 00:05:15 2006
@@ -212,6 +212,18 @@
AXIS2_EXTERN axis2_date_time_t * AXIS2_CALL
axis2_date_time_create(const axis2_env_t *env );
+/*
+ * Creates axis2_date_time struct with an additional offset value
+ * If the offset is a positive value then the time will be in the future
+ * offset is 0, then the time will be the current time
+ * offset is a negative value then the time is in the past.
+ * @param env double pointer to environment struct. MUST NOT be NULL
+ * @param offset the offset from the current time in seconds
+ * @return pointer to newly created axis2_date_time struct
+ **/
+AXIS2_EXTERN axis2_date_time_t * AXIS2_CALL
+axis2_date_time_create_with_offset (const axis2_env_t *env, int offset);
+
/*************************** Function macros **********************************/
#define AXIS2_DATE_TIME_FREE(date_time, env) \
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?view=diff&rev=442114&r1=442113&r2=442114
==============================================================================
--- webservices/axis2/trunk/c/util/src/date_time.c (original)
+++ webservices/axis2/trunk/c/util/src/date_time.c Mon Sep 11 00:05:15 2006
@@ -105,13 +105,13 @@
/************************** End of function prototypes ************************/
-AXIS2_EXTERN axis2_date_time_t * AXIS2_CALL
-axis2_date_time_create (const axis2_env_t *env)
+AXIS2_EXTERN axis2_date_time_t * AXIS2_CALL
+axis2_date_time_create_with_offset (const axis2_env_t *env, int offset)
{
axis2_date_time_impl_t *date_time_impl = NULL;
- time_t now;
+ time_t t;
struct tm* utc_time = NULL;
-
+
AXIS2_ENV_CHECK(env, NULL);
date_time_impl = (axis2_date_time_impl_t *) AXIS2_MALLOC(env->
@@ -119,12 +119,12 @@
if(NULL == date_time_impl)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
-
- now = time (NULL );
- utc_time = gmtime ( &now);
+
+ t = time (NULL ) + offset;
+ utc_time = gmtime( &t);
date_time_impl-> year= utc_time-> tm_year;
date_time_impl-> mon= utc_time-> tm_mon;
date_time_impl-> day= utc_time-> tm_mday;
@@ -132,7 +132,7 @@
date_time_impl-> min= utc_time-> tm_min;
date_time_impl-> sec= utc_time-> tm_sec;
- date_time_impl->date_time.ops =
+ date_time_impl->date_time.ops =
AXIS2_MALLOC (env->allocator, sizeof(axis2_date_time_ops_t));
if(NULL == date_time_impl->date_time.ops)
{
@@ -140,7 +140,7 @@
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return NULL;
}
-
+
date_time_impl->date_time.ops->free = axis2_date_time_free;
date_time_impl->date_time.ops->deserialize_time = axis2_date_time_deserialize_time;
date_time_impl->date_time.ops->deserialize_date = axis2_date_time_deserialize_date;
@@ -157,6 +157,13 @@
date_time_impl->date_time.ops->get_second = axis2_date_time_get_second;
return &(date_time_impl->date_time);
+}
+
+
+AXIS2_EXTERN axis2_date_time_t * AXIS2_CALL
+axis2_date_time_create (const axis2_env_t *env)
+{
+ return axis2_date_time_create_with_offset(env, 0);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org