Fix various compile errors.

Temporarily restrict Appveyor to one config.
diff --git a/appveyor.yml b/appveyor.yml
index 9954edf..8a9b6f7 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -7,42 +7,42 @@
       TRIPLET: x64-windows
       CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
       CMAKE_CONFIG: Release
-    - GENERATOR: "Visual Studio 15 2017 Win64"
-      TRIPLET: x64-windows
-      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
-      CMAKE_CONFIG: Debug
-    - GENERATOR: "Visual Studio 15 2017 Win64"
-      TRIPLET: x64-uwp
-      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0"
-      CMAKE_CONFIG: Release
-    - GENERATOR: "Visual Studio 15 2017"
-      TRIPLET: x86-windows
-      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
-      CMAKE_CONFIG: Release
-    - GENERATOR: "Visual Studio 15 2017"
-      TRIPLET: x86-windows
-      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
-      CMAKE_CONFIG: Debug
-    - GENERATOR: "Visual Studio 15 2017"
-      TRIPLET: x86-uwp
-      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0"
-      CMAKE_CONFIG: Release
-    - GENERATOR: "Visual Studio 15 2017 ARM"
-      TRIPLET: arm-windows
-      CMAKE_OPTS: "-DENABLE_OPENSSL=off"
-      CMAKE_CONFIG: Release
-    - GENERATOR: "Visual Studio 15 2017 ARM"
-      TRIPLET: arm-uwp
-      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off"
-      CMAKE_CONFIG: Release
-    - GENERATOR: "Visual Studio 15 2017"
-      TRIPLET: arm64-windows
-      CMAKE_OPTS: "-AARM64 -DENABLE_OPENSSL=off"
-      CMAKE_CONFIG: Release
-    - GENERATOR: "Visual Studio 15 2017"
-      TRIPLET: arm64-uwp
-      CMAKE_OPTS: "-AARM64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off"
-      CMAKE_CONFIG: Release
+#    - GENERATOR: "Visual Studio 15 2017 Win64"
+#      TRIPLET: x64-windows
+#      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
+#      CMAKE_CONFIG: Debug
+#    - GENERATOR: "Visual Studio 15 2017 Win64"
+#      TRIPLET: x64-uwp
+#      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0"
+#      CMAKE_CONFIG: Release
+#   - GENERATOR: "Visual Studio 15 2017"
+#      TRIPLET: x86-windows
+#      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
+#      CMAKE_CONFIG: Release
+#    - GENERATOR: "Visual Studio 15 2017"
+#      TRIPLET: x86-windows
+#      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
+#      CMAKE_CONFIG: Debug
+#    - GENERATOR: "Visual Studio 15 2017"
+#      TRIPLET: x86-uwp
+#      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0"
+#      CMAKE_CONFIG: Release
+#    - GENERATOR: "Visual Studio 15 2017 ARM"
+#      TRIPLET: arm-windows
+#      CMAKE_OPTS: "-DENABLE_OPENSSL=off"
+#      CMAKE_CONFIG: Release
+#    - GENERATOR: "Visual Studio 15 2017 ARM"
+#      TRIPLET: arm-uwp
+#      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off"
+#      CMAKE_CONFIG: Release
+#    - GENERATOR: "Visual Studio 15 2017"
+#      TRIPLET: arm64-windows
+#      CMAKE_OPTS: "-AARM64 -DENABLE_OPENSSL=off"
+#      CMAKE_CONFIG: Release
+#    - GENERATOR: "Visual Studio 15 2017"
+#      TRIPLET: arm64-uwp
+#      CMAKE_OPTS: "-AARM64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off"
+#      CMAKE_CONFIG: Release
 
 before_build:
   cmd: >-
