diff options
author | hongbotian <hongbo.tianhongbo@huawei.com> | 2015-11-30 01:45:08 -0500 |
---|---|---|
committer | hongbotian <hongbo.tianhongbo@huawei.com> | 2015-11-30 01:45:08 -0500 |
commit | e8ec7aa8e38a93f5b034ac74cebce5de23710317 (patch) | |
tree | aa031937bf856c1f8d6ad7877b8d2cb0224da5ef /rubbos/app/httpd-2.0.64/srclib/apr/time | |
parent | cc40af334e619bb549038238507407866f774f8f (diff) |
upload http
JIRA: BOTTLENECK-10
Change-Id: I7598427ff904df438ce77c2819ee48ac75ffa8da
Signed-off-by: hongbotian <hongbo.tianhongbo@huawei.com>
Diffstat (limited to 'rubbos/app/httpd-2.0.64/srclib/apr/time')
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/time.o | bin | 0 -> 18272 bytes | |||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/timestr.o | bin | 0 -> 13512 bytes | |||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile | 13 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile.in | 13 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.c | 351 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.lo | 12 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.o | bin | 0 -> 18904 bytes | |||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.c | 153 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.lo | 12 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.o | bin | 0 -> 13448 bytes | |||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/win32/access.c | 204 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/win32/time.c | 357 | ||||
-rw-r--r-- | rubbos/app/httpd-2.0.64/srclib/apr/time/win32/timestr.c | 216 |
13 files changed, 1331 insertions, 0 deletions
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/time.o b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/time.o Binary files differnew file mode 100644 index 00000000..316635d7 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/time.o diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/timestr.o b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/timestr.o Binary files differnew file mode 100644 index 00000000..95193180 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/.libs/timestr.o diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile new file mode 100644 index 00000000..80911a61 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile @@ -0,0 +1,13 @@ +srcdir = . + + +TARGETS = time.lo timestr.lo + +# bring in rules.mk for standard functionality +include /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/build/apr_rules.mk + +DEFOSDIR=$(INCDIR)/arch/unix +INCDIR=../../include +INCLUDES=-I$(INCDIR) -I$(DEFOSDIR) + +# DO NOT REMOVE diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile.in new file mode 100644 index 00000000..1cc010b5 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/Makefile.in @@ -0,0 +1,13 @@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +TARGETS = time.lo timestr.lo + +# bring in rules.mk for standard functionality +@INCLUDE_RULES@ + +DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@ +INCDIR=../../include +INCLUDES=-I$(INCDIR) -I$(DEFOSDIR) + +# DO NOT REMOVE diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.c b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.c new file mode 100644 index 00000000..bcfa8195 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.c @@ -0,0 +1,351 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "apr_portable.h" +#include "apr_time.h" +#include "apr_lib.h" +#include "apr_private.h" +#include "apr_strings.h" + +/* private APR headers */ +#include "apr_arch_internal_time.h" + +/* System Headers required for time library */ +#if APR_HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +#if APR_HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_TIME_H +#include <time.h> +#endif +/* End System Headers */ + +#if !defined(HAVE_GMTOFF) && !defined(HAVE___OFFSET) +static apr_int32_t server_gmt_offset; +#endif /* if !defined(HAVE_GMTOFF) && !defined(HAVE___OFFSET) */ + +static apr_int32_t get_offset(struct tm *tm) +{ +#ifdef HAVE_GMTOFF + return tm->tm_gmtoff; +#elif defined(HAVE___OFFSET) + return tm->__tm_gmtoff; +#else +#ifdef NETWARE + /* Need to adjust the global variable each time otherwise + the web server would have to be restarted when daylight + savings changes. + */ + if (daylightOnOff) { + return server_gmt_offset + daylightOffset; + } +#else + if(tm->tm_isdst) + return server_gmt_offset + 3600; +#endif + return server_gmt_offset; +#endif +} + +APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, + time_t input) +{ + *result = (apr_time_t)input * APR_USEC_PER_SEC; + return APR_SUCCESS; +} + +/* NB NB NB NB This returns GMT!!!!!!!!!! */ +APR_DECLARE(apr_time_t) apr_time_now(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec * APR_USEC_PER_SEC + tv.tv_usec; +} + +static void explode_time(apr_time_exp_t *xt, apr_time_t t, + apr_int32_t offset, int use_localtime) +{ + struct tm tm; + time_t tt = (t / APR_USEC_PER_SEC) + offset; + xt->tm_usec = t % APR_USEC_PER_SEC; + +#if APR_HAS_THREADS && defined (_POSIX_THREAD_SAFE_FUNCTIONS) + if (use_localtime) + localtime_r(&tt, &tm); + else + gmtime_r(&tt, &tm); +#else + if (use_localtime) + tm = *localtime(&tt); + else + tm = *gmtime(&tt); +#endif + + xt->tm_sec = tm.tm_sec; + xt->tm_min = tm.tm_min; + xt->tm_hour = tm.tm_hour; + xt->tm_mday = tm.tm_mday; + xt->tm_mon = tm.tm_mon; + xt->tm_year = tm.tm_year; + xt->tm_wday = tm.tm_wday; + xt->tm_yday = tm.tm_yday; + xt->tm_isdst = tm.tm_isdst; + xt->tm_gmtoff = get_offset(&tm); +} + +APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, + apr_time_t input, apr_int32_t offs) +{ + explode_time(result, input, offs, 0); + result->tm_gmtoff = offs; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, + apr_time_t input) +{ + return apr_time_exp_tz(result, input, 0); +} + +APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, + apr_time_t input) +{ +#if defined(__EMX__) + /* EMX gcc (OS/2) has a timezone global we can use */ + return apr_time_exp_tz(result, input, -timezone); +#else + explode_time(result, input, 0, 1); + return APR_SUCCESS; +#endif /* __EMX__ */ +} + +APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt) +{ + apr_time_t year = xt->tm_year; + apr_time_t days; + static const int dayoffset[12] = + {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; + + /* shift new year to 1st March in order to make leap year calc easy */ + + if (xt->tm_mon < 2) + year--; + + /* Find number of days since 1st March 1900 (in the Gregorian calendar). */ + + days = year * 365 + year / 4 - year / 100 + (year / 100 + 3) / 4; + days += dayoffset[xt->tm_mon] + xt->tm_mday - 1; + days -= 25508; /* 1 jan 1970 is 25508 days since 1 mar 1900 */ + days = ((days * 24 + xt->tm_hour) * 60 + xt->tm_min) * 60 + xt->tm_sec; + + if (days < 0) { + return APR_EBADDATE; + } + *t = days * APR_USEC_PER_SEC + xt->tm_usec; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *t, + apr_time_exp_t *xt) +{ + apr_status_t status = apr_time_exp_get(t, xt); + if (status == APR_SUCCESS) + *t -= (apr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; + return status; +} + +APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, + apr_time_t *aprtime) +{ + (*ostime)->tv_usec = *aprtime % APR_USEC_PER_SEC; + (*ostime)->tv_sec = *aprtime / APR_USEC_PER_SEC; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, + apr_time_exp_t *aprtime) +{ + (*ostime)->tm_sec = aprtime->tm_sec; + (*ostime)->tm_min = aprtime->tm_min; + (*ostime)->tm_hour = aprtime->tm_hour; + (*ostime)->tm_mday = aprtime->tm_mday; + (*ostime)->tm_mon = aprtime->tm_mon; + (*ostime)->tm_year = aprtime->tm_year; + (*ostime)->tm_wday = aprtime->tm_wday; + (*ostime)->tm_yday = aprtime->tm_yday; + (*ostime)->tm_isdst = aprtime->tm_isdst; + +#if HAVE_GMTOFF + (*ostime)->tm_gmtoff = aprtime->tm_gmtoff; +#elif defined(HAVE__OFFSET) + (*ostime)->__tm_gmtoff = aprtime->tm_gmtoff; +#endif + + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, + apr_os_imp_time_t **ostime, + apr_pool_t *cont) +{ + *aprtime = (*ostime)->tv_sec * APR_USEC_PER_SEC + (*ostime)->tv_usec; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, + apr_os_exp_time_t **ostime, + apr_pool_t *cont) +{ + aprtime->tm_sec = (*ostime)->tm_sec; + aprtime->tm_min = (*ostime)->tm_min; + aprtime->tm_hour = (*ostime)->tm_hour; + aprtime->tm_mday = (*ostime)->tm_mday; + aprtime->tm_mon = (*ostime)->tm_mon; + aprtime->tm_year = (*ostime)->tm_year; + aprtime->tm_wday = (*ostime)->tm_wday; + aprtime->tm_yday = (*ostime)->tm_yday; + aprtime->tm_isdst = (*ostime)->tm_isdst; + +#if HAVE_GMTOFF + aprtime->tm_gmtoff = (*ostime)->tm_gmtoff; +#elif defined(HAVE__OFFSET) + aprtime->tm_gmtoff = (*ostime)->__tm_gmtoff; +#endif + + return APR_SUCCESS; +} + +APR_DECLARE(void) apr_sleep(apr_interval_time_t t) +{ +#ifdef OS2 + DosSleep(t/1000); +#elif defined(BEOS) + snooze(t); +#elif defined(NETWARE) + delay(t/1000); +#else + struct timeval tv; + tv.tv_usec = t % APR_USEC_PER_SEC; + tv.tv_sec = t / APR_USEC_PER_SEC; + select(0, NULL, NULL, NULL, &tv); +#endif +} + +#ifdef OS2 +APR_DECLARE(apr_status_t) apr_os2_time_to_apr_time(apr_time_t *result, + FDATE os2date, + FTIME os2time) +{ + struct tm tmpdate; + + memset(&tmpdate, 0, sizeof(tmpdate)); + tmpdate.tm_hour = os2time.hours; + tmpdate.tm_min = os2time.minutes; + tmpdate.tm_sec = os2time.twosecs * 2; + + tmpdate.tm_mday = os2date.day; + tmpdate.tm_mon = os2date.month - 1; + tmpdate.tm_year = os2date.year + 80; + tmpdate.tm_isdst = -1; + + *result = mktime(&tmpdate) * APR_USEC_PER_SEC; + return APR_SUCCESS; +} +#endif + +#ifdef NETWARE +APR_DECLARE(void) apr_netware_setup_time(void) +{ + tzset(); + server_gmt_offset = -TZONE; +} +#else +APR_DECLARE(void) apr_unix_setup_time(void) +{ +#if !defined(HAVE_GMTOFF) && !defined(HAVE___OFFSET) + /* Precompute the offset from GMT on systems where it's not + in struct tm. + + Note: This offset is normalized to be independent of daylight + savings time; if the calculation happens to be done in a + time/place where a daylight savings adjustment is in effect, + the returned offset has the same value that it would have + in the same location if daylight savings were not in effect. + The reason for this is that the returned offset can be + applied to a past or future timestamp in explode_time(), + so the DST adjustment obtained from the current time won't + necessarily be applicable. + + mktime() is the inverse of localtime(); so, presumably, + passing in a struct tm made by gmtime() let's us calculate + the true GMT offset. However, there's a catch: if daylight + savings is in effect, gmtime()will set the tm_isdst field + and confuse mktime() into returning a time that's offset + by one hour. In that case, we must adjust the calculated GMT + offset. + + */ + + struct timeval now; + time_t t1, t2; + struct tm t; + + gettimeofday(&now, NULL); + t1 = now.tv_sec; + t2 = 0; + +#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) + gmtime_r(&t1, &t); +#else + t = *gmtime(&t1); +#endif + t.tm_isdst = 0; /* we know this GMT time isn't daylight-savings */ + t2 = mktime(&t); + server_gmt_offset = (apr_int32_t) difftime(t1, t2); +#endif +} + +#endif + +/* A noop on all known Unix implementations */ +APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) +{ + return; +} + +/* Deprecated */ +APR_DECLARE(apr_status_t) apr_explode_time(apr_time_exp_t *result, + apr_time_t input, + apr_int32_t offs) +{ + return apr_time_exp_tz(result, input, offs); +} + +/* Deprecated */ +APR_DECLARE(apr_status_t) apr_explode_localtime(apr_time_exp_t *result, + apr_time_t input) +{ + return apr_time_exp_lt(result, input); +} + +/* Deprecated */ +APR_DECLARE(apr_status_t) apr_implode_gmt(apr_time_t *t, apr_time_exp_t *xt) +{ + return apr_time_exp_gmt_get(t, xt); +} + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.lo b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.lo new file mode 100644 index 00000000..74d7a1e1 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.lo @@ -0,0 +1,12 @@ +# time.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/time.o' + +# Name of the non-PIC object. +non_pic_object='time.o' + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.o b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.o Binary files differnew file mode 100644 index 00000000..1e407ae2 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/time.o diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.c b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.c new file mode 100644 index 00000000..14f27b7e --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.c @@ -0,0 +1,153 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "apr_portable.h" +#include "apr_time.h" +#include "apr_lib.h" +#include "apr_private.h" +/* System Headers required for time library */ +#if APR_HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +#ifdef HAVE_TIME_H +#include <time.h> +#endif +#if APR_HAVE_STRING_H +#include <string.h> +#endif +/* End System Headers */ + +APR_DECLARE_DATA const char apr_month_snames[12][4] = +{ + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; +APR_DECLARE_DATA const char apr_day_snames[7][4] = +{ + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; + +apr_status_t apr_rfc822_date(char *date_str, apr_time_t t) +{ + apr_time_exp_t xt; + const char *s; + int real_year; + + apr_time_exp_gmt(&xt, t); + + /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */ + /* 12345678901234567890123456789 */ + + s = &apr_day_snames[xt.tm_wday][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ','; + *date_str++ = ' '; + *date_str++ = xt.tm_mday / 10 + '0'; + *date_str++ = xt.tm_mday % 10 + '0'; + *date_str++ = ' '; + s = &apr_month_snames[xt.tm_mon][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ' '; + real_year = 1900 + xt.tm_year; + /* This routine isn't y10k ready. */ + *date_str++ = real_year / 1000 + '0'; + *date_str++ = real_year % 1000 / 100 + '0'; + *date_str++ = real_year % 100 / 10 + '0'; + *date_str++ = real_year % 10 + '0'; + *date_str++ = ' '; + *date_str++ = xt.tm_hour / 10 + '0'; + *date_str++ = xt.tm_hour % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_min / 10 + '0'; + *date_str++ = xt.tm_min % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_sec / 10 + '0'; + *date_str++ = xt.tm_sec % 10 + '0'; + *date_str++ = ' '; + *date_str++ = 'G'; + *date_str++ = 'M'; + *date_str++ = 'T'; + *date_str++ = 0; + return APR_SUCCESS; +} + +apr_status_t apr_ctime(char *date_str, apr_time_t t) +{ + apr_time_exp_t xt; + const char *s; + int real_year; + + /* example: "Wed Jun 30 21:49:08 1993" */ + /* 123456789012345678901234 */ + + apr_time_exp_lt(&xt, t); + s = &apr_day_snames[xt.tm_wday][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ' '; + s = &apr_month_snames[xt.tm_mon][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ' '; + *date_str++ = xt.tm_mday / 10 + '0'; + *date_str++ = xt.tm_mday % 10 + '0'; + *date_str++ = ' '; + *date_str++ = xt.tm_hour / 10 + '0'; + *date_str++ = xt.tm_hour % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_min / 10 + '0'; + *date_str++ = xt.tm_min % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_sec / 10 + '0'; + *date_str++ = xt.tm_sec % 10 + '0'; + *date_str++ = ' '; + real_year = 1900 + xt.tm_year; + *date_str++ = real_year / 1000 + '0'; + *date_str++ = real_year % 1000 / 100 + '0'; + *date_str++ = real_year % 100 / 10 + '0'; + *date_str++ = real_year % 10 + '0'; + *date_str++ = 0; + + return APR_SUCCESS; +} + +apr_status_t apr_strftime(char *s, apr_size_t *retsize, apr_size_t max, + const char *format, apr_time_exp_t *xt) +{ + struct tm tm; + memset(&tm, 0, sizeof tm); + tm.tm_sec = xt->tm_sec; + tm.tm_min = xt->tm_min; + tm.tm_hour = xt->tm_hour; + tm.tm_mday = xt->tm_mday; + tm.tm_mon = xt->tm_mon; + tm.tm_year = xt->tm_year; + tm.tm_wday = xt->tm_wday; + tm.tm_yday = xt->tm_yday; + tm.tm_isdst = xt->tm_isdst; +#if defined(HAVE_GMTOFF) + tm.tm_gmtoff = xt->tm_gmtoff; +#elif defined(HAVE___OFFSET) + tm.__tm_gmtoff = xt->tm_gmtoff; +#endif + (*retsize) = strftime(s, max, format, &tm); + return APR_SUCCESS; +} diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.lo b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.lo new file mode 100644 index 00000000..0af55b22 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.lo @@ -0,0 +1,12 @@ +# timestr.lo - a libtool object file +# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/timestr.o' + +# Name of the non-PIC object. +non_pic_object='timestr.o' + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.o b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.o Binary files differnew file mode 100644 index 00000000..2a0fe3d4 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/unix/timestr.o diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/access.c b/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/access.c new file mode 100644 index 00000000..cd25e2f0 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/access.c @@ -0,0 +1,204 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "win32/apr_arch_atime.h" +#include "apr_time.h" +#include "apr_general.h" +#include "apr_lib.h" + +apr_status_t apr_get_curtime(struct atime_t *time, apr_time_t *rv) +{ + if (time) { + (*rv) = time->currtime; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_get_sec(struct atime_t *time, apr_int32_t *rv) +{ + if (time) { + (*rv) = time->explodedtime->wSecond; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_get_min(struct atime_t *time, apr_int32_t *rv) +{ + if (time) { + (*rv) = time->explodedtime->wMinute; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_get_hour(struct atime_t *time, apr_int32_t *rv) +{ + if (time) { + (*rv) = time->explodedtime->wHour; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_get_mday(struct atime_t *time, apr_int32_t *rv) +{ + if (time) { + (*rv) = time->explodedtime->wDay; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_get_mon(struct atime_t *time, apr_int32_t *rv) +{ + if (time) { + (*rv) = time->explodedtime->wMonth; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_get_year(struct atime_t *time, apr_int32_t *rv) +{ + if (time) { + (*rv) = time->explodedtime->wYear; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_get_wday(struct atime_t *time, apr_int32_t *rv) +{ + if (time) { + (*rv) = time->explodedtime->wDayOfWeek; + return APR_SUCCESS; + } + return APR_ENOTIME; +} + +apr_status_t apr_set_sec(struct atime_t *time, apr_int32_t value) +{ + if (!time) { + return APR_ENOTIME; + } + if (time->explodedtime == NULL) { + time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + sizeof(SYSTEMTIME)); + } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } + time->explodedtime->wSecond = value; + return APR_SUCCESS; +} + +apr_status_t apr_set_min(struct atime_t *time, apr_int32_t value) +{ + if (!time) { + return APR_ENOTIME; + } + if (time->explodedtime == NULL) { + time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + sizeof(SYSTEMTIME)); + } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } + time->explodedtime->wMinute = value; + return APR_SUCCESS; +} + +apr_status_t apr_set_hour(struct atime_t *time, apr_int32_t value) +{ + if (!time) { + return APR_ENOTIME; + } + if (time->explodedtime == NULL) { + time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + sizeof(SYSTEMTIME)); + } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } + time->explodedtime->wHour = value; + return APR_SUCCESS; +} + +apr_status_t apr_set_mday(struct atime_t *time, apr_int32_t value) +{ + if (!time) { + return APR_ENOTIME; + } + if (time->explodedtime == NULL) { + time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + sizeof(SYSTEMTIME)); + } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } + time->explodedtime->wDay = value; + return APR_SUCCESS; +} + +apr_status_t apr_set_mon(struct atime_t *time, apr_int32_t value) +{ + if (!time) { + return APR_ENOTIME; + } + if (time->explodedtime == NULL) { + time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + sizeof(SYSTEMTIME)); + } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } + time->explodedtime->wMonth = value; + return APR_SUCCESS; +} + +apr_status_t apr_set_year(struct atime_t *time, apr_int32_t value) +{ + if (!time) { + return APR_ENOTIME; + } + if (time->explodedtime == NULL) { + time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + sizeof(SYSTEMTIME)); + } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } + time->explodedtime->wYear = value; + return APR_SUCCESS; +} + +apr_status_t apr_set_wday(struct atime_t *time, apr_int32_t value) +{ + if (!time) { + return APR_ENOTIME; + } + if (time->explodedtime == NULL) { + time->explodedtime = (SYSTEMTIME *)apr_pcalloc(time->cntxt, + sizeof(SYSTEMTIME)); + } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } + time->explodedtime->wDayOfWeek = value; + return APR_SUCCESS; +} diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/time.c b/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/time.c new file mode 100644 index 00000000..2711488f --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/time.c @@ -0,0 +1,357 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "win32/apr_arch_atime.h" +#include "apr_time.h" +#include "apr_general.h" +#include "apr_lib.h" +#include "apr_portable.h" +#if APR_HAVE_TIME_H +#include <time.h> +#endif +#if APR_HAVE_ERRNO_H +#include <errno.h> +#endif +#include <string.h> +#include <winbase.h> +#include "apr_arch_misc.h" + +/* Leap year is any year divisible by four, but not by 100 unless also + * divisible by 400 + */ +#define IsLeapYear(y) ((!(y % 4)) ? (((!(y % 400)) && (y % 100)) ? 1 : 0) : 0) + +static DWORD get_local_timezone(TIME_ZONE_INFORMATION **tzresult) +{ + static TIME_ZONE_INFORMATION tz; + static DWORD result; + static int init = 0; + + if (!init) { + result = GetTimeZoneInformation(&tz); + init = 1; + } + + *tzresult = &tz; + return result; +} + +static void SystemTimeToAprExpTime(apr_time_exp_t *xt, SYSTEMTIME *tm) +{ + static const int dayoffset[12] = + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + + /* Note; the caller is responsible for filling in detailed tm_usec, + * tm_gmtoff and tm_isdst data when applicable. + */ + xt->tm_usec = tm->wMilliseconds * 1000; + xt->tm_sec = tm->wSecond; + xt->tm_min = tm->wMinute; + xt->tm_hour = tm->wHour; + xt->tm_mday = tm->wDay; + xt->tm_mon = tm->wMonth - 1; + xt->tm_year = tm->wYear - 1900; + xt->tm_wday = tm->wDayOfWeek; + xt->tm_yday = dayoffset[xt->tm_mon] + (tm->wDay - 1); + xt->tm_isdst = 0; + xt->tm_gmtoff = 0; + + /* If this is a leap year, and we're past the 28th of Feb. (the + * 58th day after Jan. 1), we'll increment our tm_yday by one. + */ + if (IsLeapYear(tm->wYear) && (xt->tm_yday > 58)) + xt->tm_yday++; +} + +APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, + time_t input) +{ + *result = (apr_time_t) input * APR_USEC_PER_SEC; + return APR_SUCCESS; +} + +/* Return micro-seconds since the Unix epoch (jan. 1, 1970) UTC */ +APR_DECLARE(apr_time_t) apr_time_now(void) +{ + LONGLONG aprtime = 0; + FILETIME time; +#ifndef _WIN32_WCE + GetSystemTimeAsFileTime(&time); +#else + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, &time); +#endif + FileTimeToAprTime(&aprtime, &time); + return aprtime; +} + +APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, + apr_time_t input) +{ + FILETIME ft; + SYSTEMTIME st; + AprTimeToFileTime(&ft, input); + FileTimeToSystemTime(&ft, &st); + /* The Platform SDK documents that SYSTEMTIME/FILETIME are + * generally UTC, so no timezone info needed + */ + SystemTimeToAprExpTime(result, &st); + result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, + apr_time_t input, + apr_int32_t offs) +{ + FILETIME ft; + SYSTEMTIME st; + AprTimeToFileTime(&ft, input + (offs * APR_USEC_PER_SEC)); + FileTimeToSystemTime(&ft, &st); + /* The Platform SDK documents that SYSTEMTIME/FILETIME are + * generally UTC, so we will simply note the offs used. + */ + SystemTimeToAprExpTime(result, &st); + result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + result->tm_gmtoff = offs; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, + apr_time_t input) +{ + SYSTEMTIME st; + FILETIME ft, localft; + + AprTimeToFileTime(&ft, input); + +#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE) + IF_WIN_OS_IS_UNICODE + { + TIME_ZONE_INFORMATION *tz; + SYSTEMTIME localst; + apr_time_t localtime; + + get_local_timezone(&tz); + + FileTimeToSystemTime(&ft, &st); + + /* The Platform SDK documents that SYSTEMTIME/FILETIME are + * generally UTC. We use SystemTimeToTzSpecificLocalTime + * because FileTimeToLocalFileFime is documented that the + * resulting time local file time would have DST relative + * to the *present* date, not the date converted. + */ + SystemTimeToTzSpecificLocalTime(tz, &st, &localst); + SystemTimeToAprExpTime(result, &localst); + result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + + + /* Recover the resulting time as an apr time and use the + * delta for gmtoff in seconds (and ignore msec rounding) + */ + SystemTimeToFileTime(&localst, &localft); + FileTimeToAprTime(&localtime, &localft); + result->tm_gmtoff = (int)apr_time_sec(localtime) + - (int)apr_time_sec(input); + + /* To compute the dst flag, we compare the expected + * local (standard) timezone bias to the delta. + * [Note, in war time or double daylight time the + * resulting tm_isdst is, desireably, 2 hours] + */ + result->tm_isdst = (result->tm_gmtoff / 3600) + - (-(tz->Bias + tz->StandardBias) / 60); + } +#endif +#if APR_HAS_ANSI_FS || defined(_WIN32_WCE) + ELSE_WIN_OS_IS_ANSI + { + TIME_ZONE_INFORMATION tz; + /* XXX: This code is simply *wrong*. The time converted will always + * map to the *now current* status of daylight savings time. + */ + + FileTimeToLocalFileTime(&ft, &localft); + FileTimeToSystemTime(&localft, &st); + SystemTimeToAprExpTime(result, &st); + result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC); + + switch (GetTimeZoneInformation(&tz)) { + case TIME_ZONE_ID_UNKNOWN: + result->tm_isdst = 0; + /* Bias = UTC - local time in minutes + * tm_gmtoff is seconds east of UTC + */ + result->tm_gmtoff = tz.Bias * -60; + break; + case TIME_ZONE_ID_STANDARD: + result->tm_isdst = 0; + result->tm_gmtoff = (tz.Bias + tz.StandardBias) * -60; + break; + case TIME_ZONE_ID_DAYLIGHT: + result->tm_isdst = 1; + result->tm_gmtoff = (tz.Bias + tz.DaylightBias) * -60; + break; + default: + /* noop */; + } + } +#endif + + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, + apr_time_exp_t *xt) +{ + apr_time_t year = xt->tm_year; + apr_time_t days; + static const int dayoffset[12] = + {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; + + /* shift new year to 1st March in order to make leap year calc easy */ + + if (xt->tm_mon < 2) + year--; + + /* Find number of days since 1st March 1900 (in the Gregorian calendar). */ + + days = year * 365 + year / 4 - year / 100 + (year / 100 + 3) / 4; + days += dayoffset[xt->tm_mon] + xt->tm_mday - 1; + days -= 25508; /* 1 jan 1970 is 25508 days since 1 mar 1900 */ + + days = ((days * 24 + xt->tm_hour) * 60 + xt->tm_min) * 60 + xt->tm_sec; + + if (days < 0) { + return APR_EBADDATE; + } + *t = days * APR_USEC_PER_SEC + xt->tm_usec; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *t, + apr_time_exp_t *xt) +{ + apr_status_t status = apr_time_exp_get(t, xt); + if (status == APR_SUCCESS) + *t -= (apr_time_t) xt->tm_gmtoff * APR_USEC_PER_SEC; + return status; +} + +APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, + apr_time_t *aprtime) +{ + /* TODO: Consider not passing in pointer to apr_time_t (e.g., call by value) */ + AprTimeToFileTime(*ostime, *aprtime); + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, + apr_time_exp_t *aprexptime) +{ + (*ostime)->wYear = aprexptime->tm_year + 1900; + (*ostime)->wMonth = aprexptime->tm_mon + 1; + (*ostime)->wDayOfWeek = aprexptime->tm_wday; + (*ostime)->wDay = aprexptime->tm_mday; + (*ostime)->wHour = aprexptime->tm_hour; + (*ostime)->wMinute = aprexptime->tm_min; + (*ostime)->wSecond = aprexptime->tm_sec; + (*ostime)->wMilliseconds = aprexptime->tm_usec / 1000; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, + apr_os_imp_time_t **ostime, + apr_pool_t *cont) +{ + /* XXX: sanity failure, what is file time, gmt or local ? + */ + FileTimeToAprTime(aprtime, *ostime); + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, + apr_os_exp_time_t **ostime, + apr_pool_t *cont) +{ + /* The Platform SDK documents that SYSTEMTIME/FILETIME are + * generally UTC, so no timezone info needed + */ + SystemTimeToAprExpTime(aprtime, *ostime); + return APR_SUCCESS; +} + +APR_DECLARE(void) apr_sleep(apr_interval_time_t t) +{ + /* One of the few sane situations for a cast, Sleep + * is in ms, not us, and passed as a DWORD value + */ + Sleep((DWORD)(t / 1000)); +} + +#if defined(_WIN32_WCE) +/* A noop on WinCE, like Unix implementation */ +APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) +{ + return; +} +#else +static apr_status_t clock_restore(void *unsetres) +{ + ULONG newRes; + SetTimerResolution((ULONG)unsetres, FALSE, &newRes); + return APR_SUCCESS; +} + +APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p) +{ + ULONG newRes; + /* Timer resolution is stated in 100ns units. Note that TRUE requests the + * new clock resolution, FALSE above releases the request. + */ + if (SetTimerResolution(10000, TRUE, &newRes) == 0 /* STATUS_SUCCESS */) { + /* register the cleanup... */ + apr_pool_cleanup_register(p, (void*)10000, clock_restore, + apr_pool_cleanup_null); + } +} +#endif + + +/* Deprecated */ +APR_DECLARE(apr_status_t) apr_explode_time(apr_time_exp_t *result, + apr_time_t input, + apr_int32_t offs) +{ + return apr_time_exp_tz(result, input, offs); +} + +/* Deprecated */ +APR_DECLARE(apr_status_t) apr_explode_localtime(apr_time_exp_t *result, + apr_time_t input) +{ + return apr_time_exp_lt(result, input); +} + +/* Deprecated */ +APR_DECLARE(apr_status_t) apr_implode_gmt(apr_time_t *t, + apr_time_exp_t *xt) +{ + return apr_time_exp_gmt_get(t, xt); +} + diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/timestr.c b/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/timestr.c new file mode 100644 index 00000000..0c533be0 --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/time/win32/timestr.c @@ -0,0 +1,216 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "win32/apr_arch_atime.h" +#include "apr_portable.h" +#include "apr_strings.h" + +APR_DECLARE_DATA const char apr_month_snames[12][4] = +{ + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; +APR_DECLARE_DATA const char apr_day_snames[7][4] = +{ + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; + +APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t) +{ + apr_time_exp_t xt; + const char *s; + int real_year; + + apr_time_exp_gmt(&xt, t); + + /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */ + /* 12345678901234567890123456789 */ + + s = &apr_day_snames[xt.tm_wday][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ','; + *date_str++ = ' '; + *date_str++ = xt.tm_mday / 10 + '0'; + *date_str++ = xt.tm_mday % 10 + '0'; + *date_str++ = ' '; + s = &apr_month_snames[xt.tm_mon][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ' '; + real_year = 1900 + xt.tm_year; + /* This routine isn't y10k ready. */ + *date_str++ = real_year / 1000 + '0'; + *date_str++ = real_year % 1000 / 100 + '0'; + *date_str++ = real_year % 100 / 10 + '0'; + *date_str++ = real_year % 10 + '0'; + *date_str++ = ' '; + *date_str++ = xt.tm_hour / 10 + '0'; + *date_str++ = xt.tm_hour % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_min / 10 + '0'; + *date_str++ = xt.tm_min % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_sec / 10 + '0'; + *date_str++ = xt.tm_sec % 10 + '0'; + *date_str++ = ' '; + *date_str++ = 'G'; + *date_str++ = 'M'; + *date_str++ = 'T'; + *date_str++ = 0; + return APR_SUCCESS; +} + +APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t) +{ + apr_time_exp_t xt; + const char *s; + int real_year; + + /* example: "Wed Jun 30 21:49:08 1993" */ + /* 123456789012345678901234 */ + + apr_time_exp_lt(&xt, t); + s = &apr_day_snames[xt.tm_wday][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ' '; + s = &apr_month_snames[xt.tm_mon][0]; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = *s++; + *date_str++ = ' '; + *date_str++ = xt.tm_mday / 10 + '0'; + *date_str++ = xt.tm_mday % 10 + '0'; + *date_str++ = ' '; + *date_str++ = xt.tm_hour / 10 + '0'; + *date_str++ = xt.tm_hour % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_min / 10 + '0'; + *date_str++ = xt.tm_min % 10 + '0'; + *date_str++ = ':'; + *date_str++ = xt.tm_sec / 10 + '0'; + *date_str++ = xt.tm_sec % 10 + '0'; + *date_str++ = ' '; + real_year = 1900 + xt.tm_year; + *date_str++ = real_year / 1000 + '0'; + *date_str++ = real_year % 1000 / 100 + '0'; + *date_str++ = real_year % 100 / 10 + '0'; + *date_str++ = real_year % 10 + '0'; + *date_str++ = 0; + + return APR_SUCCESS; +} + + +#ifndef _WIN32_WCE + +int win32_strftime_extra(char *s, size_t max, const char *format, + const struct tm *tm) +{ + /* If the new format string is bigger than max, the result string won't fit + * anyway. If format strings are added, made sure the padding below is + * enough */ + char *new_format = (char *) malloc(max + 11); + size_t i, j, format_length = strlen(format); + int return_value; + int length_written; + + for (i = 0, j = 0; (i < format_length && j < max);) { + if (format[i] != '%') { + new_format[j++] = format[i++]; + continue; + } + switch (format[i+1]) { + case 'C': + length_written = apr_snprintf(new_format + j, max - j, "%2d", + (tm->tm_year + 1970)/100); + j = (length_written == -1) ? max : (j + length_written); + i += 2; + break; + case 'D': + /* Is this locale dependent? Shouldn't be... + Also note the year 2000 exposure here */ + memcpy(new_format + j, "%m/%d/%y", 8); + i += 2; + j += 8; + break; + case 'r': + memcpy(new_format + j, "%I:%M:%S %p", 11); + i += 2; + j += 11; + break; + case 'R': + memcpy(new_format + j, "%H:%M", 5); + i += 2; + j += 5; + break; + case 'T': + memcpy(new_format + j, "%H:%M:%S", 8); + i += 2; + j += 8; + break; + case 'e': + length_written = apr_snprintf(new_format + j, max - j, "%2d", + tm->tm_mday); + j = (length_written == -1) ? max : (j + length_written); + i += 2; + break; + default: + /* We know we can advance two characters forward here. Also + * makes sure that %% is preserved. */ + new_format[j++] = format[i++]; + new_format[j++] = format[i++]; + } + } + if (j >= max) { + *s = '\0'; /* Defensive programming, okay since output is undefined*/ + return_value = 0; + } else { + new_format[j] = '\0'; + return_value = strftime(s, max, new_format, tm); + } + free(new_format); + return return_value; +} + +#endif + + +APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, + apr_size_t max, const char *format, + apr_time_exp_t *xt) +{ +#ifdef _WIN32_WCE + return APR_ENOTIMPL; +#else + struct tm tm; + memset(&tm, 0, sizeof tm); + tm.tm_sec = xt->tm_sec; + tm.tm_min = xt->tm_min; + tm.tm_hour = xt->tm_hour; + tm.tm_mday = xt->tm_mday; + tm.tm_mon = xt->tm_mon; + tm.tm_year = xt->tm_year; + tm.tm_wday = xt->tm_wday; + tm.tm_yday = xt->tm_yday; + tm.tm_isdst = xt->tm_isdst; + (*retsize) = win32_strftime_extra(s, max, format, &tm); + return APR_SUCCESS; +#endif +} |