Re: I port polipo to VS2008 under Win32

honglei junan <[email protected]>
Newsgroups gmane.comp.web.polipo.user
Message-ID <[email protected]>
now i change ms_port into 10 patches ,all in one file. I just use the
command:
   git format-patch master --stdout >../ms_port.patch
should i part to 10 different patch files? i don't know how to do it.
as i beginner for using git,i still not quit familiar with it.

>
> Perhaps you could also implement change_to_dir() for Windows in
> fts_compat?
>

 i implement a change_to_dir() for Windows ,but now only work for VC,i will
do it later to make it work for MINGW.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

_______________________________________________
Polipo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/polipo-users
ms_port.patch (application/octet-stream, 31.4 KB)
From 7753dfa5249824013cb26bcbd87d691287bfed2f Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 20:49:02 +0800
Subject: [PATCH 01/10] renaming of mingw* to win32*

---
 io.c    |    4 ++--
 mingw.c |   32 ++++++++++++++++----------------
 mingw.h |   56 ++++++++++++++++++++++++++++----------------------------
 3 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/io.c b/io.c
index 95de1a5..957c6b9 100644
--- a/io.c
+++ b/io.c
@@ -799,8 +799,8 @@ create_listener(char *address, int port,
 int
 setNonblocking(int fd, int nonblocking)
 {
-#ifdef MINGW
-    return mingw_setnonblocking(fd, nonblocking);
+#ifdef WIN32 /*MINGW*/
+    return win32_setnonblocking(fd, nonblocking);
 #else
     int rc;
     rc = fcntl(fd, F_GETFL, 0);
diff --git a/mingw.c b/mingw.c
index a33d2cc..5b8f08c 100644
--- a/mingw.c
+++ b/mingw.c
@@ -23,7 +23,7 @@ THE SOFTWARE.
 
 #include "polipo.h"
 
-#ifndef MINGW
+#ifndef WIN32 /*MINGW*/
 
 static int dummy ATTRIBUTE((unused));
 
@@ -53,7 +53,7 @@ static int dummy ATTRIBUTE((unused));
  * (with trivial modifications) from the OpenBSD project.
  */
 int
-mingw_inet_aton(const char *cp, struct in_addr *addr)
+win32_inet_aton(const char *cp, struct in_addr *addr)
 {
     register unsigned int val;
     register int base, n;
@@ -148,14 +148,14 @@ mingw_inet_aton(const char *cp, struct in_addr *addr)
 }
 
 unsigned int
-mingw_sleep(unsigned int seconds)
+win32_sleep(unsigned int seconds)
 {
     Sleep(seconds * 1000);
     return 0;
 }
 
 int
-mingw_gettimeofday(struct timeval *tv, char *tz)
+win32_gettimeofday(struct timeval *tv, char *tz)
 {
     const long long EPOCHFILETIME = (116444736000000000LL);
     FILETIME        ft;
@@ -183,7 +183,7 @@ mingw_gettimeofday(struct timeval *tv, char *tz)
     return 0;
 }
 
-int mingw_poll(struct pollfd *fds, unsigned int nfds, int timo)
+int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
 {
     struct timeval timeout, *toptr;
     fd_set ifds, ofds, efds, *ip, *op;
@@ -248,7 +248,7 @@ int mingw_poll(struct pollfd *fds, unsigned int nfds, int timo)
     return rc;
 }
 
-int mingw_close_socket(SOCKET fd) {
+int win32_close_socket(SOCKET fd) {
     int rc;
 
     rc = closesocket(fd);
@@ -268,7 +268,7 @@ set_errno(int winsock_err)
     }
 }
 
-int mingw_write_socket(SOCKET fd, void *buf, int n)
+int win32_write_socket(SOCKET fd, void *buf, int n)
 {
     int rc = send(fd, buf, n, 0);
     if(rc == SOCKET_ERROR) {
@@ -277,7 +277,7 @@ int mingw_write_socket(SOCKET fd, void *buf, int n)
     return rc;
 }
 
-int mingw_read_socket(SOCKET fd, void *buf, int n)
+int win32_read_socket(SOCKET fd, void *buf, int n)
 {
     int rc = recv(fd, buf, n, 0);
     if(rc == SOCKET_ERROR) {
@@ -294,7 +294,7 @@ int mingw_read_socket(SOCKET fd, void *buf, int n)
  * is successful, other -1.
  */
 int
-mingw_setnonblocking(SOCKET fd, int nonblocking)
+win32_setnonblocking(SOCKET fd, int nonblocking)
 {
     int rc;
 
@@ -312,7 +312,7 @@ mingw_setnonblocking(SOCKET fd, int nonblocking)
  * even if we are using winsock.
  */
 SOCKET
-mingw_socket(int domain, int type, int protocol)
+win32_socket(int domain, int type, int protocol)
 {
     SOCKET fd = socket(domain, type, protocol);
     if(fd == INVALID_SOCKET) {
@@ -342,7 +342,7 @@ set_connect_errno(int winsock_err)
  * even if we are using winsock.
  */
 int
-mingw_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len)
+win32_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len)
 {
     int rc = connect(fd, addr, addr_len);
     assert(rc == 0 || rc == SOCKET_ERROR);
@@ -358,7 +358,7 @@ mingw_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len)
  * even if we are using winsock.
  */
 SOCKET
-mingw_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len)
+win32_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len)
 {
     SOCKET newfd = accept(fd, addr, addr_len);
     if(newfd == INVALID_SOCKET) {
@@ -374,7 +374,7 @@ mingw_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len)
  * even if we are using winsock.
  */
 int
-mingw_shutdown(SOCKET fd, int mode)
+win32_shutdown(SOCKET fd, int mode)
 {
     int rc = shutdown(fd, mode);
     assert(rc == 0 || rc == SOCKET_ERROR);
@@ -390,7 +390,7 @@ mingw_shutdown(SOCKET fd, int mode)
  * even if we are using winsock.
  */
 int
-mingw_getpeername(SOCKET fd, struct sockaddr *name, socklen_t *namelen)
+win32_getpeername(SOCKET fd, struct sockaddr *name, socklen_t *namelen)
 {
     int rc = getpeername(fd, name, namelen);
     assert(rc == 0 || rc == SOCKET_ERROR);
@@ -403,7 +403,7 @@ mingw_getpeername(SOCKET fd, struct sockaddr *name, socklen_t *namelen)
 /* Stat doesn't work on directories if the name ends in a slash. */
 
 int
-mingw_stat(const char *filename, struct stat *ss)
+win32_stat(const char *filename, struct stat *ss)
 {
     int len, rc, saved_errno;
     char *noslash;
@@ -425,7 +425,7 @@ mingw_stat(const char *filename, struct stat *ss)
     errno = saved_errno;
     return rc;
 }
-#endif /* #ifdef MINGW */
+#endif /* #ifdef WIN32 MINGW */
 
 #ifndef HAVE_READV_WRITEV
 
diff --git a/mingw.h b/mingw.h
index baca6fb..4b2ec77 100644
--- a/mingw.h
+++ b/mingw.h
@@ -32,7 +32,7 @@ THE SOFTWARE.
  * symbol. For Unix or Unix-like systems, leave it undefined.
  */
 
-#ifdef MINGW
+#ifdef WIN32 /*MINGW*/
 
 /* Unfortunately, there's no hiding it. */
 #define HAVE_WINSOCK 1
@@ -74,7 +74,7 @@ struct pollfd {
     short events;     /* requested events */
     short revents;    /* returned events */
 };
-#define poll(x, y, z)        mingw_poll(x, y, z)
+#define poll(x, y, z)        win32_poll(x, y, z)
 
 /* These wrappers do nothing special except set the global errno variable if
  * an error occurs (winsock doesn't do this by default). They set errno
@@ -82,17 +82,17 @@ struct pollfd {
  * outside of this file "shouldn't" have to worry about winsock specific error
  * handling.
  */
-#define socket(x, y, z)      mingw_socket(x, y, z)
-#define connect(x, y, z)     mingw_connect(x, y, z)
-#define accept(x, y, z)      mingw_accept(x, y, z)
-#define shutdown(x, y)       mingw_shutdown(x, y)
-#define getpeername(x, y, z) mingw_getpeername(x, y, z)
+#define socket(x, y, z)      win32_socket(x, y, z)
+#define connect(x, y, z)     win32_connect(x, y, z)
+#define accept(x, y, z)      win32_accept(x, y, z)
+#define shutdown(x, y)       win32_shutdown(x, y)
+#define getpeername(x, y, z) win32_getpeername(x, y, z)
 
 /* Wrapper macros to call misc. functions mingw is missing */
-#define sleep(x)             mingw_sleep(x)
-#define inet_aton(x, y)      mingw_inet_aton(x, y)
-#define gettimeofday(x, y)   mingw_gettimeofday(x, y)
-#define stat(x, y)           mingw_stat(x, y)
+#define sleep(x)             win32_sleep(x)
+#define inet_aton(x, y)      win32_inet_aton(x, y)
+#define gettimeofday(x, y)   win32_gettimeofday(x, y)
+#define stat(x, y)           win32_stat(x, y)
 
 #define mkdir(x, y) mkdir(x)
 
@@ -100,27 +100,27 @@ struct pollfd {
 typedef int socklen_t;
 
 /* Function prototypes for functions in mingw.c */
-unsigned int mingw_sleep(unsigned int);
-int     mingw_inet_aton(const char *, struct in_addr *);
-int     mingw_gettimeofday(struct timeval *, char *);
-int     mingw_poll(struct pollfd *, unsigned int, int);
-SOCKET  mingw_socket(int, int, int);
-int     mingw_connect(SOCKET, struct sockaddr*, socklen_t);
-SOCKET  mingw_accept(SOCKET, struct sockaddr*, socklen_t *);
-int     mingw_shutdown(SOCKET, int);
-int     mingw_getpeername(SOCKET, struct sockaddr*, socklen_t *);
+unsigned int win32_sleep(unsigned int);
+int     win32_inet_aton(const char *, struct in_addr *);
+int     win32_gettimeofday(struct timeval *, char *);
+int     win32_poll(struct pollfd *, unsigned int, int);
+SOCKET  win32_socket(int, int, int);
+int     win32_connect(SOCKET, struct sockaddr*, socklen_t);
+SOCKET  win32_accept(SOCKET, struct sockaddr*, socklen_t *);
+int     win32_shutdown(SOCKET, int);
+int     win32_getpeername(SOCKET, struct sockaddr*, socklen_t *);
 
 /* Three socket specific macros */
-#define READ(x, y, z)  mingw_read_socket(x, y, z)
-#define WRITE(x, y, z) mingw_write_socket(x, y, z)
-#define CLOSE(x)       mingw_close_socket(x)
+#define READ(x, y, z)  win32_read_socket(x, y, z)
+#define WRITE(x, y, z) win32_write_socket(x, y, z)
+#define CLOSE(x)       win32_close_socket(x)
 
-int mingw_read_socket(SOCKET, void *, int);
-int mingw_write_socket(SOCKET, void *, int);
-int mingw_close_socket(SOCKET);
+int win32_read_socket(SOCKET, void *, int);
+int win32_write_socket(SOCKET, void *, int);
+int win32_close_socket(SOCKET);
 
-int mingw_setnonblocking(SOCKET, int);
-int mingw_stat(const char*, struct stat*);
+int win32_setnonblocking(SOCKET, int);
+int win32_stat(const char*, struct stat*);
 #endif
 
 #ifndef HAVE_READV_WRITEV
-- 
1.6.5.1.msysgit.1


From 9a404ba9e3f7e51668af8c769175d8c70f38ff1f Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 20:53:37 +0800
Subject: [PATCH 02/10] move the same va_copy in log.c/util.c to polipo.h

---
 log.c    |    4 ----
 polipo.h |    8 ++++++++
 util.c   |    6 ++++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/log.c b/log.c
index ec5c545..31aa15e 100644
--- a/log.c
+++ b/log.c
@@ -304,10 +304,6 @@ maybeFlushSyslog(int type)
     }
 }
 
-#ifndef va_copy
-#define va_copy(a, b) do { a = b; } while(0)
-#endif
-
 static void
 accumulateSyslogV(int type, const char *f, va_list args)
 {
diff --git a/polipo.h b/polipo.h
index b0481b8..c7c8916 100644
--- a/polipo.h
+++ b/polipo.h
@@ -58,6 +58,14 @@ THE SOFTWARE.
 #include <signal.h>
 #endif
 
+#if defined(va_copy)
+#elif defined(__va_copy)
+#  define va_copy(dst, src) __va_copy((dst), (src))
+#else
+/* #  define va_copy(dst, src) (memcpy(&(dst), &(src), sizeof (va_list))) */
+#  define va_copy(dst, src) do{((dst) = (src)) ;} while(0) 
+#endif
+
 #ifndef MAP_ANONYMOUS
 #define MAP_ANONYMOUS MAP_ANON
 #endif
diff --git a/util.c b/util.c
index e6494ed..a3617cc 100644
--- a/util.c
+++ b/util.c
@@ -311,11 +311,13 @@ vsprintf_a(const char *f, va_list args)
 
 #else
 
-/* This is not going to work if va_list is interesting.  But then, if you
+/*** This is not going to work if va_list is interesting.  But then, if you
    have a non-trivial implementation of va_list, you should have va_copy. */
+/*
 #ifndef va_copy
 #define va_copy(a, b) do { a = b; } while(0)
-#endif
+#endif 
+*/
 
 char*
 vsprintf_a(const char *f, va_list args)
-- 
1.6.5.1.msysgit.1


From 8277dd1b83652c422892122065da3d70186877df Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 20:58:30 +0800
Subject: [PATCH 03/10] change MINGW to WIN32

---
 chunk.c      |    2 +-
 fts_compat.c |    2 +-
 polipo.h     |    4 ++--
 util.c       |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/chunk.c b/chunk.c
index f7bb6d2..0a7ed16 100644
--- a/chunk.c
+++ b/chunk.c
@@ -184,7 +184,7 @@ totalChunkArenaSize()
 }
 #else
 
-#ifdef MINGW
+#ifdef WIN32 /*MINGW*/
 #define MAP_FAILED NULL
 #define getpagesize() (64 * 1024)
 static void *
diff --git a/fts_compat.c b/fts_compat.c
index 7451e81..c42c3eb 100644
--- a/fts_compat.c
+++ b/fts_compat.c
@@ -127,7 +127,7 @@ dirfd(DIR *dir)
 /*
  * Make the directory identified by the argument the current directory.
  */
-#ifdef MINGW
+#ifdef WIN32 /*MINGW*/
 int
 change_to_dir(DIR *dir)
 {
diff --git a/polipo.h b/polipo.h
index c7c8916..44d3aed 100644
--- a/polipo.h
+++ b/polipo.h
@@ -43,7 +43,7 @@ THE SOFTWARE.
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <dirent.h>
-#ifndef MINGW
+#ifndef WIN32 /*MINGW*/
 #include <sys/mman.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -173,7 +173,7 @@ THE SOFTWARE.
 #define UNALIGNED_ACCESS
 #endif
 
-#ifndef MINGW
+#ifndef WIN32 /*MINGW*/
 #define HAVE_FORK
 #ifndef NO_SYSLOG
 #define HAVE_SYSLOG
diff --git a/util.c b/util.c
index a3617cc..008c6e6 100644
--- a/util.c
+++ b/util.c
@@ -428,7 +428,7 @@ pstrerror(int e)
     default: s = NULL; break;
     }
     if(!s) s = strerror(e);
-#ifdef MINGW
+#ifdef WIN32 /*MINGW*/
     if(!s) {
         if(e >= WSABASEERR && e <= WSABASEERR + 2000) {
             /* This should be okay, as long as the caller discards the
-- 
1.6.5.1.msysgit.1


From a60a542a91122e743ba4733e55ff1aa7db85e41b Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 21:02:23 +0800
Subject: [PATCH 04/10] add direct.h/c

---
 dirent.c |  218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 dirent.h |   23 +++++++
 2 files changed, 241 insertions(+), 0 deletions(-)
 create mode 100644 dirent.c
 create mode 100644 dirent.h

diff --git a/dirent.c b/dirent.c
new file mode 100644
index 0000000..48d5ded
--- /dev/null
+++ b/dirent.c
@@ -0,0 +1,218 @@
+/** dirent.c: emulates POSIX directory readin functions: opendir(), readdir(),
+ *           etc. under Win32   
+ */
+
+#include <windows.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <malloc.h>
+#include "dirent.h"
+
+
+
+/*--------------------------------------------------------------------------
+ Name         countslashes
+
+ Description  
+--------------------------------------------------------------------------*/
+
+static int countslashes(const char *dirname)
+{
+  const char *p;
+  int n;
+
+  n = 0;
+  p = dirname;
+
+  while (*p)
+    if (*p++ == '\\')
+      ++n;
+
+  return n;
+}
+
+/*--------------------------------------------------------------------------
+* Name         opendir
+*
+* Description  
+--------------------------------------------------------------------------*/
+DIR * opendir ( const char * dirname )
+{
+  DIR * dir;
+  int   nameLen;
+  struct stat st;
+  unsigned char flagNetPath;
+  unsigned char flagRootOnly;
+
+  if (dirname == NULL || *dirname == 0)
+  {
+    errno = EINVAL;
+    return NULL;
+  }
+
+  nameLen = strlen( dirname );
+  flagNetPath = 0;
+  if (dirname[0] == '\\' && dirname[1] == '\\')
+    flagNetPath = 1;
+  /* we have to check for root-dir-only case */
+  flagRootOnly = 0;
+  if (flagNetPath)
+  {
+    if (countslashes(&dirname[2]) == 2)  /* only the separation for server_name and the root*/
+      flagRootOnly = 1;
+  }
+
+  if ((dirname[nameLen-1] == '/' || dirname[nameLen-1] == '\\') &&
+      (nameLen != 3 || dirname[1] != ':') && nameLen != 1 && !flagRootOnly)
+  {
+    char * t = alloca( nameLen );
+    memcpy( t, dirname, nameLen );
+    t[nameLen-1] = 0;
+    dirname = t;
+    --nameLen;
+  }
+
+  if (stat( dirname, &st ))
+    return NULL;
+
+  if ((st.st_mode & S_IFDIR) == 0)
+  {
+    /* this is not a DIR */
+    errno = ENOTDIR;
+    return NULL;
+  }
+
+  if ((dir = malloc( sizeof( DIR ) + nameLen + 2 )) == NULL)
+  {
+    errno = ENOMEM;
+    return NULL;
+  }
+
+  dir->hFind = INVALID_HANDLE_VALUE;
+
+  memcpy( dir->szDirName, dirname, nameLen );
+  if (nameLen && dirname[nameLen-1] != ':' && dirname[nameLen-1] != '\\' &&
+      dirname[nameLen-1] != '/')
+  {
+    dir->szDirName[nameLen++] = '\\';
+  }
+  dir->szDirName[nameLen] = '*';
+  dir->szDirName[nameLen+1] = 0;
+
+  return dir;
+};
+
+
+/* Use the new safe string functions introduced in Visual Studio 2005 */
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
+#else
+# define STRNCPY(dest,src,size) strncpy((dest),(src),(size))
+#endif
+
+/*--------------------------------------------------------------------------
+ * Name         readdir
+ *
+ * Description  
+--------------------------------------------------------------------------*/
+struct dirent * readdir ( DIR * dir )
+{
+  static WIN32_FIND_DATA fData;
+
+  if (dir == NULL)
+  {
+    errno = EBADF;
+    return NULL;
+  }
+
+  do
+  {
+    int ok = 1;
+
+    if (dir->hFind == INVALID_HANDLE_VALUE)
+    {
+      dir->hFind = FindFirstFile( dir->szDirName, &fData );
+      if (dir->hFind == INVALID_HANDLE_VALUE)
+        ok = 0;
+    }
+    else
+    if (!FindNextFile( dir->hFind, &fData ))
+      ok = 0;
+
+    if (!ok)
+    {
+      switch (GetLastError())
+      {
+        case ERROR_NO_MORE_FILES:
+        case ERROR_FILE_NOT_FOUND:
+        case ERROR_PATH_NOT_FOUND:
+          errno = ENOENT;
+          break;
+
+        case ERROR_NOT_ENOUGH_MEMORY:
+          errno = ENOMEM;
+          break;
+
+        default:
+          errno = EINVAL;
+          break;
+      }
+      return NULL;
+    }
+  }
+  while (fData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN);
+
+  return (struct dirent *)&fData.cFileName;
+};
+
+/*--------------------------------------------------------------------------
+ * Name         closedir
+--------------------------------------------------------------------------*/
+int closedir ( DIR * dir )
+{
+  if (dir == NULL)
+  {
+    errno = EBADF;
+    return -1;
+  }
+  if (dir->hFind != INVALID_HANDLE_VALUE)
+    FindClose( dir->hFind );
+  free( dir );
+  return 0;
+};
+
+/*--------------------------------------------------------------------------
+ Name         rewinddir
+ Description  
+--------------------------------------------------------------------------*/
+void rewinddir ( DIR * dir )
+{
+  if (dir)
+  {
+    if (dir->hFind != INVALID_HANDLE_VALUE)
+      FindClose( dir->hFind );
+    dir->hFind = INVALID_HANDLE_VALUE;
+  }
+};
+
+/*
+int main ( int argc, char ** argv )
+{
+  DIR * dir;
+  struct dirent * de;
+  char * arg;
+
+  arg = argc > 1 ? argv[1] : ".";
+
+  if (dir = opendir( arg ))
+  {
+    while (de = readdir( dir ))
+    {
+      puts( de->d_name );
+    }
+    closedir( dir );
+  }
+  return 0;
+};
+*/
diff --git a/dirent.h b/dirent.h
new file mode 100644
index 0000000..6e4a829
--- /dev/null
+++ b/dirent.h
@@ -0,0 +1,23 @@
+
+#ifndef DIRENT_H
+#define DIRENT_H
+
+#include <stdio.h>
+
+struct dirent
+{
+	char d_name[FILENAME_MAX+1]; /* File name. */
+};
+struct DIR
+{
+  HANDLE hFind; /* File search handle */
+  char   szDirName[MAX_PATH + 3]; /* search pattern (3 = pattern + "\\*\0") */
+};
+typedef struct DIR DIR;
+
+DIR * opendir ( const char * dirname );
+struct dirent * readdir ( DIR * dir );
+int closedir ( DIR * dir );
+void rewinddir ( DIR * dir );
+
+#endif /* DIRENT_H */
-- 
1.6.5.1.msysgit.1


From 0c244e8f041448f334639a7c276fb431fa7b4504 Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 21:04:34 +0800
Subject: [PATCH 05/10] add mktime_gmt for VC

---
 util.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/util.c b/util.c
index 008c6e6..464d6e5 100644
--- a/util.c
+++ b/util.c
@@ -487,6 +487,23 @@ mktime_gmt(struct tm *tm)
     tzset();
     return t;
 }
+#elif defined(_MSC_VER)
+ time_t
+mktime_gmt(struct tm *tm)
+{
+	time_t t;
+	static int bias = -1;
+	if(bias == -1)
+	{
+		time_t   curr   =   time(NULL);   
+		struct   tm   *  p   = gmtime(&curr);   
+		time_t   gmtcurr     =   mktime(p);  
+		bias = curr-gmtcurr ; 
+	}
+	t = mktime(tm)+bias;
+	/* printf("mktime_gmt2: %d\n", t ); */
+    return t;
+}
 #else
 time_t
 mktime_gmt(struct tm *tm)
-- 
1.6.5.1.msysgit.1


From 0f7a80ab9eae625bbe3a1d5413899db9021e8e8d Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 21:05:32 +0800
Subject: [PATCH 06/10] add HAVE_FORK for func interestingSignals

---
 event.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/event.h b/event.h
index 05575d6..c94aa3c 100644
--- a/event.h
+++ b/event.h
@@ -52,7 +52,9 @@ typedef struct _Condition {
 
 void initEvents(void);
 void uninitEvents(void);
+#ifdef HAVE_FORK
 void interestingSignals(sigset_t *ss);
+#endif
 
 TimeEventHandlerPtr scheduleTimeEvent(int seconds,
                                       int (*handler)(TimeEventHandlerPtr),
-- 
1.6.5.1.msysgit.1


From a9cc8392aa6b94d7a6d7a9cd655e86c176d63bda Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 21:09:11 +0800
Subject: [PATCH 07/10] add _MSC_VER to compiled under VC

---
 fts_compat.c |   11 +++++++++--
 fts_compat.h |    5 +++++
 local.h      |    3 +++
 polipo.h     |   17 +++++++++++++++--
 4 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/fts_compat.c b/fts_compat.c
index c42c3eb..1c68a48 100644
--- a/fts_compat.c
+++ b/fts_compat.c
@@ -25,9 +25,16 @@ THE SOFTWARE.
 
 #include <stdlib.h>
 #include <errno.h>
-#include <unistd.h>
+#ifdef _MSC_VER
+ #include "polipo.h"
+ #include <direct.h>
+#else
+ #include <unistd.h>
+ #include <dirent.h>
+#endif
+
 #include <sys/types.h>
-#include <dirent.h>
+
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/fts_compat.h b/fts_compat.h
index c23d405..6babece 100644
--- a/fts_compat.h
+++ b/fts_compat.h
@@ -50,6 +50,11 @@ struct _FTSENT {
 
 typedef struct _FTSENT FTSENT;
 
+#ifdef _MSC_VER
+#include "dirent.h"
+#else
+#include <dirent.h>
+#endif
 struct _FTS {
     int depth;
     DIR *dir[FTS_MAX_DEPTH];
diff --git a/local.h b/local.h
index 24dde5a..b626606 100644
--- a/local.h
+++ b/local.h
@@ -20,6 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
 
+#ifdef _MSC_VER
+  typedef int pid_t;
+#endif
 typedef struct _SpecialRequest {
     ObjectPtr object;
     int fd;
diff --git a/polipo.h b/polipo.h
index 44d3aed..6ea9d95 100644
--- a/polipo.h
+++ b/polipo.h
@@ -24,7 +24,9 @@ THE SOFTWARE.
 #define _GNU_SOURCE
 #endif
 
+#ifndef WIN32
 #include <sys/param.h>
+#endif
 
 #ifdef __MINGW32_VERSION
 #define MINGW
@@ -37,12 +39,14 @@ THE SOFTWARE.
 #include <errno.h>
 #include <string.h>
 #include <assert.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
-#include <sys/time.h>
 #include <sys/stat.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#include <sys/time.h>
 #include <dirent.h>
+#endif
 #ifndef WIN32 /*MINGW*/
 #include <sys/mman.h>
 #include <sys/socket.h>
@@ -189,6 +193,15 @@ THE SOFTWARE.
 #endif
 #endif
 
+#ifdef _MSC_VER
+
+#define F_OK 00
+#define snprintf _snprintf
+#define S_ISDIR(x) (S_IFDIR&(x))
+#define S_ISREG(x) (S_IFREG&(x))
+
+#endif
+
 #ifdef HAVE_READV_WRITEV
 #define WRITEV(x, y, z) writev(x, y, z)
 #define READV(x, y, z)  readv(x, y, z)
-- 
1.6.5.1.msysgit.1


From 94d9a060396f57cab6f554090d86d8029245cedb Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 21:10:28 +0800
Subject: [PATCH 08/10] add Func change_to_dir for win32

---
 fts_compat.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fts_compat.c b/fts_compat.c
index 1c68a48..a15c1cf 100644
--- a/fts_compat.c
+++ b/fts_compat.c
@@ -138,8 +138,13 @@ dirfd(DIR *dir)
 int
 change_to_dir(DIR *dir)
 {
-    errno = ENOSYS;
-    return -1;
+	char c;
+	if(!dir)
+	{ 
+		errno = EINVAL;
+		return -1;
+	}
+	return _chdir((dir->szDirName) );
 }
 #else
 int
-- 
1.6.5.1.msysgit.1


From e31394c35e3f6243f8aa9825ca095fdcf64bb4f6 Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 21:12:03 +0800
Subject: [PATCH 09/10] change fts_compat.h istat to stat for compile under VC

---
 fts_compat.c |   13 ++++++++-----
 fts_compat.h |    2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/fts_compat.c b/fts_compat.c
index a15c1cf..5d3b3c5 100644
--- a/fts_compat.c
+++ b/fts_compat.c
@@ -25,6 +25,7 @@ THE SOFTWARE.
 
 #include <stdlib.h>
 #include <errno.h>
+
 #ifdef _MSC_VER
  #include "polipo.h"
  #include <direct.h>
@@ -39,6 +40,8 @@ THE SOFTWARE.
 #include <errno.h>
 #include <string.h>
 
+
+
 #include "fts_compat.h"
 
 static char *
@@ -293,13 +296,13 @@ fts_read(FTS *fts)
     name = dirent->d_name;
 
  again2:
-    rc = stat(name, &fts->stat);
+    rc = stat(name, &fts->istat);
     if(rc < 0) {
         fts->ftsent.fts_info = FTS_NS;
         goto error2;
     }
 
-    if(S_ISDIR(fts->stat.st_mode)) {
+    if(S_ISDIR(fts->istat.st_mode)) {
         char *newcwd;
         DIR *dir;
 
@@ -330,11 +333,11 @@ fts_read(FTS *fts)
         fts->depth++;
         fts->dir[fts->depth] = dir;
         goto done;
-    } else if(S_ISREG(fts->stat.st_mode)) {
+    } else if(S_ISREG(fts->istat.st_mode)) {
         fts->ftsent.fts_info = FTS_F;
         goto done;
 #ifdef S_ISLNK
-    } else if(S_ISLNK(fts->stat.st_mode)) {
+    } else if(S_ISLNK(fts->istat.st_mode)) {
         int rc;
         rc = readlink(name, buf, 1024);
         if(rc < 0)
@@ -362,7 +365,7 @@ fts_read(FTS *fts)
     fts->ftsent.fts_path = mkfilename(fts->cwd, name);
     if(fts->ftsent.fts_path == NULL) goto error;
     fts->ftsent.fts_accpath = name;
-    fts->ftsent.fts_statp = &fts->stat;
+    fts->ftsent.fts_statp = &fts->istat;
     return &fts->ftsent;
 
  error:
diff --git a/fts_compat.h b/fts_compat.h
index 6babece..e20c962 100644
--- a/fts_compat.h
+++ b/fts_compat.h
@@ -60,7 +60,7 @@ struct _FTS {
     DIR *dir[FTS_MAX_DEPTH];
     char *cwd0, *cwd;
     struct _FTSENT ftsent;
-    struct stat stat;
+	struct stat istat;  
     char *dname;
 };
 
-- 
1.6.5.1.msysgit.1


From de9737281f143ee37583f937cd3b479ad25dcb95 Mon Sep 17 00:00:00 2001
From: unknown <CN@.(none)>
Date: Tue, 26 Jan 2010 21:29:01 +0800
Subject: [PATCH 10/10] add VC2008 project file

---
 polipo.vcproj |  391 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 391 insertions(+), 0 deletions(-)
 create mode 100644 polipo.vcproj

diff --git a/polipo.vcproj b/polipo.vcproj
new file mode 100644
index 0000000..5145ca1
--- /dev/null
+++ b/polipo.vcproj
@@ -0,0 +1,391 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="polipo"
+	ProjectGUID="{B4E72DB8-4BA8-44D9-83F4-84162140CC91}"
+	RootNamespace="polipo"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="ws2_32.lib Iphlpapi.lib"
+				GenerateDebugInformation="true"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="WIN32;HAS_INTTYPES_H"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="ws2_32.lib Iphlpapi.lib"
+				GenerateDebugInformation="true"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Ô´Îļþ"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\atom.c"
+				>
+			</File>
+			<File
+				RelativePath=".\auth.c"
+				>
+			</File>
+			<File
+				RelativePath=".\chunk.c"
+				>
+			</File>
+			<File
+				RelativePath=".\client.c"
+				>
+			</File>
+			<File
+				RelativePath=".\config.c"
+				>
+			</File>
+			<File
+				RelativePath=".\diskcache.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dns.c"
+				>
+			</File>
+			<File
+				RelativePath=".\event.c"
+				>
+			</File>
+			<File
+				RelativePath=".\forbidden.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fts_compat.c"
+				>
+			</File>
+			<File
+				RelativePath=".\http.c"
+				>
+			</File>
+			<File
+				RelativePath=".\http_parse.c"
+				>
+			</File>
+			<File
+				RelativePath=".\io.c"
+				>
+			</File>
+			<File
+				RelativePath=".\local.c"
+				>
+			</File>
+			<File
+				RelativePath=".\log.c"
+				>
+			</File>
+			<File
+				RelativePath=".\main.c"
+				>
+			</File>
+			<File
+				RelativePath=".\md5import.c"
+				>
+			</File>
+			<File
+				RelativePath=".\mingw.c"
+				>
+			</File>
+			<File
+				RelativePath=".\object.c"
+				>
+			</File>
+			<File
+				RelativePath=".\parse_time.c"
+				>
+			</File>
+			<File
+				RelativePath=".\server.c"
+				>
+			</File>
+			<File
+				RelativePath=".\socks.c"
+				>
+			</File>
+			<File
+				RelativePath=".\tunnel.c"
+				>
+			</File>
+			<File
+				RelativePath=".\util.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Í·Îļþ"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\atom.h"
+				>
+			</File>
+			<File
+				RelativePath=".\auth.h"
+				>
+			</File>
+			<File
+				RelativePath=".\chunk.h"
+				>
+			</File>
+			<File
+				RelativePath=".\client.h"
+				>
+			</File>
+			<File
+				RelativePath=".\config.h"
+				>
+			</File>
+			<File
+				RelativePath=".\diskcache.h"
+				>
+			</File>
+			<File
+				RelativePath=".\dns.h"
+				>
+			</File>
+			<File
+				RelativePath=".\event.h"
+				>
+			</File>
+			<File
+				RelativePath=".\forbidden.h"
+				>
+			</File>
+			<File
+				RelativePath=".\fts_compat.h"
+				>
+			</File>
+			<File
+				RelativePath=".\ftsimport.h"
+				>
+			</File>
+			<File
+				RelativePath=".\http.h"
+				>
+			</File>
+			<File
+				RelativePath=".\http_parse.h"
+				>
+			</File>
+			<File
+				RelativePath=".\io.h"
+				>
+			</File>
+			<File
+				RelativePath=".\local.h"
+				>
+			</File>
+			<File
+				RelativePath=".\log.h"
+				>
+			</File>
+			<File
+				RelativePath=".\md5.h"
+				>
+			</File>
+			<File
+				RelativePath=".\md5import.h"
+				>
+			</File>
+			<File
+				RelativePath=".\mingw.h"
+				>
+			</File>
+			<File
+				RelativePath=".\object.h"
+				>
+			</File>
+			<File
+				RelativePath=".\parse_time.h"
+				>
+			</File>
+			<File
+				RelativePath=".\polipo.h"
+				>
+			</File>
+			<File
+				RelativePath=".\server.h"
+				>
+			</File>
+			<File
+				RelativePath=".\socks.h"
+				>
+			</File>
+			<File
+				RelativePath=".\tunnel.h"
+				>
+			</File>
+			<File
+				RelativePath=".\util.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="port"
+			>
+			<File
+				RelativePath=".\dirent.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dirent.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
-- 
1.6.5.1.msysgit.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.