apply VC9 patch
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/mkstemp.c
--- a/lib/mkstemp.c Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/mkstemp.c Fri Aug 22 01:35:34 2008 +0900
@@ -45,6 +45,15 @@
#ifndef O_BINARY
#define O_BINARY 0
+#endif
+
+#ifdef _MSC_VER
+#include <io.h>
+#include <process.h>
+typedef int pid_t;
+#define getpid() _getpid()
+#define open(p, f, m) _open((p), ((f) | _O_BINARY), _S_IREAD | _S_IWRITE)
+#define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
#endif
^L
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zip.h
--- a/lib/zip.h Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zip.h Fri Aug 22 01:35:34 2008 +0900
@@ -53,6 +53,10 @@
#include <sys/types.h>
#include <stdio.h>
#include <time.h>
+
+#ifdef _MSC_VER
+typedef int ssize_t;
+#endif
/* flags for zip_open */
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zip_close.c
--- a/lib/zip_close.c Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zip_close.c Fri Aug 22 01:35:34 2008 +0900
@@ -40,6 +40,19 @@
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef _MSC_VER
+#include <io.h>
+#define close(f) _close(f)
+#define fdopen(f, m) _fdopen((f), (m))
+#define strcasecmp(s1, s2) _stricmp((s1), (s2))
+#define strdup(s) _strdup(s)
+#if _MSC_VER >=1400
+#define snprintf(s, n, f, ...) _snprintf((s), (n), (f), __VA_ARGS__)
+#else
+#define snprintf _snprintf
+#endif
+#endif
+
#include "zipint.h"
static int add_data(struct zip *, struct zip_source *, struct zip_dirent *,
@@ -72,7 +85,9 @@
int i, j, error;
char *temp;
FILE *out;
+#ifndef _MSC_VER
mode_t mask;
+#endif
struct zip_cdir *cd;
struct zip_dirent de;
struct filelist *filelist;
@@ -301,9 +316,11 @@
}
return -1;
}
+#ifndef _MSC_VER
mask = umask(0);
umask(mask);
chmod(za->zn, 0666&~mask);
+#endif
_zip_free(za);
free(temp);
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zip_error_to_str.c
--- a/lib/zip_error_to_str.c Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zip_error_to_str.c Fri Aug 22 01:35:34 2008 +0900
@@ -38,6 +38,13 @@
#include <stdlib.h>
#include <string.h>
+#ifdef _MSC_VER
+#if _MSC_VER >=1400
+#define snprintf(s, n, f, ...) _snprintf((s), (n), (f), __VA_ARGS__)
+#else
+#define snprintf _snprintf
+#endif
+
#include "zipint.h"
^L
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zip_name_locate.c
--- a/lib/zip_name_locate.c Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zip_name_locate.c Fri Aug 22 01:35:34 2008 +0900
@@ -34,6 +34,10 @@
^L
#include <string.h>
+
+#ifdef _MSC_VER
+#define strcasecmp _stricmp
+#endif
#include "zipint.h"
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zip_open.c
--- a/lib/zip_open.c Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zip_open.c Fri Aug 22 01:35:34 2008 +0900
@@ -39,6 +39,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#ifdef _MSC_VER
+#define strdup(s) _strdup(s)
+#endif
#include "zipint.h"
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zip_set_name.c
--- a/lib/zip_set_name.c Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zip_set_name.c Fri Aug 22 01:35:34 2008 +0900
@@ -36,6 +36,10 @@
#include <stdlib.h>
#include <string.h>
+#ifdef _MSC_VER
+#define strdup(s) _strdup(s)
+#endif
+
#include "zipint.h"
^L
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zip_source_filep.c
--- a/lib/zip_source_filep.c Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zip_source_filep.c Fri Aug 22 01:35:34 2008 +0900
@@ -38,6 +38,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#ifdef _MSC_VER
+#define fileno(f) _fileno(f)
+#define strdup(s) _strdup(s)
+#endif
#include "zipint.h"
diff -r 42fb66a37ba6 -r 44261ec59c90 lib/zipint.h
--- a/lib/zipint.h Sun Aug 03 20:14:40 2008 +0200
+++ b/lib/zipint.h Fri Aug 22 01:35:34 2008 +0900
@@ -37,11 +37,17 @@
#include <zlib.h>
#ifdef _MSC_VER
+#ifdef _EXPORTING
+#define ZIP_EXTERN __declspec(dllexport)
+#else
#define ZIP_EXTERN __declspec(dllimport)
+#endif
#endif
#include "zip.h"
+#ifndef _MSC_VER
#include "config.h"
+#endif
#ifndef HAVE_MKSTEMP
int _zip_mkstemp(char *);