Index: src/comm.c diff -u src/comm.c:1.12 src/comm.c:1.4.20.3 --- src/comm.c:1.12 Fri Apr 13 17:31:02 2001 +++ src/comm.c Sun May 6 14:04:04 2001 @@ -35,6 +35,9 @@ #include "squid.h" +#if defined(_SQUID_CYGWIN_) +#include +#endif #ifdef HAVE_NETINET_TCP_H #include #endif Index: src/defines.h diff -u src/defines.h:1.12 src/defines.h:1.3.22.10 --- src/defines.h:1.12 Sat May 5 13:47:38 2001 +++ src/defines.h Sun May 6 10:44:02 2001 @@ -301,5 +301,4 @@ #define _WIN_OS_WIN98 3 #define _WIN_OS_WINNT 4 #define _WIN_OS_WIN2K 5 -#define _WIN_OS_STRING_SZ 80 #endif Index: src/globals.h diff -u src/globals.h:1.10 src/globals.h:1.5.12.10 --- src/globals.h:1.10 Sat May 5 13:47:38 2001 +++ src/globals.h Sun May 6 10:44:02 2001 @@ -156,5 +156,5 @@ extern int incoming_sockets_accepted; #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) extern unsigned int WIN32_OS_version; /* 0 */ -extern char WIN32_OS_string[_WIN_OS_STRING_SZ]; +extern char *WIN32_OS_string; #endif Index: src/main.c diff -u src/main.c:1.24 src/main.c:1.12.2.13 --- src/main.c:1.24 Sat May 19 17:20:57 2001 +++ src/main.c Sun Aug 12 07:52:24 2001 @@ -998,9 +998,5 @@ version_string); if (debug_log) fclose(debug_log); -#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) - WIN32_Exit(0); -#else exit(0); -#endif } Index: src/protos.h diff -u src/protos.h:1.31 src/protos.h:1.9.2.14 --- src/protos.h:1.31 Sun Aug 12 08:20:28 2001 +++ src/protos.h Sun Aug 12 09:15:02 2001 @@ -1313,6 +1313,6 @@ /* CygWin & Windows NT Port */ /* win32.c */ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) -extern int WIN32_Subsystem_Init(); -extern void WIN32_Exit(int); +extern int WIN32_Subsystem_Init(void); +extern void WIN32_Exit(void); #endif Index: src/tools.c diff -u src/tools.c:1.14 src/tools.c:1.7.2.13 --- src/tools.c:1.14 Sun Aug 12 08:20:28 2001 +++ src/tools.c Sun Aug 12 07:52:24 2001 @@ -968,17 +1010,49 @@ char *lt = buf; char *addr = buf; char *host = NULL; +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) + char * systemroot=NULL; +#endif if (NULL == Config.etcHostsPath) return; if (0 == strcmp(Config.etcHostsPath, "none")) return; fp = fopen(Config.etcHostsPath, "r"); if (fp == NULL) { +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) + switch (WIN32_OS_version) { + case _WIN_OS_WINNT: + case _WIN_OS_WIN2K: + if ((systemroot=getenv("SYSTEMROOT")) != NULL) { + strcpy(buf,systemroot); + strcat(buf,"\\system32\\drivers\\etc\\hosts"); + } + break; + case _WIN_OS_WIN95: + case _WIN_OS_WIN98: + if ((systemroot=getenv("WINDIR")) != NULL) { + strcpy(buf,systemroot); + strcat(buf,"\\hosts"); + } + break; + } + if (systemroot != NULL) { + safe_free(Config.etcHostsPath); + Config.etcHostsPath=xstrdup(buf); + fp = fopen(Config.etcHostsPath, "r"); + } + if (fp == NULL) { + debug(1, 1) ("parseEtcHosts: %s: %s\n", + Config.etcHostsPath, xstrerror()); + return; + } +#else debug(1, 1) ("parseEtcHosts: %s: %s\n", Config.etcHostsPath, xstrerror()); return; +#endif } -#if defined(_SQUID_CYGWIN_) +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif while (fgets(buf, 1024, fp)) { /* for each line */ Index: src/win32.c diff -u src/win32.c:1.2 src/win32.c:1.1.50.7 --- src/win32.c:1.2 Sun May 6 07:28:38 2001 +++ src/win32.c Sun Aug 12 07:52:24 2001 @@ -28,7 +28,6 @@ #include static unsigned int GetOSVersion(); -void WIN32_svcstatusupdate(DWORD); /* ====================================================================== */ /* LOCAL FUNCTIONS */ @@ -39,37 +38,38 @@ { OSVERSIONINFO osvi; + xfree(WIN32_OS_string); memset(&osvi, '\0', sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx((OSVERSIONINFO *) & osvi); switch (osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: if (osvi.dwMajorVersion <= 4) { - strcpy(WIN32_OS_string, "Windows NT"); + WIN32_OS_string=xstrdup("Windows NT"); return _WIN_OS_WINNT; } if (osvi.dwMajorVersion == 5) { - strcpy(WIN32_OS_string, "Windows 2000"); + WIN32_OS_string=xstrdup("Windows 2000"); return _WIN_OS_WIN2K; } break; case VER_PLATFORM_WIN32_WINDOWS: if ((osvi.dwMajorVersion > 4) || ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0))) { - strcpy(WIN32_OS_string, "Windows 98"); + WIN32_OS_string=xstrdup("Windows 98"); return _WIN_OS_WIN98; } - strcpy(WIN32_OS_string, "Windows 95"); + WIN32_OS_string=xstrdup("Windows 95"); return _WIN_OS_WIN95; break; case VER_PLATFORM_WIN32s: - strcpy(WIN32_OS_string, "Windows 3.1 with WIN32S"); + WIN32_OS_string=xstrdup("Windows 3.1 with WIN32S"); return _WIN_OS_WIN32S; break; default: return _WIN_OS_UNKNOWN; } - strcpy(WIN32_OS_string, "Unknown"); + WIN32_OS_string=xstrdup("Unknown"); return _WIN_OS_UNKNOWN; } @@ -77,16 +77,18 @@ /* PUBLIC FUNCTIONS */ /* ====================================================================== */ -VOID -WIN32_Exit(int ExitStatus) +void +WIN32_Exit() { - exit(0); + _exit(0); } int WIN32_Subsystem_Init() { WIN32_OS_version = GetOSVersion(); + if (atexit(WIN32_Exit) != 0) + return 1; return 0; } #endif