Hi,
  here's the first part of the merge proposal for the mswin branch.
What I'm doing is simply to examine and try to validate the output of
a "bzr send" from the mswin branch.
These changes should be quite local and windows-specific; when they're
not, they're mostly about adding guards to
existing includes.

-- 
    /kinkie
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: kin...@squid-cache.org-20120119210056-l7wcpk4mhe9tlvg8
# target_branch: file:///home/kinkie/squid/workspace/trunk/
# testament_sha1: 526729e43bf985397f607fb597237d56328ee284
# timestamp: 2012-01-20 23:03:39 +0100
# base_revision_id: kin...@squid-cache.org-20120119200853-\
#   1y8ixp3jd6kt168i
# 
# Begin patch
=== modified file 'compat/mswin.cc'
--- compat/mswin.cc	2011-08-07 09:29:11 +0000
+++ compat/mswin.cc	2011-08-07 10:03:14 +0000
@@ -41,26 +41,29 @@
 /* Windows NT/2000 Squid port - Compiles only on MS Visual C++ or MinGW */
 #if _SQUID_MSWIN_ || _SQUID_MINGW_
 
-#undef strerror
+//#undef strerror
 #define sys_nerr _sys_nerr
 
 #undef assert
 #include <assert.h>
 #include <stdio.h>
 #include <fcntl.h>
-#include "squid_windows.h"
 #include <string.h>
 #include <sys/timeb.h>
 #if HAVE_WIN32_PSAPI
 #include <psapi.h>
-#endif
+#endif /* HAVE_WIN32_PSAPI */
+#ifndef _MSWSOCK_
+#include <mswsock.h>
+#endif /* _MSWSOCK_ */
+
 
 THREADLOCAL int ws32_result;
 LPCRITICAL_SECTION dbg_mutex = NULL;
 
 void GetProcessName(pid_t, char *);
 
-#if defined(_MSC_VER)		/* Microsoft C Compiler ONLY */
+#if HAVE_GETPAGESIZE > 1
 size_t
 getpagesize()
 {
@@ -72,55 +75,7 @@
     }
     return system_pagesize;
 }
-#endif
-
-uid_t
-geteuid(void)
-{
-    return 100;
-}
-
-uid_t
-getuid(void)
-{
-    return 100;
-}
-
-int
-setuid(uid_t uid)
-{
-    return 0;
-}
-
-int
-seteuid(uid_t euid)
-{
-    return 0;
-}
-
-gid_t
-getegid(void)
-{
-    return 100;
-}
-
-gid_t
-getgid(void)
-{
-    return 100;
-}
-
-int
-setgid(gid_t gid)
-{
-    return 0;
-}
-
-int
-setegid(gid_t egid)
-{
-    return 0;
-}
+#endif /* HAVE_GETPAGESIZE > 1 */
 
 int
 chroot(const char *dirname)
@@ -134,14 +89,10 @@
 void
 GetProcessName(pid_t pid, char *ProcessName)
 {
-    HANDLE hProcess;
-
     strcpy(ProcessName, "unknown");
 #if HAVE_WIN32_PSAPI
     /* Get a handle to the process. */
-    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
-                           PROCESS_VM_READ,
-                           FALSE, pid);
+    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
     /* Get the process name. */
     if (NULL != hProcess) {
         HMODULE hMod;
@@ -156,7 +107,7 @@
     } else
         return;
     CloseHandle(hProcess);
-#endif
+#endif /* HAVE_WIN32_PSAPI */
 }
 
 int
@@ -195,12 +146,12 @@
     pcur_time->tv_sec = current.time;
     pcur_time->tv_usec = current.millitm * 1000L;
     if (tz) {
-        tz->tz_minuteswest = current.timezone;	/* minutes west of Greenwich  */
-        tz->tz_dsttime = current.dstflag;	/* type of dst correction  */
+        tz->tz_minuteswest = current.timezone; /* minutes west of Greenwich  */
+        tz->tz_dsttime = current.dstflag;      /* type of dst correction  */
     }
     return 0;
 }
-#endif
+#endif /* !HAVE_GETTIMEOFDAY */
 
 int
 statfs(const char *path, struct statfs *sfs)
@@ -236,6 +187,7 @@
     return 0;
 }
 
+#if !_SQUID_MINGW_
 int
 WIN32_ftruncate(int fd, off_t size)
 {
@@ -283,6 +235,7 @@
 
     return res;
 }
+#endif /* !_SQUID_MINGW_ */
 
 struct passwd *
 getpwnam(char *unused) {
@@ -296,7 +249,7 @@
     return &grp;
 }
 
-#if defined(__MINGW32__)	/* MinGW environment */
+#if _SQUID_MINGW_
 int
 _free_osfhnd(int filehandle)
 {
@@ -322,7 +275,7 @@
         return -1;
     }
 }