diff --git a/developer-xcode/libzip.xcodeproj/project.pbxproj b/developer-xcode/libzip.xcodeproj/project.pbxproj
index 8ef4e86..f58cd06 100644
--- a/developer-xcode/libzip.xcodeproj/project.pbxproj
+++ b/developer-xcode/libzip.xcodeproj/project.pbxproj
@@ -638,6 +638,7 @@
 		4B93996224643F5700AEBDA4 /* zip_source_file_win32_utf8.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = zip_source_file_win32_utf8.c; sourceTree = "<group>"; };
 		4B9399632464401300AEBDA4 /* zip_source_file_win32_utf16.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zip_source_file_win32_utf16.c; sourceTree = "<group>"; };
 		4B93996424644E7E00AEBDA4 /* zip_source_file_win32_write.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = zip_source_file_win32_write.c; sourceTree = "<group>"; };
+		4B939965246553FD00AEBDA4 /* appveyor.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = appveyor.yml; sourceTree = "<group>"; };
 		4B97204D188EBE85002FAFAD /* zip_file_get_external_attributes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zip_file_get_external_attributes.c; sourceTree = "<group>"; };
 		4B97204E188EBE85002FAFAD /* zip_file_set_external_attributes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zip_file_set_external_attributes.c; sourceTree = "<group>"; };
 		4BACD57715BC2AEF00920691 /* add_from_filep.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = add_from_filep.c; path = ../regress/add_from_filep.c; sourceTree = "<group>"; };
@@ -1168,6 +1169,7 @@
 		4B28AA2815BAD4F800D0C17D /* info */ = {
 			isa = PBXGroup;
 			children = (
+				4B939965246553FD00AEBDA4 /* appveyor.yml */,
 				4B28AA2215BAD4E200D0C17D /* API-CHANGES.md */,
 				4B28AA2315BAD4E200D0C17D /* AUTHORS */,
 				4B28AA2415BAD4E200D0C17D /* NEWS.md */,
diff --git a/lib/zip_source_file_win32.c b/lib/zip_source_file_win32.c
index dbb21da..0ee5298 100644
--- a/lib/zip_source_file_win32.c
+++ b/lib/zip_source_file_win32.c
@@ -33,6 +33,10 @@
 
 #include "zip_source_file_win32.h"
 
+static bool _zip_win32_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st);
+
+static int _zip_filetime_to_time_t(FILETIME ft, time_t *t);
+
 static zip_source_file_operations_t ops_win32_read = {
     _zip_win32_op_close,
     NULL,
@@ -67,7 +71,7 @@
         return NULL;
     }
 
-    return zip_source_file_common_new(NULL, h, start, len, NULL, ops_win32_read, NULL, error);
+    return zip_source_file_common_new(NULL, h, start, length, NULL, ops_win32_read, NULL, error);
 }
 
 
@@ -106,13 +110,13 @@
         method = FILE_CURRENT;
         break;
     default:
-        zip_error_set(error, ZIP_ER_SEEK, EINVAL);
+        zip_error_set(&ctx->error, ZIP_ER_SEEK, EINVAL);
         return -1;
     }
 
     li.QuadPart = (LONGLONG)offset;
-    if (!SetFilePointerEx(h, li, NULL, method)) {
-    zip_error_set(error, ZIP_ER_SEEK, _zip_win32_error_to_errno(GetLastError()));
+    if (!SetFilePointerEx((HANDLE)ctx->f, li, NULL, method)) {
+    zip_error_set(&ctx->error, ZIP_ER_SEEK, _zip_win32_error_to_errno(GetLastError()));
         return false;
     }
 
@@ -175,63 +179,6 @@
     }
 }
 
