Last active
August 29, 2015 14:19
-
-
Save zsprackett/63445988617a1ce8de87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ruN httpd-2.2.22/include/util_time.h httpd-2.2.22.patched/include/util_time.h | |
--- httpd-2.2.22/include/util_time.h 2006-07-11 20:38:44.000000000 -0700 | |
+++ httpd-2.2.22.patched/include/util_time.h 2015-04-11 17:46:18.345588587 -0700 | |
@@ -77,6 +77,13 @@ | |
AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t); | |
/** | |
+ * format a recent timestamp in the ISO8601 format | |
+ * @param date_str String to write to (must have length >= APR_ISO8601_DATE_LEN) | |
+ * @param t the time to convert | |
+ */ | |
+AP_DECLARE(apr_status_t) ap_recent_iso8601_date(char *date_str, apr_time_t t); | |
+ | |
+/** | |
* format a recent timestamp in the RFC822 format | |
* @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN) | |
* @param t the time to convert | |
diff -ruN httpd-2.2.22/server/log.c httpd-2.2.22.patched/server/log.c | |
--- httpd-2.2.22/server/log.c 2009-05-21 10:31:52.000000000 -0700 | |
+++ httpd-2.2.22.patched/server/log.c 2015-04-11 17:49:20.557635810 -0700 | |
@@ -29,6 +29,7 @@ | |
#include "apr_lib.h" | |
#include "apr_signal.h" | |
+#define APR_ISO8601_DATE_LEN (26) | |
#define APR_WANT_STDIO | |
#define APR_WANT_STRFUNC | |
#include "apr_want.h" | |
@@ -575,10 +576,10 @@ | |
if (logf && ((level & APLOG_STARTUP) != APLOG_STARTUP)) { | |
errstr[0] = '['; | |
- ap_recent_ctime(errstr + 1, apr_time_now()); | |
- errstr[1 + APR_CTIME_LEN - 1] = ']'; | |
- errstr[1 + APR_CTIME_LEN ] = ' '; | |
- len = 1 + APR_CTIME_LEN + 1; | |
+ ap_recent_iso8601_date(errstr + 1, apr_time_now()); | |
+ errstr[1 + APR_ISO8601_DATE_LEN - 1] = ']'; | |
+ errstr[1 + APR_ISO8601_DATE_LEN] = ' '; | |
+ len = 1 + APR_ISO8601_DATE_LEN + 1; | |
} else { | |
len = 0; | |
} | |
@@ -626,6 +627,10 @@ | |
} | |
#endif /* TPF */ | |
+ if (r) { | |
+ len += apr_snprintf(errstr + len, MAX_STRING_LEN - len, | |
+ "[host %s] ", r->hostname); | |
+ } | |
if (c) { | |
/* XXX: TODO: add a method of selecting whether logged client | |
* addresses are in dotted quad or resolved form... dotted | |
diff -ruN httpd-2.2.22/server/util_time.c httpd-2.2.22.patched/server/util_time.c | |
--- httpd-2.2.22/server/util_time.c 2006-07-11 20:38:44.000000000 -0700 | |
+++ httpd-2.2.22.patched/server/util_time.c 2015-04-11 17:46:18.364588696 -0700 | |
@@ -188,6 +188,51 @@ | |
return APR_SUCCESS; | |
} | |
+APR_DECLARE(apr_status_t) ap_recent_iso8601_date(char *date_str, apr_time_t t) | |
+{ | |
+ /* ### This code is a clone of apr_ios8601_date(), except that it | |
+ * uses ap_explode_recent_gmt() instead of apr_time_exp_gmt(). | |
+ */ | |
+ apr_time_exp_t xt; | |
+ const char *s; | |
+ int real_year; | |
+ | |
+ ap_explode_recent_gmt(&xt, t); | |
+ | |
+ /* example: "2015-04-11T00:09:47+00:00" */ | |
+ /* 1234567890123456789012345 */ | |
+ | |
+ 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_mon + 1) / 10 + '0'; | |
+ *date_str++ = (xt.tm_mon + 1) % 10 + '0'; | |
+ *date_str++ = '-'; | |
+ *date_str++ = xt.tm_mday / 10 + '0'; | |
+ *date_str++ = xt.tm_mday % 10 + '0'; | |
+ *date_str++ = 'T'; | |
+ *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++ = '0'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = ':'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = 0; | |
+ return APR_SUCCESS; | |
+} | |
+ | |
AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t) | |
{ | |
/* ### This code is a clone of apr_rfc822_date(), except that it | |
diff -ruN httpd-2.2.22/srclib/apr/include/apr_time.h httpd-2.2.22.patched/srclib/apr/include/apr_time.h | |
--- httpd-2.2.22/srclib/apr/include/apr_time.h 2008-10-20 16:35:03.000000000 -0700 | |
+++ httpd-2.2.22.patched/srclib/apr/include/apr_time.h 2015-04-11 17:46:18.372588742 -0700 | |
@@ -180,6 +180,18 @@ | |
*/ | |
APR_DECLARE(void) apr_sleep(apr_interval_time_t t); | |
+/** length of a ISO8601 Date */ | |
+#define APR_ISO8601_DATE_LEN (26) | |
+/** | |
+ * apr_iso8601_date formats dates in the ISO 8601 | |
+ * format in an efficient manner. It is a fixed length | |
+ * format which requires the indicated amount of storage, | |
+ * including the trailing NUL terminator. | |
+ * @param date_str String to write to. | |
+ * @param t the time to convert | |
+ */ | |
+APR_DECLARE(apr_status_t) apr_iso8601_date(char *date_str, apr_time_t t); | |
+ | |
/** length of a RFC822 Date */ | |
#define APR_RFC822_DATE_LEN (30) | |
/** | |
diff -ruN httpd-2.2.22/srclib/apr/time/unix/timestr.c httpd-2.2.22.patched/srclib/apr/time/unix/timestr.c | |
--- httpd-2.2.22/srclib/apr/time/unix/timestr.c 2006-08-03 03:55:31.000000000 -0700 | |
+++ httpd-2.2.22.patched/srclib/apr/time/unix/timestr.c 2015-04-11 17:46:18.380588788 -0700 | |
@@ -39,6 +39,48 @@ | |
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" | |
}; | |
+APR_DECLARE(apr_status_t) apr_iso8601_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: "2015-04-11T00:09:47+00:00" */ | |
+ /* 1234567890123456789012345 */ | |
+ | |
+ 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_mon + 1) / 10 + '0'; | |
+ *date_str++ = (xt.tm_mon + 1) % 10 + '0'; | |
+ *date_str++ = '-'; | |
+ *date_str++ = xt.tm_mday / 10 + '0'; | |
+ *date_str++ = xt.tm_mday % 10 + '0'; | |
+ *date_str++ = 'T'; | |
+ *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++ = '0'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = ':'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = 0; | |
+ return APR_SUCCESS; | |
+} | |
+ | |
apr_status_t apr_rfc822_date(char *date_str, apr_time_t t) | |
{ | |
apr_time_exp_t xt; | |
diff -ruN httpd-2.2.22/srclib/apr/time/win32/timestr.c httpd-2.2.22.patched/srclib/apr/time/win32/timestr.c | |
--- httpd-2.2.22/srclib/apr/time/win32/timestr.c 2011-03-22 12:49:19.000000000 -0700 | |
+++ httpd-2.2.22.patched/srclib/apr/time/win32/timestr.c 2015-04-11 17:46:18.386588822 -0700 | |
@@ -31,6 +31,48 @@ | |
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" | |
}; | |
+APR_DECLARE(apr_status_t) apr_iso8601_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: "2015-04-11T00:09:47+00:00" */ | |
+ /* 1234567890123456789012345 */ | |
+ | |
+ 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_mon + 1) / 10 + '0'; | |
+ *date_str++ = (xt.tm_mon + 1) % 10 + '0'; | |
+ *date_str++ = '-'; | |
+ *date_str++ = xt.tm_mday / 10 + '0'; | |
+ *date_str++ = xt.tm_mday % 10 + '0'; | |
+ *date_str++ = 'T'; | |
+ *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++ = '0'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = ':'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = '0'; | |
+ *date_str++ = 0; | |
+ return APR_SUCCESS; | |
+} | |
+ | |
APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t) | |
{ | |
apr_time_exp_t xt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment