manoj 98/11/05 11:20:18
Modified: src CHANGES
src/include ap_config.h
src/os/win32 os.h util_win32.c
Log:
Work around incomplete implementation of strftime on Win32.
Revision Changes Path
1.1134 +3 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1133
retrieving revision 1.1134
diff -u -u -r1.1133 -r1.1134
--- CHANGES 1998/11/04 22:23:42 1.1133
+++ CHANGES 1998/11/05 19:20:14 1.1134
@@ -1,5 +1,8 @@
Changes with Apache 1.3.4
+ *) Work around incomplete implementation of strftime on Win32.
+ [Manoj Kasichainula, Ken Parzygnat <[EMAIL PROTECTED]>]
+
*) Move a typedef to fix compile problems on Linux with 1.x kernels.
[Manoj Kasichainula] PR#3177
1.243 +3 -0 apache-1.3/src/include/ap_config.h
Index: ap_config.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/ap_config.h,v
retrieving revision 1.242
retrieving revision 1.243
diff -u -u -r1.242 -r1.243
--- ap_config.h 1998/11/04 22:23:45 1.242
+++ ap_config.h 1998/11/05 19:20:16 1.243
@@ -938,6 +938,9 @@
#endif /* ndef WIN32 */
#include <time.h> /* for ctime */
+#ifdef WIN32
+#define strftime(s,max,format,tm) os_strftime(s,max,format,tm)
+#endif
#include <signal.h>
#include <errno.h>
#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT)
1.25 +2 -0 apache-1.3/src/os/win32/os.h
Index: os.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/win32/os.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -u -r1.24 -r1.25
--- os.h 1998/09/19 12:27:25 1.24
+++ os.h 1998/11/05 19:20:17 1.25
@@ -93,6 +93,8 @@
#define stat(f,ps) os_stat(f,ps)
API_EXPORT(int) os_stat(const char *szPath,struct stat *pStat);
+API_EXPORT(int) os_strftime(char *s, size_t max, const char *format, const
struct tm *tm);
+
#define _spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv)
#define spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv)
API_EXPORT(int) os_spawnv(int mode,const char *cmdname,const char *const
*argv);
1.27 +69 -0 apache-1.3/src/os/win32/util_win32.c
Index: util_win32.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/win32/util_win32.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -u -r1.26 -r1.27
--- util_win32.c 1998/10/01 04:52:32 1.26
+++ util_win32.c 1998/11/05 19:20:17 1.27
@@ -1,6 +1,8 @@
#include <windows.h>
#include <sys/stat.h>
#include <stdarg.h>
+#include <time.h>
+#include <stdlib.h>
#include "httpd.h"
#include "http_log.h"
@@ -415,4 +417,71 @@
va_end(vlist);
return _spawnve(mode, szCmd, aszArgs, aszEnv);
+}
+
+#undef strftime
+
+/* Partial replacement for strftime. This adds certain expandos to the
+ * Windows version
+ */
+
+API_EXPORT(int) os_strftime(char *s, size_t max, const char *format,
+ const struct tm *tm) {
+ /* If the new format string is bigger than max, the result string probably
+ * won't fit anyway. When %-expandos are added, made sure the padding
below
+ * is enough.
+ */
+ char *new_format = (char *) _alloca(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 '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 'T':
+ memcpy(new_format + j, "%H:%M:%S", 8);
+ i += 2;
+ j += 8;
+ break;
+ case 'e':
+ length_written = ap_snprintf(new_format + j, max - j, "%2d",
+ tm->tm_mday);
+ j = (length_written == -1) ? max : (j + length_written);
+ i += 2;
+ break;
+ /* Handle "%%" to avoid dying on strftime(out, 600, 1200 "%"'s)
*/
+ case '%':
+ new_format[j++] = '%';
+ i += 2;
+ break;
+ default:
+ /* We know we can advance two characters forward here. */
+ 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);
+ }
+ return return_value;
}