my patch 1 of 2

[email protected] Sat, 02 May 2015 07:17:33 +0900
Newsgroups gmane.comp.web.polipo.user
Message-ID <20150502071733.1a27177f%[email protected]>
I downloaded source from GitHub 2015 Mar. 27.
Please try these changes.

Changes :
 bugfix
 move variable definition location in function for C language style
 Visual C++ support ( merge from polipovc  http://code.google.com/p/polipovc/ )

If you use Visual Studio, Add stdint.h and inttypes.h from polipovc
and make new solution file, or, modify by yourself.
I tested on Visual C++ 2010 Express Edition.
New version is here.
https://www.visualstudio.com/en-us/products/visual-studio-community-vs
It is very convenient to debug on Visual Studio. However, It seems that
MinGW build is faster to run.


diff -Nur ./polipo-master/config.c ./polipo-1.1.2/config.c
--- ./polipo-master/config.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/config.c	Tue Apr 28 18:25:38 2015
@@ -852,7 +852,7 @@
 configFloatSetter(ConfigVariablePtr var, void* value)
 {
     assert(var->type == CONFIG_FLOAT);
-    *var->value.i = *(float*)value;
+    *var->value.f = *(float*)value;
     return 1;
 }
 
diff -Nur ./polipo-master/object.c ./polipo-1.1.2/object.c
--- ./polipo-master/object.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/object.c	Tue Apr 28 18:25:38 2015
@@ -985,8 +985,8 @@
         if(object->last_modified >= 0)
             /* Again, take care of clock skew */
             stale = MIN(stale,
-                        object->age +
-                        (date - object->last_modified) * maxAgeFraction);
+                        (int) (object->age +
+                        (date - object->last_modified) * maxAgeFraction) );
         else
             stale = MIN(stale, object->age + maxNoModifiedAge);
     }
diff -Nur ./polipo-master/server.c ./polipo-1.1.2/server.c
--- ./polipo-master/server.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/server.c	Tue Apr 28 18:25:38 2015
@@ -1207,7 +1207,7 @@
                request->time0.tv_sec != null_time.tv_sec)
                 rtt = timeval_minus_usec(&request->time1, &request->time0);
             if(size >= 8192 && d > 50000)
-                rate = ((double)size / (double)d) * 1000000.0 + 0.5;
+                rate = (int)( ((double)size / (double)d) * 1000000.0 + 0.5 );
         }
         request->time0 = null_time;
         request->time1 = null_time;
diff -Nur ./polipo-master/mingw.c ./polipo-1.1.2/mingw.c
--- ./polipo-master/mingw.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/mingw.c	Tue Apr 28 18:25:38 2015
@@ -186,8 +186,8 @@
 
     if(tv) {
         GetSystemTimeAsFileTime(&ft);
-        li.LowPart  = ft.dwLowDateTime;
-        li.HighPart = ft.dwHighDateTime;
+        li.u.LowPart  = ft.dwLowDateTime;
+        li.u.HighPart = ft.dwHighDateTime;
         t  = li.QuadPart;       /* In 100-nanosecond intervals */
         t -= EPOCHFILETIME;     /* Offset to the Epoch time */
         t /= 10;                /* In microseconds */
diff -Nur ./polipo-master/diskcache.c ./polipo-1.1.2/diskcache.c
--- ./polipo-master/diskcache.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/diskcache.c	Tue Apr 28 18:37:23 2015
@@ -2433,8 +2433,15 @@
     long left = 0, total = 0;
 
     if(diskCacheRoot == NULL || 
-       diskCacheRoot->length <= 0 || diskCacheRoot->string[0] != '/')
-        return;
+       diskCacheRoot->length <= 0 || 
+#ifdef WIN32
+       !(isalpha(diskCacheRoot->string[0]) && (diskCacheRoot->string[1] == ':') &&
+         ((diskCacheRoot->string[2] == '/') || (diskCacheRoot->string[2] == '\\')))
+#else
+       diskCacheRoot->string[0] != '/'
+#endif
+      )
+       return;
 
     fts_argv[0] = diskCacheRoot->string;
     fts_argv[1] = NULL;