-#endif
+#endif /* _SQUID_MINGW_ */
 
 struct errorentry {
     unsigned long WIN32_code;
@@ -386,10 +339,8 @@
 void
 WIN32_maperror(unsigned long WIN32_oserrno)
 {
-    int i;
-
     _doserrno = WIN32_oserrno;
-    for (i = 0; i < (sizeof(errortable) / sizeof(struct errorentry)); ++i) {
+    for (size_t i = 0; i < (sizeof(errortable) / sizeof(struct errorentry)); ++i) {
         if (WIN32_oserrno == errortable[i].WIN32_code) {
             errno = errortable[i].POSIX_errno;
             return;
@@ -402,4 +353,65 @@
     else
         errno = EINVAL;
 }
-#endif
+
+/* syslog emulation layer derived from git */
+static HANDLE ms_eventlog;
+void openlog(const char *ident, int logopt, int facility)
+{
+        if (ms_eventlog)
+                return;
+
+        ms_eventlog = RegisterEventSourceA(NULL, ident);
+
+		// note: RegisterEventAtSourceA may fail and return NULL.
+        //   in that case we'll just retry at the next message or not log
+}
+#define SYSLOG_MAX_MSG_SIZE 1024
+
+void syslog(int priority, const char *fmt, ...)
+{
+        WORD logtype;
+        char *str=static_cast<char *>(xmalloc(SYSLOG_MAX_MSG_SIZE));
+        int str_len;
+        va_list ap;
+
+        if (!ms_eventlog)
+                return;
+
+        va_start(ap, fmt);
+        str_len = vsnprintf(str, SYSLOG_MAX_MSG_SIZE-1, fmt, ap);
+        va_end(ap);
+
+        if (str_len < 0) {
+        	/* vsnprintf failed */
+            return;
+        }
+
+        switch (priority) {
+        case LOG_EMERG:
+        case LOG_ALERT:
+        case LOG_CRIT:
+        case LOG_ERR:
+                logtype = EVENTLOG_ERROR_TYPE;
+                break;
+
+        case LOG_WARNING:
+                logtype = EVENTLOG_WARNING_TYPE;
+                break;
+
+        case LOG_NOTICE:
+        case LOG_INFO:
+        case LOG_DEBUG:
+        default:
+                logtype = EVENTLOG_INFORMATION_TYPE;
+                break;
+        }
+
+        //Windows API suck. They are overengineered
+        ReportEventA(ms_eventlog, logtype, 0, 0, NULL, 1, 0,
+            const_cast<const char **>(&str), NULL);
+}
+
+
+/* note: this is all MSWindows-specific code; all of it should be conditional */
+#endif /* _SQUID_WINDOWS_ */

=== modified file 'compat/os/mswin.h'
--- compat/os/mswin.h	2011-08-26 16:50:49 +0000
+++ compat/os/mswin.h	2011-11-26 13:25:05 +0000
@@ -36,20 +36,27 @@
 
 #if _SQUID_WINDOWS_
 
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+#if HAVE_STRING_H
+#include <string.h>
+#endif /* HAVE_FCNTL_H */
+
 #define ACL WindowsACL
 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
 #if _MSC_VER == 1400
 #define _CRT_SECURE_NO_DEPRECATE
 #pragma warning( disable : 4290 )
 #pragma warning( disable : 4996 )
-#endif
-#endif
+#endif /* _MSC_VER == 1400 */
+#endif /* _MSC_VER */
 
 /* Some MinGW version defines min() and max() as macros
    causing the fail of the build process. The following
    #define will disable that definition
  */
-#if defined(__GNUC__)
+#if defined(__GNUC__) && !NOMINMAX
 #define NOMINMAX
 #endif
 
@@ -63,7 +70,7 @@
 typedef uint64_t ino_t;
 #else
 typedef unsigned long ino_t;
-#endif
+#endif /* __USE_FILE_OFFSET64 */
 
 #define INT64_MAX _I64_MAX
 #define INT64_MIN _I64_MIN
@@ -77,11 +84,11 @@
 
 #define THREADLOCAL __attribute__((section(".tls")))
 
-#endif
+#endif /* _MSC_VER */
 
 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
 #define alloca _alloca
-#endif
+#endif /* _MSC_VER */
 #define chdir _chdir
 #define dup _dup
 #define dup2 _dup2
@@ -89,19 +96,24 @@
 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
 #define fileno _fileno
 #define fstat _fstati64
-#endif
+#endif /* _MSC_VER */
+#if 0
 #define ftruncate WIN32_ftruncate
+#if !_SQUID_MINGW_
+extern int WIN32_ftruncate(int fd, off_t size);
+#endif
+#endif /* 0 */
 #define getcwd _getcwd
 #define getpid _getpid
-#define getrusage WIN32_getrusage
 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
 #define lseek _lseeki64
 #define memccpy _memccpy
-#define mkdir(p) _mkdir(p)
+#define mkdir(p,F) _mkdir((p))
 #define mktemp _mktemp
-#endif
+#else
+#define mkdir(p,F) mkdir((p)) // MinGW supplies mkdir with no permissions bits available.
+#endif /* _MSC_VER */
 #define pclose _pclose
-#define pipe WIN32_pipe
 #define popen _popen
 #define putenv _putenv
 #define setmode _setmode
@@ -114,8 +126,7 @@
 #define strlwr _strlwr
 #define strncasecmp _strnicmp
 #define tempnam _tempnam
-#endif
-#define truncate WIN32_truncate
+#endif /* _MSC_VER */
 #define umask _umask
 #define unlink _unlink
 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
@@ -151,7 +162,7 @@
 #define S_IRWXO 007
 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
 #define	S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
-#endif
+#endif /* _MSC_VER */
 
 #define	SIGHUP	1	/* hangup */
 #define	SIGKILL	9	/* kill (cannot be caught or ignored) */
@@ -161,7 +172,12 @@
 #define SIGUSR1 30	/* user defined signal 1 */
 #define SIGUSR2 31	/* user defined signal 2 */
 
-#if !_SQUID_CYGWIN_
+#if _SQUID_MINGW_
+typedef unsigned char boolean;
+typedef unsigned char u_char;
+typedef unsigned int u_int;
+#endif /* _SQUID_MINGW_ */
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
 typedef int uid_t;
 typedef int gid_t;
 #endif
@@ -201,7 +217,7 @@
     int	tz_minuteswest;	/* minutes west of Greenwich */
     int	tz_dsttime;	/* type of dst correction */
 };
-#endif
+#endif /* !HAVE_GETTIMEOFDAY */
 
 #define CHANGE_FD_SETSIZE 1
 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
@@ -210,10 +226,16 @@
 
 #include <process.h>
 #include <errno.h>
-#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#if _SQUID_MSWIN_ || _SQUID_MINGW_
+#if HAVE_WINSOCK2_H
 #include <winsock2.h>
+#elif HAVE_WINSOCK_H
+#include <winsock.h>
 #endif
+#undef IN_ADDR
 #include <ws2tcpip.h>
+#endif /* _SQUID_MSWIN_ || _SQUID_MINGW_ */
+
 #if (EAI_NODATA == EAI_NONAME)
 #undef EAI_NODATA
 #define EAI_NODATA WSANO_DATA
@@ -343,13 +365,10 @@
 __MINGW_IMPORT ioinfo * __pioinfo[];
 SQUIDCEXTERN int _free_osfhnd(int);
 
-#endif
+#endif /* _MSC_VER */
 
 SQUIDCEXTERN THREADLOCAL int ws32_result;
 
-#define strerror(e) WIN32_strerror(e)
-#define HAVE_STRERROR 1
-
 #ifdef __cplusplus
 
 inline
@@ -387,7 +406,7 @@
 {
     return _open(filename, oflag, pmode & (_S_IREAD | _S_IWRITE));
 }
-#endif
+#endif /* _MSC_VER */
 
 inline
 int read(int fd, void * buf, size_t siz)
@@ -426,11 +445,11 @@
 {
 /** \endcond */
 
-inline
-int accept(int s, struct sockaddr * a, size_t * l)
+inline int
+accept(int s, struct sockaddr * a, socklen_t * l)
 {
     SOCKET result;
-    if ((result = ::accept(_get_osfhandle(s), a, (int *)l)) == INVALID_SOCKET) {
+    if ((result = ::accept(_get_osfhandle(s), a, l)) == INVALID_SOCKET) {
         if (WSAEMFILE == (errno = WSAGetLastError()))
             errno = EMFILE;
         return -1;
@@ -438,8 +457,8 @@
         return _open_osfhandle(result, 0);
 }
 
-inline
-int bind(int s, struct sockaddr * n, int l)
+inline int
+bind(int s, const struct sockaddr * n, socklen_t l)
 {
     if (::bind(_get_osfhandle(s),n,l) == SOCKET_ERROR) {
         errno = WSAGetLastError();
@@ -448,8 +467,8 @@
         return 0;
 }
 
-inline
-int connect(int s, const struct sockaddr * n, int l)
+inline int
+connect(int s, const struct sockaddr * n, socklen_t l)
 {
     if (::connect(_get_osfhandle(s),n,l) == SOCKET_ERROR) {
         if (WSAEMFILE == (errno = WSAGetLastError()))
@@ -459,8 +478,9 @@
         return 0;
 }
 
-inline
-struct hostent * gethostbyname (const char *n) {
+inline struct hostent *
+gethostbyname(const char *n)
+{
     HOSTENT FAR * result;
     if ((result = ::gethostbyname(n)) == NULL)
         errno = WSAGetLastError();
@@ -468,8 +488,8 @@
 }
 #define gethostbyname(n) Squid::gethostbyname(n)
 
-inline
-SERVENT FAR* getservbyname (const char * n, const char * p)
+inline SERVENT FAR *
+getservbyname(const char * n, const char * p)
 {
     SERVENT FAR * result;
     if ((result = ::getservbyname(n, p)) == NULL)
@@ -478,28 +498,29 @@
 }
 #define getservbyname(n,p) Squid::getservbyname(n,p)
 
-inline
-HOSTENT FAR * gethostbyaddr(const char * a, int l, int t)
+inline HOSTENT FAR *
+gethostbyaddr(const void * a, size_t l, int t)
 {
     HOSTENT FAR * result;
-    if ((result = ::gethostbyaddr(a, l, t)) == NULL)
+    if ((result = ::gethostbyaddr((const char*)a, l, t)) == NULL)
         errno = WSAGetLastError();
     return result;
 }
 #define gethostbyaddr(a,l,t) Squid::gethostbyaddr(a,l,t)
 
-inline
-int getsockname(int s, struct sockaddr * n, size_t * l)
+inline int
+getsockname(int s, struct sockaddr * n, socklen_t * l)
 {
-    if ((::getsockname(_get_osfhandle(s), n, (int *)l)) == SOCKET_ERROR) {
+    if ((::getsockname(_get_osfhandle(s), n, l)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
         return -1;
     } else
         return 0;
 }
+#define getsockname(s,a,l) Squid::getsockname(s,a,l)
 
-inline
-int gethostname(char * n, size_t l)
+inline int
+gethostname(char * n, size_t l)
 {
     if ((::gethostname(n, l)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
@@ -509,8 +530,8 @@
 }
 #define gethostname(n,l) Squid::gethostname(n,l)
 
-inline
-int getsockopt(int s, int l, int o, void * v, int * n)
+inline int
+getsockopt(int s, int l, int o, void * v, socklen_t * n)
 {
     Sleep(1);
     if ((::getsockopt(_get_osfhandle(s), l, o,(char *) v, n)) == SOCKET_ERROR) {
@@ -521,8 +542,8 @@
 }
 
 /* Simple ioctl() emulation */
-inline
-int ioctl(int s, int c, void * a)
+inline int
+ioctl(int s, int c, void * a)
 {
     if ((::ioctlsocket(_get_osfhandle(s), c, (u_long FAR *)a)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
@@ -531,8 +552,8 @@
         return 0;
 }
 
-inline
-int ioctlsocket(int s, long c, u_long FAR * a)
+inline int
+ioctlsocket(int s, long c, u_long FAR * a)
 {
     if ((::ioctlsocket(_get_osfhandle(s), c, a)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
@@ -541,8 +562,8 @@
         return 0;
 }
 
-inline
-int listen(int s, int b)
+inline int
+listen(int s, int b)
 {
     if (::listen(_get_osfhandle(s), b) == SOCKET_ERROR) {
         if (WSAEMFILE == (errno = WSAGetLastError()))
@@ -553,30 +574,32 @@
 }
 #define listen(s,b) Squid::listen(s,b)
 
-inline
-int recv(int s, void * b, size_t l, int f)
+inline ssize_t
+recv(int s, void * b, size_t l, int f)
 {
-    int result;
+    ssize_t result;
     if ((result = ::recv(_get_osfhandle(s), (char *)b, l, f)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
         return -1;
     } else
         return result;
 }
+#define recv(s,b,l,f) Squid::recv(s,b,l,f)
 
-inline
-int recvfrom(int s, void * b, size_t l, int f, struct sockaddr * fr, size_t * fl)
+inline ssize_t
+recvfrom(int s, void * b, size_t l, int f, struct sockaddr * fr, socklen_t * fl)
 {
-    int result;
-    if ((result = ::recvfrom(_get_osfhandle(s), (char *)b, l, f, fr, (int *)fl)) == SOCKET_ERROR) {
+    ssize_t result;
+    if ((result = ::recvfrom(_get_osfhandle(s), (char *)b, l, f, fr, fl)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
         return -1;
     } else
         return result;
 }
+#define recvfrom(s,b,l,f,fr,fl) Squid::recvfrom(s,b,l,f,fr,fl)
 
-inline
-int select(int n, fd_set * r, fd_set * w, fd_set * e, struct timeval * t)
+inline int
+select(int n, fd_set * r, fd_set * w, fd_set * e, struct timeval * t)
 {
     int result;
     if ((result = ::select(n,r,w,e,t)) == SOCKET_ERROR) {
@@ -587,21 +610,22 @@
 }
 #define select(n,r,w,e,t) Squid::select(n,r,w,e,t)
 
-inline
-int send(int s, const void * b, size_t l, int f)
+inline ssize_t
+send(int s, const void * b, size_t l, int f)
 {
-    int result;
+    ssize_t result;
     if ((result = ::send(_get_osfhandle(s), (char *)b, l, f)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
         return -1;
     } else
         return result;
 }
+#define send(s,b,l,f) Squid::send(s,b,l,f)
 
-inline
-int sendto(int s, const void * b, size_t l, int f, const struct sockaddr * t, int tl)
+inline ssize_t
+sendto(int s, const void * b, size_t l, int f, const struct sockaddr * t, socklen_t tl)
 {
-    int result;
+    ssize_t result;
     if ((result = ::sendto(_get_osfhandle(s), (char *)b, l, f, t, tl)) == SOCKET_ERROR) {
         errno = WSAGetLastError();
         return -1;
@@ -609,14 +633,14 @@
         return result;
 }
 
-inline
-int setsockopt(SOCKET s, int l, int o, const char * v, int n)
+inline int
+setsockopt(SOCKET s, int l, int o, const void * v, socklen_t n)
 {
     SOCKET socket;
 
     socket = ((s == INVALID_SOCKET) ? s : (SOCKET)_get_osfhandle((int)s));
 
-    if (::setsockopt(socket, l, o, v, n) == SOCKET_ERROR) {
+    if (::setsockopt(socket, l, o, (const char *)v, n) == SOCKET_ERROR) {
         errno = WSAGetLastError();
         return -1;
     } else
@@ -624,8 +648,8 @@
 }
 #define setsockopt(s,l,o,v,n) Squid::setsockopt(s,l,o,v,n)
 
-inline
-int shutdown(int s, int h)
+inline int
+shutdown(int s, int h)
 {
     if (::shutdown(_get_osfhandle(s),h) == SOCKET_ERROR) {
         errno = WSAGetLastError();
@@ -634,8 +658,8 @@
         return 0;
 }
 
-inline
-int socket(int f, int t, int p)
+inline int
+socket(int f, int t, int p)
 {
     SOCKET result;
     if ((result = ::socket(f, t, p)) == INVALID_SOCKET) {
@@ -724,6 +748,7 @@
 #define	RUSAGE_SELF	0		/* calling process */
 #define	RUSAGE_CHILDREN	-1		/* terminated child processes */
 
+#define HAVE_RUSAGE 1
 struct rusage {
     struct timeval ru_utime;	/* user time used */
     struct timeval ru_stime;	/* system time used */
@@ -746,11 +771,31 @@
 
 #undef ACL
 
-#if !defined(getpagesize)
+SQUIDCEXTERN int chroot(const char *dirname);
+SQUIDCEXTERN int kill(pid_t, int);
+SQUIDCEXTERN int statfs(const char *, struct statfs *);
+SQUIDCEXTERN struct passwd * getpwnam(char *unused);
+SQUIDCEXTERN struct group * getgrnam(char *unused);
+
+#define geteuid(X)  static_cast<uid_t>(100)
+#define seteuid(X)  (void)0
+#define getuid(X)   static_cast<uid_t>(100)
+#define setuid(X)   (void)0
+#define getegid(X)  static_cast<gid_t>(100)
+#define setegid(X)  (void)0
+#define getgid(X)   static_cast<gid_t>(100)
+#define setgid(X)   (void)0
+
+#if !HAVE_GETPAGESIZE
 /* Windows may lack getpagesize() prototype */
-SQUIDCEXTERN size_t getpagesize(void);
+SQUIDCEXTERN size_t getpagesize();
+#define HAVE_GETPAGESIZE 2
 #endif
 
+SQUIDCEXTERN void WIN32_ExceptionHandlerInit(void);
+SQUIDCEXTERN int Win32__WSAFDIsSet(int fd, fd_set* set);
+SQUIDCEXTERN DWORD WIN32_IpAddrChangeMonitorInit();
+
 /* gcc doesn't recognize the Windows native 64 bit formatting tags causing
  * the compile fail, so we must disable the check on native Windows.
  */
@@ -760,5 +805,61 @@
 #define PRINTF_FORMAT_ARG3
 #endif
 
+#if !HAVE_SYSLOG
+/* syslog compatibility layer derives from git */
+#define LOG_PID     0x01
+#define LOG_EMERG   0
+#define LOG_ALERT   1
+#define LOG_CRIT    2
+#define LOG_ERR     3
+#define LOG_WARNING 4
+#define LOG_NOTICE  5
+#define LOG_INFO    6
+#define LOG_DEBUG   7
+#define LOG_DAEMON  (3<<3)
+
+void openlog(const char *ident, int logopt, int facility);
+void syslog(int priority, const char *fmt, ...);
+#endif
+
+#if _SQUID_MINGW_
+/* broken mingw header... */
+# ifdef WSA_CMSG_FIRSTHDR
+#  define CMSG_FIRSTHDR(x) WSA_CMSG_FIRSTHDR(x)
+# endif
+# ifdef WSA_CMSG_NXTHDR
+#  define CMSG_NXTHDR(x, y) WSA_CMSG_NXTHDR(x, y)
+# endif
+# ifdef WSA_CMSG_DATA
+#  define CMSG_DATA(x) WSA_CMSG_DATA(x)
+# endif
+# ifdef WSA_CMSG_LEN
+#  define CMSG_LEN(x) WSA_CMSG_LEN(x)
+# endif
+# ifdef WSA_CMSG_SPACE
+#  define CMSG_SPACE(x) WSA_CMSG_SPACE(x)
+# endif
+# ifdef WSA_CMSG_FIRSTHDR
+#  define CMSG_FIRSTHDR(x) WSA_CMSG_FIRSTHDR(x)
+# endif
+
+/* MinGW missing bits from sys/wait.h */
+/* A status looks like:
+ *  <2 bytes info> <2 bytes code>
+ *
+ *  <code> == 0, child has exited, info is the exit value
+ *  <code> == 1..7e, child has exited, info is the signal number.
+ *  <code> == 7f, child has stopped, info was the signal number.
+ *  <code> == 80, there was a core dump.
+ */
+#define WIFEXITED(w)    (((w) & 0xff) == 0)
+#define WIFSIGNALED(w)  (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
+#define WIFSTOPPED(w)   (((w) & 0xff) == 0x7f)
+#define WEXITSTATUS(w)  (((w) >> 8) & 0xff)
+#define WTERMSIG(w) ((w) & 0x7f)
+#define WSTOPSIG    WEXITSTATUS
+
+#endif
+
 #endif /* _SQUID_WINDOWS_ */
 #endif /* SQUID_OS_MSWIN_H */

=== modified file 'compat/os/windows.h'
--- compat/os/windows.h	2011-01-28 07:58:53 +0000
+++ compat/os/windows.h	2011-06-02 16:47:24 +0000
@@ -45,5 +45,9 @@
 #undef _MSWIN_ACL_WAS_NOT_DEFINED
 #endif
 
+#ifndef USE_REGULAR_COPY
+#define USE_REGULAR_COPY 1
+#endif
+
 #endif /* _SQUID_WINDOWS_ */
 #endif /* SQUID_OS_WINDOWS_H */

=== modified file 'compat/osdetect.h'
--- compat/osdetect.h	2011-01-28 08:16:17 +0000
+++ compat/osdetect.h	2011-01-28 08:28:11 +0000
@@ -74,11 +74,13 @@
 #define _SQUID_WINDOWS_ 1
 
 #elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32)
-/* We are using _SQUID_MSWIN_ define in cf.data.pre, so
-   it must be defined to 1 to avoid the build failure of cfgen.
- */
+#define _SQUID_WINDOWS_ 1
+
+// TODO: isolate this section better so only Visual Studio build environment
+//       gets detected and a macro defined for it.
+
+// the old name for MSVC *and* MingW (TODO: remove from use)
 #define _SQUID_MSWIN_ 1
-#define _SQUID_WINDOWS_ 1
 
 #elif defined(__APPLE__)
 #define _SQUID_APPLE_ 1

=== modified file 'compat/types.h'
--- compat/types.h	2011-08-02 07:31:53 +0000
+++ compat/types.h	2012-01-15 02:22:39 +0000
@@ -122,6 +122,21 @@
 #endif
 #endif
 
+#ifndef PRIuSIZE
+// TODO: check for support of %zu and use where possible
+#if SIZEOF_SIZE_T == 4 && _SQUID_MINGW_
+#define PRIuSIZE "I32u"
+#elif SIZEOF_SIZE_T == 4
+#define PRIuSIZE "u"
+#elif SIZEOF_SIZE_T == 8 && _SQUID_MINGW_
+#define PRIuSIZE "I64u"
+#elif SIZEOF_SIZE_T == 8
+#define PRIuSIZE "lu"
+#else
+#error size_t is not 32-bit or 64-bit
+#endif
+#endif /* PRIuSIZE */
+
 #ifndef HAVE_MODE_T
 typedef unsigned short mode_t;
 #endif

=== modified file 'helpers/negotiate_auth/wrapper/config.test'
--- helpers/negotiate_auth/wrapper/config.test	2011-04-15 11:51:15 +0000
+++ helpers/negotiate_auth/wrapper/config.test	2011-05-27 11:56:58 +0000
@@ -1,2 +1,12 @@
 #!/bin/sh
+
+exit 1
+
+# Don't build on Windows
+if [ -f /usr/include/w32api/windows.h ]; then
+        exit 1
+fi
+if [ -f /usr/include/windows.h ]; then
+        exit 1
+fi
 exit 0

=== modified file 'helpers/ntlm_auth/SSPI/Makefile.am'
--- helpers/ntlm_auth/SSPI/Makefile.am	2010-06-28 10:51:55 +0000
+++ helpers/ntlm_auth/SSPI/Makefile.am	2011-05-31 14:48:17 +0000
@@ -7,8 +7,9 @@
 ntlm_sspi_auth_SOURCES = ntlm_sspi_auth.cc
 
 LDADD = \
-	-L$(top_builddir)/libntlmauth -lntlmauth \
+	$(top_builddir)/lib/ntlmauth/libntlmauth.la \
 	-L$(top_builddir)/lib -lsspwin32 \
+	$(top_builddir)/lib/libmiscencoding.la \
 	$(COMPAT_LIB) \
 	-lnetapi32 \
 	-ladvapi32 \

=== modified file 'helpers/ntlm_auth/SSPI/ntlm_sspi_auth.cc'
--- helpers/ntlm_auth/SSPI/ntlm_sspi_auth.cc	2011-05-03 00:12:39 +0000
+++ helpers/ntlm_auth/SSPI/ntlm_sspi_auth.cc	2011-05-28 14:29:29 +0000
@@ -64,9 +64,10 @@
 typedef unsigned char uchar;
 
 #include "config.h"
+#include "base64.h"
 #include "helpers/defines.h"
-#include "libntlmauth/ntlmauth.h"
-#include "libntlmauth/support_bits.h"
+#include "ntlmauth/ntlmauth.h"
+#include "ntlmauth/support_bits.cci"
 #include "sspwin32.h"
 #include "util.h"
 
@@ -95,6 +96,17 @@
 int fail_debug_enabled = 0;
 #endif
 
+/* A couple of harmless helper macros */
+#define SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n");
+#ifdef __GNUC__
+#define SEND2(X,Y...) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
+#define SEND3(X,Y...) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
+#else
+/* no gcc, no debugging. varargs macros are a gcc extension */
+#define SEND2(X,Y) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
+#define SEND3(X,Y,Z) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y,Z);
+#endif
+
 /* returns 1 on success, 0 on failure */
 int
 Valid_Group(char *UserName, char *Group)
@@ -274,11 +286,12 @@
     return DomainName;
 }
 
-/* returns NULL on failure, or a pointer to
- * the user's credentials (domain\\username)
- * upon success. WARNING. It's pointing to static storage.
- * In case of problem sets as side-effect ntlm_errno to one of the
- * codes defined in libntlmauth/ntlmauth.h
+/*
+ * Sets user and domain parameters to the user's
+ * credentials (domain\\username) upon success.
+ *
+ * In case of problem returns an NTLM auth error
+ * code defined in ntlmauth/ntlmauth.h
  */
 int
 ntlm_check_auth(ntlm_authenticate * auth, char *user, char *domain, int auth_length)
@@ -286,7 +299,6 @@
     int x;
     int rv;
     char credentials[DNLEN+UNLEN+2];	/* we can afford to waste */
-    lstring tmp;
 
     if (!NTLM_LocalCall) {
 
@@ -418,7 +430,7 @@
     char decoded[BUFFER_SIZE];
     int decodedLen;
     char helper_command[3];
-    char *c, *cred;
+    char *c;
     int oversized = 0;
     char * ErrorMessage;
     static ntlm_negotiate local_nego;
@@ -427,10 +439,10 @@
 
     /* NP: for some reason this helper sometimes needs to accept
      * from clients that send no negotiate packet. */
-    if (memcpy(local_nego.signature, "NTLMSSP", 8) != 0) {
+    if (memcpy(local_nego.hdr.signature, "NTLMSSP", 8) != 0) {
         memset(&local_nego, 0, sizeof(ntlm_negotiate));	/* reset */
-        memcpy(local_nego.signature, "NTLMSSP", 8);     /* set the signature */
-        local_nego.type = le32toh(NTLM_NEGOTIATE);      /* this is a challenge */
+        memcpy(local_nego.hdr.signature, "NTLMSSP", 8);     /* set the signature */
+        local_nego.hdr.type = le32toh(NTLM_NEGOTIATE);      /* this is a challenge */
         local_nego.flags = le32toh(NTLM_NEGOTIATE_ALWAYS_SIGN |
                                    NTLM_NEGOTIATE_USE_NTLM |
                                    NTLM_NEGOTIATE_USE_LM |
@@ -441,7 +453,7 @@
     if (fgets(buf, BUFFER_SIZE, stdin) == NULL)
         return 0;
 
-    c = memchr(buf, '\n', BUFFER_SIZE);	/* safer against overrun than strchr */
+    c = static_cast<char*>(memchr(buf, '\n', BUFFER_SIZE));	/* safer against overrun than strchr */
     if (c) {
         if (oversized) {
             helperfail("illegal request received");
@@ -458,7 +470,7 @@
         decodedLen = base64_decode(decoded, sizeof(decoded), buf+3);
         strncpy(helper_command, buf, 2);
         debug("Got '%s' from Squid with data:\n", helper_command);
-        hex_dump(decoded, decodedLen);
+        hex_dump((unsigned char*)decoded, decodedLen);
     } else
         debug("Got '%s' from Squid\n", buf);
     if (memcmp(buf, "YR", 2) == 0) {	/* refresh-request */
@@ -467,8 +479,8 @@
             decodedLen = base64_decode(decoded, sizeof(decoded), buf+3);
         else {
             debug("Negotiate packet not supplied - self generated\n");
-            memcpy(decoded, local_lego, sizeof(local_nego));
-            decodedLen = sizeof(localnego);
+            memcpy(decoded, &local_nego, sizeof(local_nego));
+            decodedLen = sizeof(local_nego);
         }
         if ((size_t)decodedLen < sizeof(ntlmhdr)) {		/* decoding failure, return error */
             SEND("NA Packet format error, couldn't base64-decode");
@@ -491,9 +503,10 @@
                     printf("TT %s\n",c);
                     decodedLen = base64_decode(decoded, sizeof(decoded), c);
                     debug("sending 'TT' to squid with data:\n");
-                    hex_dump(decoded, decodedLen);
-                    if (NTLM_LocalCall)
+                    hex_dump((unsigned char *)decoded, decodedLen);
+                    if (NTLM_LocalCall) {
                         debug("NTLM Local Call detected\n");
+                    }
                 } else {
                     SEND2("TT %s", c);
                 }
@@ -548,14 +561,15 @@
             return 1;
             /* notreached */
         case NTLM_AUTHENTICATE:
+        {
             /* check against SSPI */
-            err = ntlm_check_auth((ntlm_authenticate *) decoded, user, domain, decodedLen);
+            int err = ntlm_check_auth((ntlm_authenticate *) decoded, user, domain, decodedLen);
             have_challenge = 0;
             if (err != NTLM_ERR_NONE) {
 #if FAIL_DEBUG
                 fail_debug_enabled =1;
 #endif
-                switch (ntlm_errno) {
+                switch (err) {
                 case NTLM_ERR_NONE:
                     break;
                 case NTLM_BAD_NTGROUP:
@@ -588,8 +602,11 @@
                 }
             }
             /* let's lowercase them for our convenience */
-            SEND3("AF %s\\%s", lc(domain), lc(user));
+            lc(domain);
+            lc(user);
+            SEND3("AF %s\\%s", domain, user);
             return 1;
+        }
         default:
             helperfail("unknown authentication packet type");
             return 1;

=== removed file 'include/squid_windows.h'
--- include/squid_windows.h	2011-01-28 07:58:53 +0000
+++ include/squid_windows.h	1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
-/*
- * $Id$
- *
- * AUTHOR: Guido Serassio <seras...@squid-cache.org>
- *
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-#ifndef _INC_SQUID_WINDOWS_H
-#define _INC_SQUID_WINDOWS_H
-
-#if _SQUID_WINDOWS_
-
-#ifndef ACL
-#define ACL WindowsACL
-#define _MSWIN_ACL_WAS_NOT_DEFINED 1
-#endif
-#include <windows.h>
-#if _MSWIN_ACL_WAS_NOT_DEFINED
-#undef ACL
-#undef _MSWIN_ACL_WAS_NOT_DEFINED
-#endif
-
-#endif /* _SQUID_WINDOWS_ */
-#endif /* _INC_SQUID_WINDOWS_H */

=== modified file 'include/sspwin32.h'
--- include/sspwin32.h	2011-01-28 07:58:53 +0000
+++ include/sspwin32.h	2011-05-28 14:29:29 +0000
@@ -34,6 +34,10 @@
 #ifndef _LIBSSPWIN32_H_
 #define _LIBSSPWIN32_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if _SQUID_WINDOWS_
 
 #define SECURITY_WIN32
@@ -66,7 +70,7 @@
 #define SSP_OK 1
 #define SSP_ERROR 2
 
-HMODULE LoadSecurityDll(int, char *);
+HMODULE LoadSecurityDll(int, const char *);
 void UnloadSecurityDll(void);
 BOOL WINAPI SSP_LogonUser(PTSTR, PTSTR, PTSTR);
 BOOL WINAPI SSP_ValidateNTLMCredentials(PVOID, int, char *);
@@ -77,5 +81,8 @@
 extern BOOL Use_Unicode;
 extern BOOL NTLM_LocalCall;
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* _SQUID_WINDOWS_ */
 #endif /* LIBSSPWIN32_H_ */

=== modified file 'include/util.h'
--- include/util.h	2012-01-05 14:12:04 +0000
+++ include/util.h	2012-01-14 07:42:56 +0000
@@ -112,27 +112,4 @@
 
 SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what);
 
-/* Windows Port */
-/* win32lib.c */
-#if _SQUID_MSWIN_
-SQUIDCEXTERN int chroot (const char *);
-SQUIDCEXTERN int ftruncate(int, off_t);
-#if !HAVE_GETTIMEOFDAY
-SQUIDCEXTERN int gettimeofday(struct timeval * ,void *);
-#endif
-SQUIDCEXTERN int kill(pid_t, int);
-SQUIDCEXTERN int statfs(const char *, struct statfs *);
-SQUIDCEXTERN int truncate(const char *, off_t);
-SQUIDCEXTERN struct passwd *getpwnam(char *);
-SQUIDCEXTERN struct group *getgrnam(char *);
-SQUIDCEXTERN uid_t geteuid(void);
-SQUIDCEXTERN uid_t getuid(void);
-SQUIDCEXTERN int setuid(uid_t);
-SQUIDCEXTERN int seteuid(uid_t);
-SQUIDCEXTERN gid_t getgid(void);
-SQUIDCEXTERN gid_t getegid(void);
-SQUIDCEXTERN int setgid(gid_t);
-SQUIDCEXTERN int setegid(gid_t);
-SQUIDCEXTERN void WIN32_maperror(unsigned long);
-#endif
 #endif /* SQUID_UTIL_H */

=== modified file 'lib/rfcnb/rfcnb-io.c'
--- lib/rfcnb/rfcnb-io.c	2011-01-10 16:55:29 +0000
+++ lib/rfcnb/rfcnb-io.c	2011-01-28 08:28:11 +0000
@@ -29,8 +29,18 @@
 #include "rfcnb/rfcnb-priv.h"
 #include "rfcnb/rfcnb-util.h"
 #include "rfcnb/rfcnb-io.h"
+#if HAVE_SYS_UIO_H
 #include <sys/uio.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#if HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+#if HAVE_SYS_SIGNAL_H
 #include <sys/signal.h>
+#endif
 
 #if HAVE_STRING_H
 #include <string.h>

=== modified file 'lib/rfcnb/std-includes.h'
--- lib/rfcnb/std-includes.h	2010-12-14 14:01:14 +0000
+++ lib/rfcnb/std-includes.h	2011-01-28 08:28:11 +0000
@@ -29,17 +29,44 @@
 #define BOOL int
 typedef short int16;
 
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#if HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
+#if HAVE_NETDB_H
 #include <netdb.h>
+#endif
+#if HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+#if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#if HAVE_SIGNAL_H
 #include <signal.h>
+#endif
+#if HAVE_ERRNO_H
 #include <errno.h>
+#endif
+#if HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
+#ifndef TRUE
 #define TRUE 1
+#endif
+#ifndef FALSE
 #define FALSE 0
+#endif
 
 /* Pick up define for INADDR_NONE */
 

=== modified file 'lib/sspwin32.c'
--- lib/sspwin32.c	2010-11-20 11:31:38 +0000
+++ lib/sspwin32.c	2011-05-28 14:29:29 +0000
@@ -34,11 +34,11 @@
  */
 
 #include "config.h"
+#include "base64.h"
+#include "ntlmauth/ntlmauth.h"
+#include "sspwin32.h"
 #include "util.h"
 
-#include "libntlmauth/ntlmauth.h"
-#include "sspwin32.h"
-
 typedef struct _AUTH_SEQ {
     BOOL fInitialized;
     BOOL fHaveCredHandle;
@@ -109,7 +109,7 @@
 }
 
 
-HMODULE LoadSecurityDll(int mode, char * SSP_Package)
+HMODULE LoadSecurityDll(int mode, const char * SSP_Package)
 {
     TCHAR lpszDLL[MAX_PATH];
     OSVERSIONINFO VerInfo;
@@ -520,8 +520,8 @@
     } while (0);
     if (fResult != NULL) {
         challenge = (ntlm_challenge *) fResult;
-        Use_Unicode = NEGOTIATE_UNICODE & challenge->flags;
-        NTLM_LocalCall = NEGOTIATE_THIS_IS_LOCAL_CALL & challenge->flags;
+        Use_Unicode = NTLM_NEGOTIATE_UNICODE & challenge->flags;
+        NTLM_LocalCall = NTLM_NEGOTIATE_THIS_IS_LOCAL_CALL & challenge->flags;
         encoded = base64_encode_bin((char *) fResult, cbOut);
     }
     return encoded;

=== modified file 'src/DiskIO/AIO/aio_win32.h'
--- src/DiskIO/AIO/aio_win32.h	2011-07-23 08:37:52 +0000
+++ src/DiskIO/AIO/aio_win32.h	2011-07-24 12:39:06 +0000
@@ -36,10 +36,6 @@
 
 #if USE_DISKIO_AIO
 
-#if _SQUID_CYGWIN_
-#include "squid_windows.h"
-#endif
-
 #ifndef off64_t
 typedef int64_t	off64_t;
 #endif

=== modified file 'src/DiskIO/DiskThreads/aiops_win32.cc'
--- src/DiskIO/DiskThreads/aiops_win32.cc	2010-12-13 11:31:14 +0000
+++ src/DiskIO/DiskThreads/aiops_win32.cc	2011-01-28 09:20:51 +0000
@@ -35,7 +35,6 @@
  */
 
 #include "squid.h"
-#include "squid_windows.h"
 #include "CommIO.h"
 #include "DiskThreads.h"
 #include "SquidTime.h"

=== modified file 'src/WinSvc.cc'
--- src/WinSvc.cc	2011-11-26 12:12:26 +0000
+++ src/WinSvc.cc	2011-11-26 13:25:05 +0000
@@ -35,7 +35,6 @@
  */
 
 #include "squid.h"
-#include "squid_windows.h"
 
 #if _SQUID_MSWIN_
 #ifndef _MSWSOCK_

=== modified file 'src/acl/HttpStatus.cc'
--- src/acl/HttpStatus.cc	2011-01-28 07:58:53 +0000
+++ src/acl/HttpStatus.cc	2011-01-28 09:20:51 +0000
@@ -35,9 +35,6 @@
  */
 
 #include "config.h"
-#if _SQUID_CYGWIN_
-#include <squid_windows.h>
-#endif
 #include "squid.h"
 
 #include "acl/HttpStatus.h"

=== modified file 'src/acl/Ip.cc'
--- src/acl/Ip.cc	2010-07-25 08:10:12 +0000
+++ src/acl/Ip.cc	2011-06-01 11:09:08 +0000
@@ -34,9 +34,9 @@
  */
 
 #include "squid.h"
-//#include "compat/getaddrinfo.h"
 #include "acl/Ip.h"
 #include "acl/Checklist.h"
+#include "compat/getaddrinfo.h"
 #include "ip/tools.h"
 #include "MemBuf.h"
 #include "wordlist.h"

=== modified file 'src/cf.data.pre'
--- src/cf.data.pre	2012-01-06 20:41:21 +0000
+++ src/cf.data.pre	2012-01-19 21:00:56 +0000
@@ -7640,7 +7640,7 @@
 DOC_END
 
 NAME: windows_ipaddrchangemonitor
-IFDEF: _SQUID_MSWIN_
+IFDEF: _SQUID_WINDOWS_
 COMMENT: on|off
 TYPE: onoff
 DEFAULT: on

Reply via email to