]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Windows port: first chunk of fixes needed to build again Squid3 using MinGW
authorGuido Serassio <serassio@squid-cache.org>
Sun, 31 May 2009 17:20:44 +0000 (19:20 +0200)
committerGuido Serassio <serassio@squid-cache.org>
Sun, 31 May 2009 17:20:44 +0000 (19:20 +0200)
compat/os/mswin.h
compat/osdetect.h
configure.in
helpers/basic_auth/mswin_sspi/valid.c
src/Makefile.am
src/acl/Arp.cc
src/dns_internal.cc
src/main.cc
src/ufsdump.cc

index fd0860c9fac32cd19d26771b538fa046ab3810cb..17467f5bf2711ee40f51d938bf07bcd3f29411e8 100644 (file)
 #endif
 #endif
 
+/* 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__)
+#define NOMINMAX
+#endif
+
 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
 # define __USE_FILE_OFFSET64   1
 #endif
@@ -720,49 +728,5 @@ struct rusage {
 
 #undef ACL
 
-
-/** \cond AUTODOCS-IGNORE */
-using namespace Squid;
-/** \endcond */
-
-
-/* win32lib.c */
-SQUIDCEXTERN int chroot (const char *);
-SQUIDCEXTERN int ftruncate(int, off_t);
-#ifndef 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 const char * wsastrerror(int);
-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 const char *WIN32_strerror(int);
-SQUIDCEXTERN void WIN32_maperror(unsigned long);
-
-// Moved in from squid.h and other duplicates.
-// BUT was already included up the top there with a wrapped conditional.
-// that may need checking....
-//#include <io.h>
-
-/* Windows may lack getpagesize() prototype */
-// Moved in from squid.h
-// NP: there may be a header include needed before this to prevent duplicate-definitions
-//     if that is true it will need including here as part of the hack.
-//     if not then this comment can be dropped.
-#if !defined(getpagesize)
-SQUIDCEXTERN size_t getpagesize(void);
-#endif
-
-
 #endif /* _SQUID_WIN32_ */
 #endif /* SQUID_OS_MSWIN_H */
index fb1eb9acad11abdd1ad7b0e9282c658ba807fa70..bb8b1e1d0eae05dfcae268c011999383064c60f9 100644 (file)
 #define _SQUID_WIN32_
 
 #elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32)