diff -Nur ./polipo-master/io.c ./polipo-1.1.2/io.c
--- ./polipo-master/io.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/io.c	Tue Apr 28 18:25:38 2015
@@ -37,6 +37,12 @@
 void
 preinitIo()
 {
+#ifdef HAVE_WINSOCK
+    WSADATA wsaData;
+    WORD wVersionRequested = MAKEWORD(2, 2);
+	int err;
+#endif
+
 #ifdef HAVE_IPV6_PREFER_TEMPADDR
     CONFIG_VARIABLE_SETTABLE(useTemporarySourceAddress, CONFIG_TRISTATE,
                              configIntSetter,
@@ -48,9 +54,7 @@
 
 #ifdef HAVE_WINSOCK
     /* Load the winsock dll */
-    WSADATA wsaData;
-    WORD wVersionRequested = MAKEWORD(2, 2);
-    int err = WSAStartup( wVersionRequested, &wsaData );
+    err = WSAStartup( wVersionRequested, &wsaData );
     if (err != 0) {
         do_log_error(L_ERROR, err, "Couldn't load winsock dll");
         exit(-1);
diff -Nur ./polipo-master/socks.c ./polipo-1.1.2/socks.c
--- ./polipo-master/socks.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/socks.c	Tue Apr 28 18:25:38 2015
@@ -83,6 +83,8 @@
 void
 preinitSocks()
 {
+	int rc;
+
     AtomPtr socksAuthCredentials = internAtom("");
 
     aSocks4a = internAtom("socks4a");
@@ -103,7 +105,7 @@
 
 
     // infer username and password from credentials
-    int rc = atomSplit(socksAuthCredentials, ':', &socksUserName, &socksPassWord);
+    rc = atomSplit(socksAuthCredentials, ':', &socksUserName, &socksPassWord);
     if (rc < 0) {
       do_log(L_ERROR, "Error splitting credentials");
       exit(1);
@@ -349,7 +351,9 @@
                   FdEventHandlerPtr event,
                   StreamRequestPtr srequest)
 {
-    SocksRequestPtr request = srequest->data;
+    int (*readHandler)(int, FdEventHandlerPtr, StreamRequestPtr) = NULL;
+
+    SocksRequestPtr request = srequest->data;
 
     if(status < 0)
         goto error;
@@ -362,7 +366,6 @@
         return 0;
     }
 
-    int (*readHandler)(int, FdEventHandlerPtr, StreamRequestPtr) = NULL;
     if (socksProxyType == aSocks4a){
       readHandler = socksReadHandler;
     } else if (socksPassWord == NULL) {
diff -Nur ./polipo-master/fts_compat.c ./polipo-1.1.2/fts_compat.c
--- ./polipo-master/fts_compat.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/fts_compat.c	Tue Apr 28 18:37:23 2015
@@ -37,6 +37,9 @@
 #include <string.h>
 
 #include "fts_compat.h"
+#ifdef _MSC_VER
+#include "mingw.h"
+#endif
 
 static char *
 getcwd_a()
diff -Nur ./polipo-master/log.c ./polipo-1.1.2/log.c
--- ./polipo-master/log.c	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/log.c	Tue Apr 28 18:37:23 2015
@@ -98,7 +98,13 @@
         return NULL;
     }
 
-    setvbuf(f, NULL, _IOLBF, 0);
+    setvbuf(f, NULL, _IOLBF,
+#ifdef _MSC_VER
+    2048
+#else
+    0
+#endif
+    );
     return f;
 }
 
diff -Nur ./polipo-master/md5.h ./polipo-1.1.2/md5.h
--- ./polipo-master/md5.h	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/md5.h	Tue Apr 28 18:37:23 2015
@@ -35,7 +35,12 @@
 #ifdef HAS_STDINT_H
 #include <stdint.h>
 #elif defined(HAS_INTTYPES_H)
-#include <inttypes.h>
+#ifdef _MSC_VER
+  #include "inttypes.h"
+#else
+  #include <inttypes.h>
+#endif
+
 #endif
 
 /* typedef a 32-bit type */
diff -Nur ./polipo-master/polipo.h ./polipo-1.1.2/polipo.h
--- ./polipo-master/polipo.h	Fri Nov 21 09:15:36 2014
+++ ./polipo-1.1.2/polipo.h	Tue Apr 28 18:37:23 2015
@@ -59,6 +59,7 @@
 #include <sys/ioctl.h>
 #include <signal.h>
 #endif
+#include <ctype.h>
 
 #ifdef __MINGW32__
 #define MINGW
@@ -195,6 +196,10 @@
 #ifndef MINGW
 #define HAVE_MKGMTIME
 #endif
+#endif
+
+#ifdef _MSC_VER
+#define F_OK 00
 #endif
 
 #ifdef HAVE_READV_WRITEV

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y