Sorry, I've been 'away' from the current world a while.
Good news, httpd-2.0 seems to build (one I fixed the cpq6000 to actually compile
things again.)
Bad news - apache-1.3 rotatelogs is now entirely broken, and there is _no_ simple
fix that I can find.
Here's the _minimal_ fix to get things straightened out, AFAICS.
os_stat, spawn* and strftime all need to slide into os.c. In that, we need to
stop using ap_snprintf and use the clib's _snprintf, and kill a stupid assert
sitting in os_stat by using MAX_PATH instead of _MAX_PATH.
Comments? I'd not post if someone has a better fix, but if noone does, this goes
in on Sunday night.
Bill
Index: os/win32/ApacheOS.dsp
===================================================================
RCS file: /home/cvs/apache-1.3/src/os/win32/ApacheOS.dsp,v
retrieving revision 1.11
diff -u -r1.11 ApacheOS.dsp
--- os/win32/ApacheOS.dsp 2001/02/14 14:45:55 1.11
+++ os/win32/ApacheOS.dsp 2001/03/25 06:55:49
@@ -39,6 +39,7 @@
# PROP Output_Dir "LibR"
# PROP Intermediate_Dir "LibR"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fd"LibR\ApacheOS"
/FD /c
BSC32=bscmake.exe
@@ -60,6 +61,7 @@
# PROP Output_Dir "LibD"
# PROP Intermediate_Dir "LibD"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /MDd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD
/c
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"
/Fd"LibD\ApacheOS" /FD /c
BSC32=bscmake.exe
Index: os/win32/os.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/os/win32/os.c,v
retrieving revision 1.4
diff -u -r1.4 os.c
--- os/win32/os.c 2001/02/14 14:22:10 1.4
+++ os/win32/os.c 2001/03/25 06:55:49
@@ -61,5 +61,268 @@
* as "__inline" in os.h.
*/
+#include <sys/stat.h>
+#include <stdio.h>
+#include <time.h>
#include "os.h"
+/* Win95 doesn't like trailing /s. NT and Unix don't mind. This works
+ * around the problem.
+ * Errr... except if it is UNC and we are referring to the root of
+ * the UNC, we MUST have a trailing \ and we can't use /s. Jeez.
+ * Not sure if this refers to all UNCs or just roots,
+ * but I'm going to fix it for all cases for now. (Ben)
+ */
+
+#undef stat
+API_EXPORT(int) os_stat(const char *szPath, struct stat *pStat)
+{
+ int n;
+ int len = strlen(szPath);
+
+ if ((len == 0) || (len >= MAX_PATH)) {
+ return -1;
+ }
+
+ if (szPath[0] == '/' && szPath[1] == '/') {
+ char buf[_MAX_PATH];
+ char *s;
+ int nSlashes = 0;
+
+ strcpy(buf, szPath);
+ for (s = buf; *s; ++s) {
+ if (*s == '/') {
+ *s = '\\';
+ ++nSlashes;
+ }
+ }
+ /* then we need to add one more to get \\machine\share\ */
+ if (nSlashes == 3) {
+ if (++len >= MAX_PATH) {
+ return -1;
+ }
+ *s++ = '\\';
+ }
+ *s = '\0';
+ return stat(buf, pStat);
+ }
+
+ /*
+ * Below removes the trailing /, however, do not remove
+ * it in the case of 'x:/' or stat will fail
+ */
+ n = strlen(szPath);
+ if ((szPath[n - 1] == '\\' || szPath[n - 1] == '/') &&
+ !(n == 3 && szPath[1] == ':')) {
+ char buf[MAX_PATH];
+
+ strcpy(buf, szPath);
+ buf[n - 1] = '\0';
+
+ return stat(buf, pStat);
+ }
+ return stat(szPath, pStat);
+}
+
+/* Fix two really crap problems with Win32 spawn[lv]e*:
+ *
+ * 1. Win32 doesn't deal with spaces in argv.
+ * 2. Win95 doesn't like / in cmdname.
+ */
+
+#undef _spawnv
+API_EXPORT(int) os_spawnv(int mode, const char *cmdname,
+ const char *const *argv)
+{
+ int n;
+ char **aszArgs;
+ const char *szArg;
+ char *szCmd;
+ char *s;
+
+ szCmd = _alloca(strlen(cmdname)+1);
+ strcpy(szCmd, cmdname);
+ for (s = szCmd; *s; ++s) {
+ if (*s == '/') {
+ *s = '\\';
+ }
+ }
+
+ for (n = 0; argv[n]; ++n)
+ ;
+
+ aszArgs = _alloca((n + 1) * sizeof(const char *));
+
+ for (n = 0; szArg = argv[n]; ++n) {
+ if (strchr(szArg, ' ')) {
+ int l = strlen(szArg);
+
+ aszArgs[n] = _alloca(l + 2 + 1);
+ aszArgs[n][0] = '"';
+ strcpy(&aszArgs[n][1], szArg);
+ aszArgs[n][l + 1] = '"';
+ aszArgs[n][l + 2] = '\0';
+ }
+ else {
+ aszArgs[n] = (char *)szArg;
+ }
+ }
+
+ aszArgs[n] = NULL;
+
+ return _spawnv(mode, szCmd, aszArgs);
+}
+
+#undef _spawnve
+API_EXPORT(int) os_spawnve(int mode, const char *cmdname,
+ const char *const *argv, const char *const *envp)
+{
+ int n;
+ char **aszArgs;
+ const char *szArg;
+ char *szCmd;
+ char *s;
+
+ szCmd = _alloca(strlen(cmdname)+1);
+ strcpy(szCmd, cmdname);
+ for (s = szCmd; *s; ++s) {
+ if (*s == '/') {
+ *s = '\\';
+ }
+ }
+
+ for (n = 0; argv[n]; ++n)
+ ;
+
+ aszArgs = _alloca((n + 1)*sizeof(const char *));
+
+ for (n = 0; szArg = argv[n]; ++n){
+ if (strchr(szArg, ' ')) {
+ int l = strlen(szArg);
+
+ aszArgs[n] = _alloca(l + 2 + 1);
+ aszArgs[n][0] = '"';
+ strcpy(&aszArgs[n][1], szArg);
+ aszArgs[n][l + 1] = '"';
+ aszArgs[n][l + 2] = '\0';
+ }
+ else {
+ aszArgs[n] = (char *)szArg;
+ }
+ }
+
+ aszArgs[n] = NULL;
+
+ return _spawnve(mode, szCmd, aszArgs, envp);
+}
+
+API_EXPORT_NONSTD(int) os_spawnle(int mode, const char *cmdname, ...)
+{
+ int n;
+ va_list vlist;
+ char **aszArgs;
+ const char *szArg;
+ const char *const *aszEnv;
+ char *szCmd;
+ char *s;
+
+ szCmd = _alloca(strlen(cmdname)+1);
+ strcpy(szCmd, cmdname);
+ for (s = szCmd; *s; ++s) {
+ if (*s == '/') {
+ *s = '\\';
+ }
+ }
+
+ va_start(vlist, cmdname);
+ for (n = 0; va_arg(vlist, const char *); ++n)
+ ;
+ va_end(vlist);
+
+ aszArgs = _alloca((n + 1) * sizeof(const char *));
+
+ va_start(vlist, cmdname);
+ for (n = 0; szArg = va_arg(vlist, const char *); ++n) {
+ if (strchr(szArg, ' ')) {
+ int l = strlen(szArg);
+
+ aszArgs[n] = _alloca(l + 2 + 1);
+ aszArgs[n][0] = '"';
+ strcpy(&aszArgs[n][1], szArg);
+ aszArgs[n][l + 1] = '"';
+ aszArgs[n][l + 2] = '\0';
+ }
+ else {
+ aszArgs[n] = (char *)szArg;
+ }
+ }
+
+ aszArgs[n] = NULL;
+
+ aszEnv = va_arg(vlist, const char *const *);
+ 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 = _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. */
+ 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;
+}
Index: os/win32/util_win32.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/os/win32/util_win32.c,v
retrieving revision 1.42
diff -u -r1.42 util_win32.c
--- os/win32/util_win32.c 2001/02/14 14:22:11 1.42
+++ os/win32/util_win32.c 2001/03/25 06:55:49
@@ -58,7 +58,6 @@
#ifdef WIN32
-#include <windows.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <time.h>
@@ -358,267 +357,6 @@
return pNewName;
}
-/* Win95 doesn't like trailing /s. NT and Unix don't mind. This works
- * around the problem.
- * Errr... except if it is UNC and we are referring to the root of
- * the UNC, we MUST have a trailing \ and we can't use /s. Jeez.
- * Not sure if this refers to all UNCs or just roots,
- * but I'm going to fix it for all cases for now. (Ben)
- */
-
-#undef stat
-API_EXPORT(int) os_stat(const char *szPath, struct stat *pStat)
-{
- int n;
- int len = strlen(szPath);
-
- if ((len == 0) || (len >= MAX_PATH)) {
- return -1;
- }
-
- if (szPath[0] == '/' && szPath[1] == '/') {
- char buf[_MAX_PATH];
- char *s;
- int nSlashes = 0;
-
- strcpy(buf, szPath);
- for (s = buf; *s; ++s) {
- if (*s == '/') {
- *s = '\\';
- ++nSlashes;
- }
- }
- /* then we need to add one more to get \\machine\share\ */
- if (nSlashes == 3) {
- if (++len >= MAX_PATH) {
- return -1;
- }
- *s++ = '\\';
- }
- *s = '\0';
- return stat(buf, pStat);
- }
-
- /*
- * Below removes the trailing /, however, do not remove
- * it in the case of 'x:/' or stat will fail
- */
- n = strlen(szPath);
- if ((szPath[n - 1] == '\\' || szPath[n - 1] == '/') &&
- !(n == 3 && szPath[1] == ':')) {
- char buf[_MAX_PATH];
-
- ap_assert(n < _MAX_PATH);
- strcpy(buf, szPath);
- buf[n - 1] = '\0';
-
- return stat(buf, pStat);
- }
- return stat(szPath, pStat);
-}
-
-/* Fix two really crap problems with Win32 spawn[lv]e*:
- *
- * 1. Win32 doesn't deal with spaces in argv.
- * 2. Win95 doesn't like / in cmdname.
- */
-
-#undef _spawnv
-API_EXPORT(int) os_spawnv(int mode, const char *cmdname,
- const char *const *argv)
-{
- int n;
- char **aszArgs;
- const char *szArg;
- char *szCmd;
- char *s;
-
- szCmd = _alloca(strlen(cmdname)+1);
- strcpy(szCmd, cmdname);
- for (s = szCmd; *s; ++s) {
- if (*s == '/') {
- *s = '\\';
- }
- }
-
- for (n = 0; argv[n]; ++n)
- ;
-
- aszArgs = _alloca((n + 1) * sizeof(const char *));
-
- for (n = 0; szArg = argv[n]; ++n) {
- if (strchr(szArg, ' ')) {
- int l = strlen(szArg);
-
- aszArgs[n] = _alloca(l + 2 + 1);
- aszArgs[n][0] = '"';
- strcpy(&aszArgs[n][1], szArg);
- aszArgs[n][l + 1] = '"';
- aszArgs[n][l + 2] = '\0';
- }
- else {
- aszArgs[n] = (char *)szArg;
- }
- }
-
- aszArgs[n] = NULL;
-
- return _spawnv(mode, szCmd, aszArgs);
-}
-
-#undef _spawnve
-API_EXPORT(int) os_spawnve(int mode, const char *cmdname,
- const char *const *argv, const char *const *envp)
-{
- int n;
- char **aszArgs;
- const char *szArg;
- char *szCmd;
- char *s;
-
- szCmd = _alloca(strlen(cmdname)+1);
- strcpy(szCmd, cmdname);
- for (s = szCmd; *s; ++s) {
- if (*s == '/') {
- *s = '\\';
- }
- }
-
- for (n = 0; argv[n]; ++n)
- ;
-
- aszArgs = _alloca((n + 1)*sizeof(const char *));
-
- for (n = 0; szArg = argv[n]; ++n){
- if (strchr(szArg, ' ')) {
- int l = strlen(szArg);
-
- aszArgs[n] = _alloca(l + 2 + 1);
- aszArgs[n][0] = '"';
- strcpy(&aszArgs[n][1], szArg);
- aszArgs[n][l + 1] = '"';
- aszArgs[n][l + 2] = '\0';
- }
- else {
- aszArgs[n] = (char *)szArg;
- }
- }
-
- aszArgs[n] = NULL;
-
- return _spawnve(mode, szCmd, aszArgs, envp);
-}
-
-API_EXPORT_NONSTD(int) os_spawnle(int mode, const char *cmdname, ...)
-{
- int n;
- va_list vlist;
- char **aszArgs;
- const char *szArg;
- const char *const *aszEnv;
- char *szCmd;
- char *s;
-
- szCmd = _alloca(strlen(cmdname)+1);
- strcpy(szCmd, cmdname);
- for (s = szCmd; *s; ++s) {
- if (*s == '/') {
- *s = '\\';
- }
- }
-
- va_start(vlist, cmdname);
- for (n = 0; va_arg(vlist, const char *); ++n)
- ;
- va_end(vlist);
-
- aszArgs = _alloca((n + 1) * sizeof(const char *));
-
- va_start(vlist, cmdname);
- for (n = 0; szArg = va_arg(vlist, const char *); ++n) {
- if (strchr(szArg, ' ')) {
- int l = strlen(szArg);
-
- aszArgs[n] = _alloca(l + 2 + 1);
- aszArgs[n][0] = '"';
- strcpy(&aszArgs[n][1], szArg);
- aszArgs[n][l + 1] = '"';
- aszArgs[n][l + 2] = '\0';
- }
- else {
- aszArgs[n] = (char *)szArg;
- }
- }
-
- aszArgs[n] = NULL;
-
- aszEnv = va_arg(vlist, const char *const *);
- 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;
- 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;
-}
/*
* ap_os_is_filename_valid is given a filename, and returns 0 if the filename
Index: support/rotatelogs.dsp
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/rotatelogs.dsp,v
retrieving revision 1.5
diff -u -r1.5 rotatelogs.dsp
--- support/rotatelogs.dsp 2000/12/19 23:22:12 1.5
+++ support/rotatelogs.dsp 2001/03/25 06:55:49
@@ -49,8 +49,8 @@
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /incremental:no /map /machine:I386
-# ADD LINK32 /nologo /subsystem:console /incremental:no /map /machine:I386
+# ADD BASE LINK32 /nologo /subsystem:console /map /machine:I386
+# ADD LINK32 kernel32.lib wsock32.lib /nologo /subsystem:console /map /machine:I386
!ELSEIF "$(CFG)" == "rotatelogs - Win32 Debug"
@@ -74,7 +74,7 @@
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /incremental:no /map /debug /machine:I386
-# ADD LINK32 /nologo /subsystem:console /incremental:no /map /debug /machine:I386
+# ADD LINK32 kernel32.lib wsock32.lib /nologo /subsystem:console /incremental:no /map
+/debug /machine:I386
!ENDIF
@@ -82,6 +82,18 @@
# Name "rotatelogs - Win32 Release"
# Name "rotatelogs - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\ap\ap_cpystrn.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\ap\ap_snprintf.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\os\win32\os.c
+# End Source File
# Begin Source File
SOURCE=.\rotatelogs.c