-zip_int64_t
-_zip_win32_create_temp_output(zip_source_file_context_t *ctx, char *tmpname, size_t tmpname_size, _zip_win32_open_t open, _zip_win32_mktmepname_t mktempname) {
-    /* Windows has GetTempFileName(), but it closes the file after
-     creation, leaving it open to a horrible race condition. So
-     we reinvent the wheel.
-     */
-     
-    int i;
-    HANDLE th = INVALID_HANDLE_VALUE;
-    void *temp = NULL;
-    PSECURITY_DESCRIPTOR psd = NULL;
-    PSECURITY_ATTRIBUTES psa = NULL;
-    SECURITY_ATTRIBUTES sa;
-    SECURITY_INFORMATION si;
-    DWORD success;
-    PACL dacl = NULL;
-
-    /*
-     Read the DACL from the original file, so we can copy it to the temp file.
-     If there is no original file, or if we can't read the DACL, we'll use the
-     default security descriptor.
-     */
-     
-    if ((HANDLE)ctx->f != INVALID_HANDLE_VALUE && GetFileType((HANDLE)ctx->f) == FILE_TYPE_DISK) {
-        si = DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION;
-        success = GetSecurityInfo(ctx->h, SE_FILE_OBJECT, si, NULL, NULL, &dacl, NULL, &psd);
-        if (success == ERROR_SUCCESS) {
-            sa.nLength = sizeof(SECURITY_ATTRIBUTES);
-            sa.bInheritHandle = FALSE;
-            sa.lpSecurityDescriptor = psd;
-            psa = &sa;
-        }
-    }
-
-    #ifndef MS_UWP
-        value = GetTickCount();
-    #else
-        value = (zip_uint32_t)GetTickCount64();
-    #endif
-
-    for (i = 0; i < 1024 && th == INVALID_HANDLE_VALUE; i++) {
-        mktempname(tmpname, tmpname_size, value + i);
-        th = open(ctx, tmpname, true, psa);
-
-        if (th == INVALID_HANDLE_VALUE && GetLastError() != ERROR_FILE_EXISTS)
-            break;
-    }
-
-    LocalFree(psd);
-
-    if (th == INVALID_HANDLE_VALUE) {
-        zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, _zip_win32_error_to_errno(GetLastError()));
-        return INVALID_HANDLE_VALUE;
-    }
-
-    return th;
-}
 
 bool
 _zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HANDLE h) {
@@ -260,7 +207,7 @@
             return false;
         }
 
-        st->size = size;
+        st->size = (zip_uint64_t)size.QuadPart;
     }
     
     /* TODO: fill in ctx->attributes */
diff --git a/lib/zip_source_file_win32.h b/lib/zip_source_file_win32.h
index 5e0b096..949d670 100644
--- a/lib/zip_source_file_win32.h
+++ b/lib/zip_source_file_win32.h
@@ -49,7 +49,7 @@
 
 struct zip_source_file_win32_write_operations {
     char *(*allocate_tempname)(const char *name, size_t extra_chars),
-    void *(*create_file)(const char *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, void *template_file),
+    void *(*create_file)(const char *, DWORD, DWORD, PSECURITY_ATTRIBUTES, DWORD, DWORD, void *),
     bool (*delete_file)(const char *name),
     DWORD (*get_file_attributes)(const char *name),
     void (*make_tempname)(char *buf, size_t len, const char *name, int i),
diff --git a/lib/zip_source_file_win32_write.c b/lib/zip_source_file_win32_write.c
index 640860f..8989fc8 100644
--- a/lib/zip_source_file_win32_write.c
+++ b/lib/zip_source_file_win32_write.c
@@ -109,7 +109,7 @@
 
      if ((HANDLE)ctx->f != INVALID_HANDLE_VALUE && GetFileType((HANDLE)ctx->f) == FILE_TYPE_DISK) {
          si = DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION;
-         success = GetSecurityInfo(ctx->h, SE_FILE_OBJECT, si, NULL, NULL, &dacl, NULL, &psd);
+         success = GetSecurityInfo((HANDLE)ctx->f, SE_FILE_OBJECT, si, NULL, NULL, &dacl, NULL, &psd);
          if (success == ERROR_SUCCESS) {
              sa.nLength = sizeof(SECURITY_ATTRIBUTES);
              sa.bInheritHandle = FALSE;
@@ -125,7 +125,7 @@
 #endif
     
     if ((tempname = write_ops->allocate_tempname(ctx->fname, 10, &tempname_size)) == NULL) {
-        zip_error_set(&ctx->error, ZIP_ER_NOMEM, 0);
+        zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0);
         return -1;
     }
         
@@ -203,6 +203,8 @@
 
 static HANDLE
 win32_write_open(zip_source_file_context_t *ctx, const char *name, bool temporary, PSECURITY_ATTRIBUTES security_attributes) {
+    zip_source_file_win32_write_operations_t *write_ops = (zip_source_file_win32_write_operations_t *)ctx->ops_userdata;
+
     DWORD access = GENERIC_READ;
     DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;
     DWORD creation_disposition = OPEN_EXISTING;