-#define _SQUID_MSWIN_
+/* 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_MSWIN_ 1
 #define _SQUID_WIN32_
 
 #elif defined(__APPLE__)
index 62e86a85a1ecbdee4134a7628b82153dacb441e3..948c6f4bcb45b5ec7533002032adcb95a3f10717 100644 (file)
@@ -3449,9 +3449,11 @@ main ()
        WSAStartup(2, &wsaData);
 #endif
        if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
-        if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+        if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) exit(1);
        WSACleanup();
+#else
+        if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
 #endif
        if (val<=0) exit(1);
         fp = fopen("conftestval", "w");
@@ -3492,9 +3494,11 @@ main ()
        WSAStartup(2, &wsaData);
 #endif
        if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
-        if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+        if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) exit(1);
        WSACleanup();
+#else
+        if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
 #endif
        if (val <= 0) exit(1);
        fp = fopen("conftestval", "w"); 
@@ -3535,9 +3539,11 @@ main ()
        WSAStartup(2, &wsaData);
 #endif
        if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
-        if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+        if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) exit(1);
        WSACleanup();
+#else
+        if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
 #endif
        if (val <= 0) exit(1);
        fp = fopen("conftestval", "w"); 
@@ -3582,9 +3588,11 @@ main ()
        WSAStartup(2, &wsaData);
 #endif
        if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
-        if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+        if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) exit(1);
        WSACleanup();
+#else
+        if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
 #endif
        if (val <= 0) exit(1);
        fp = fopen("conftestval", "w"); 
index ecb15c83110fda6e98b0ac3076313a17bd8686a1..42c1747f8540fa21d14af4c09f81f38049d48d15 100644 (file)
@@ -125,7 +125,7 @@ Valid_User(char *UserName, char *Password, char *Group)
     int result = NTV_SERVER_ERROR;
     size_t i;
     char NTDomain[256];
-    char *domain_qualify;
+    char *domain_qualify = NULL;
     char DomainUser[256];
     char User[256];
 
index 8c02760907931bb5e2e14536043d5df4828dc78f..70d06f3e62875264cb16efd125f743111d4c266b 100644 (file)
@@ -517,6 +517,7 @@ nodist_squid_SOURCES = \
 squid_LDADD = \
        $(COMMON_LIBS) \
        icmp/libicmp.la icmp/libicmp-core.la \
+        ../compat/libcompat.la \
        -L../lib \
        @XTRA_OBJS@ \
        @DISK_LINKOBJS@ \
index 7d341a01e6aa8f45ca9dd7befb505c63a3a79532..0108c9a76b04666b0352e97a5f58460e3d47b820 100644 (file)
@@ -243,7 +243,9 @@ int
 aclMatchArp(SplayNode<acl_arp_data *> **dataptr, IpAddress &c)
 {
     struct arpreq arpReq;
+#if !defined(_SQUID_WIN32_)
     struct sockaddr_in *sa = NULL;
+#endif
 
     IpAddress ipAddr = c;
 
index 224de5c20cfbd47a1dc3be55ddba248e89e822dc..15982731d3825f17a138c219d3806120b622dd39 100644 (file)
@@ -480,15 +480,14 @@ idnsParseWIN32Registry(void)
 
        if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_TCPIP_PARA_INTERFACES, 0, KEY_READ, &hndKey) == ERROR_SUCCESS) {
             int i;
-           int MaxSubkeyLen;
-           DWORD InterfacesCount;
+           DWORD MaxSubkeyLen, InterfacesCount;
            char *keyname;
            FILETIME ftLastWriteTime;
 
            if (RegQueryInfoKey(hndKey, NULL, NULL, NULL, &InterfacesCount, &MaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
                keyname = (char *) xmalloc(++MaxSubkeyLen);
                for (i = 0; i < (int) InterfacesCount; i++) {
-                   int j;
+                   DWORD j;
                    j = MaxSubkeyLen;
                    if (RegEnumKeyEx(hndKey, i, keyname, &j, NULL, NULL, NULL, &ftLastWriteTime) == ERROR_SUCCESS) {
                        char *newkeyname;
@@ -503,7 +502,7 @@ idnsParseWIN32Registry(void)
                            Result = RegQueryValueEx(hndKey2, "DhcpNameServer", NULL, &Type, NULL, &Size);
                            if (Result == ERROR_SUCCESS && Size) {
                                t = (char *) xmalloc(Size);
-                               RegQueryValueEx(hndKey2, "DhcpNameServer", NULL, &Type, t, &Size);
+                               RegQueryValueEx(hndKey2, "DhcpNameServer", NULL, &Type, (LPBYTE)t, &Size);
                                token = strtok(t, ", ");
                                while (token) {
                                     debugs(78, 1, "Adding DHCP nameserver " << token << " from Registry");
@@ -516,7 +515,7 @@ idnsParseWIN32Registry(void)
                            Result = RegQueryValueEx(hndKey2, "NameServer", NULL, &Type, NULL, &Size);
                            if (Result == ERROR_SUCCESS && Size) {
                                t = (char *) xmalloc(Size);
-                               RegQueryValueEx(hndKey2, "NameServer", NULL, &Type, t, &Size);
+                               RegQueryValueEx(hndKey2, "NameServer", NULL, &Type, (LPBYTE)t, &Size);
                                token = strtok(t, ", ");
                                while (token) {
                                    debugs(78, 1, "Adding nameserver " << token << " from Registry");
index f044b0be4170d37643d1f96487db2a4e7d1d3356..7aac0a18c700ee2333da06f1b55036355b349270 100644 (file)
@@ -1094,7 +1094,7 @@ mainInitialize(void)
 }
 
 /// unsafe main routine -- may throw
-static int SquidMain(int argc, char **argv);
+int SquidMain(int argc, char **argv);
 /// unsafe main routine wrapper to catch exceptions
 static int SquidMainSafe(int argc, char **argv);
 
@@ -1125,7 +1125,7 @@ SquidMainSafe(int argc, char **argv)
     return -1; // not reached
 }
 
-static int
+int
 SquidMain(int argc, char **argv)
 {
 #ifdef _SQUID_WIN32_
index e65e93234d6a856e948754c43f8fb384079659d1..9daf167934d821ed884cc379fe6fd9d876058eef 100644 (file)
@@ -82,6 +82,14 @@ CacheManager::GetInstance()
 void
 CacheManager::registerAction(char const * action, char const * desc, OBJH * handler, int pw_req_flag, int atomic) {}
 
+/* MinGW needs also a stub of death() */
+void
+death(int sig)
+{
+    std::cout << "Fatal: Signal " <<  sig;
+    exit (1);
+}
+
 
 /* end stub functions */