kusano fc6ab3
/* iowin32.c -- IO base function header for compress/uncompress .zip
kusano fc6ab3
     Version 1.1, February 14h, 2010
kusano fc6ab3
     part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
kusano fc6ab3
kusano fc6ab3
         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
kusano fc6ab3
kusano fc6ab3
         Modifications for Zip64 support
kusano fc6ab3
         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
kusano fc6ab3
kusano fc6ab3
     For more info read MiniZip_info.txt
kusano fc6ab3
kusano fc6ab3
*/
kusano fc6ab3
kusano fc6ab3
#include <stdlib.h></stdlib.h>
kusano fc6ab3
kusano fc6ab3
#include "zlib.h"
kusano fc6ab3
#include "ioapi.h"
kusano fc6ab3
#include "iowin32.h"
kusano fc6ab3
kusano fc6ab3
#ifndef INVALID_HANDLE_VALUE
kusano fc6ab3
#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
kusano fc6ab3
#endif
kusano fc6ab3
kusano fc6ab3
#ifndef INVALID_SET_FILE_POINTER
kusano fc6ab3
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
kusano fc6ab3
#endif
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
kusano fc6ab3
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
kusano fc6ab3
#define IOWIN32_USING_WINRT_API 1
kusano fc6ab3
#endif
kusano fc6ab3
#endif
kusano fc6ab3
kusano fc6ab3
voidpf  ZCALLBACK win32_open_file_func  OF((voidpf opaque, const char* filename, int mode));
kusano fc6ab3
uLong   ZCALLBACK win32_read_file_func  OF((voidpf opaque, voidpf stream, void* buf, uLong size));
kusano fc6ab3
uLong   ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
kusano fc6ab3
ZPOS64_T ZCALLBACK win32_tell64_file_func  OF((voidpf opaque, voidpf stream));
kusano fc6ab3
long    ZCALLBACK win32_seek64_file_func  OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
kusano fc6ab3
int     ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
kusano fc6ab3
int     ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
kusano fc6ab3
kusano fc6ab3
typedef struct
kusano fc6ab3
{
kusano fc6ab3
    HANDLE hf;
kusano fc6ab3
    int error;
kusano fc6ab3
} WIN32FILE_IOWIN;
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
static void win32_translate_open_mode(int mode,
kusano fc6ab3
                                      DWORD* lpdwDesiredAccess,
kusano fc6ab3
                                      DWORD* lpdwCreationDisposition,
kusano fc6ab3
                                      DWORD* lpdwShareMode,
kusano fc6ab3
                                      DWORD* lpdwFlagsAndAttributes)
kusano fc6ab3
{
kusano fc6ab3
    *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
kusano fc6ab3
kusano fc6ab3
    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
kusano fc6ab3
    {
kusano fc6ab3
        *lpdwDesiredAccess = GENERIC_READ;
kusano fc6ab3
        *lpdwCreationDisposition = OPEN_EXISTING;
kusano fc6ab3
        *lpdwShareMode = FILE_SHARE_READ;
kusano fc6ab3
    }
kusano fc6ab3
    else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
kusano fc6ab3
    {
kusano fc6ab3
        *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
kusano fc6ab3
        *lpdwCreationDisposition = OPEN_EXISTING;
kusano fc6ab3
    }
kusano fc6ab3
    else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
kusano fc6ab3
    {
kusano fc6ab3
        *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
kusano fc6ab3
        *lpdwCreationDisposition = CREATE_ALWAYS;
kusano fc6ab3
    }
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
static voidpf win32_build_iowin(HANDLE hFile)
kusano fc6ab3
{
kusano fc6ab3
    voidpf ret=NULL;
kusano fc6ab3
kusano fc6ab3
    if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
kusano fc6ab3
    {
kusano fc6ab3
        WIN32FILE_IOWIN w32fiow;
kusano fc6ab3
        w32fiow.hf = hFile;
kusano fc6ab3
        w32fiow.error = 0;
kusano fc6ab3
        ret = malloc(sizeof(WIN32FILE_IOWIN));
kusano fc6ab3
kusano fc6ab3
        if (ret==NULL)
kusano fc6ab3
            CloseHandle(hFile);
kusano fc6ab3
        else
kusano fc6ab3
            *((WIN32FILE_IOWIN*)ret) = w32fiow;
kusano fc6ab3
    }
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
kusano fc6ab3
{
kusano fc6ab3
    const char* mode_fopen = NULL;
kusano fc6ab3
    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
kusano fc6ab3
    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
kusano fc6ab3
kusano fc6ab3
#ifdef IOWIN32_USING_WINRT_API
kusano fc6ab3
#ifdef UNICODE
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
        hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
kusano fc6ab3
#else
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
    {
kusano fc6ab3
        WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
kusano fc6ab3
        MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
kusano fc6ab3
        hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
kusano fc6ab3
    }
kusano fc6ab3
#endif
kusano fc6ab3
#else
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
        hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
kusano fc6ab3
#endif
kusano fc6ab3
kusano fc6ab3
    return win32_build_iowin(hFile);
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
kusano fc6ab3
{
kusano fc6ab3
    const char* mode_fopen = NULL;
kusano fc6ab3
    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
kusano fc6ab3
    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
kusano fc6ab3
kusano fc6ab3
#ifdef IOWIN32_USING_WINRT_API
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
    {
kusano fc6ab3
        WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
kusano fc6ab3
        MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
kusano fc6ab3
        hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
kusano fc6ab3
    }
kusano fc6ab3
#else
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
        hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
kusano fc6ab3
#endif
kusano fc6ab3
kusano fc6ab3
    return win32_build_iowin(hFile);
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
kusano fc6ab3
{
kusano fc6ab3
    const char* mode_fopen = NULL;
kusano fc6ab3
    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
kusano fc6ab3
    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
kusano fc6ab3
kusano fc6ab3
#ifdef IOWIN32_USING_WINRT_API
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
        hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL);
kusano fc6ab3
#else
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
        hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
kusano fc6ab3
#endif
kusano fc6ab3
kusano fc6ab3
    return win32_build_iowin(hFile);
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
kusano fc6ab3
{
kusano fc6ab3
    const char* mode_fopen = NULL;
kusano fc6ab3
    DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
kusano fc6ab3
    win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
kusano fc6ab3
kusano fc6ab3
#ifdef IOWIN32_USING_WINRT_API
kusano fc6ab3
#ifdef UNICODE
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
        hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
kusano fc6ab3
#else
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
    {
kusano fc6ab3
        WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
kusano fc6ab3
        MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
kusano fc6ab3
        hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
kusano fc6ab3
    }
kusano fc6ab3
#endif
kusano fc6ab3
#else
kusano fc6ab3
    if ((filename!=NULL) && (dwDesiredAccess != 0))
kusano fc6ab3
        hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
kusano fc6ab3
#endif
kusano fc6ab3
kusano fc6ab3
    return win32_build_iowin(hFile);
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
kusano fc6ab3
{
kusano fc6ab3
    uLong ret=0;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
kusano fc6ab3
kusano fc6ab3
    if (hFile != NULL)
kusano fc6ab3
    {
kusano fc6ab3
        if (!ReadFile(hFile, buf, size, &ret, NULL))
kusano fc6ab3
        {
kusano fc6ab3
            DWORD dwErr = GetLastError();
kusano fc6ab3
            if (dwErr == ERROR_HANDLE_EOF)
kusano fc6ab3
                dwErr = 0;
kusano fc6ab3
            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
kusano fc6ab3
        }
kusano fc6ab3
    }
kusano fc6ab3
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
kusano fc6ab3
{
kusano fc6ab3
    uLong ret=0;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
kusano fc6ab3
kusano fc6ab3
    if (hFile != NULL)
kusano fc6ab3
    {
kusano fc6ab3
        if (!WriteFile(hFile, buf, size, &ret, NULL))
kusano fc6ab3
        {
kusano fc6ab3
            DWORD dwErr = GetLastError();
kusano fc6ab3
            if (dwErr == ERROR_HANDLE_EOF)
kusano fc6ab3
                dwErr = 0;
kusano fc6ab3
            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
kusano fc6ab3
        }
kusano fc6ab3
    }
kusano fc6ab3
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos,  DWORD dwMoveMethod)
kusano fc6ab3
{
kusano fc6ab3
#ifdef IOWIN32_USING_WINRT_API
kusano fc6ab3
    return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
kusano fc6ab3
#else
kusano fc6ab3
    LONG lHigh = pos.HighPart;
kusano fc6ab3
    DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, FILE_CURRENT);
kusano fc6ab3
    BOOL fOk = TRUE;
kusano fc6ab3
    if (dwNewPos == 0xFFFFFFFF)
kusano fc6ab3
        if (GetLastError() != NO_ERROR)
kusano fc6ab3
            fOk = FALSE;
kusano fc6ab3
    if ((newPos != NULL) && (fOk))
kusano fc6ab3
    {
kusano fc6ab3
        newPos->LowPart = dwNewPos;
kusano fc6ab3
        newPos->HighPart = lHigh;
kusano fc6ab3
    }
kusano fc6ab3
    return fOk;
kusano fc6ab3
#endif
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
kusano fc6ab3
{
kusano fc6ab3
    long ret=-1;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
kusano fc6ab3
    if (hFile != NULL)
kusano fc6ab3
    {
kusano fc6ab3
        LARGE_INTEGER pos;
kusano fc6ab3
        pos.QuadPart = 0;
kusano fc6ab3
kusano fc6ab3
        if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
kusano fc6ab3
        {
kusano fc6ab3
            DWORD dwErr = GetLastError();
kusano fc6ab3
            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
kusano fc6ab3
            ret = -1;
kusano fc6ab3
        }
kusano fc6ab3
        else
kusano fc6ab3
            ret=(long)pos.LowPart;
kusano fc6ab3
    }
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
kusano fc6ab3
{
kusano fc6ab3
    ZPOS64_T ret= (ZPOS64_T)-1;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
        hFile = ((WIN32FILE_IOWIN*)stream)->hf;
kusano fc6ab3
kusano fc6ab3
    if (hFile)
kusano fc6ab3
    {
kusano fc6ab3
        LARGE_INTEGER pos;
kusano fc6ab3
        pos.QuadPart = 0;
kusano fc6ab3
kusano fc6ab3
        if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
kusano fc6ab3
        {
kusano fc6ab3
            DWORD dwErr = GetLastError();
kusano fc6ab3
            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
kusano fc6ab3
            ret = (ZPOS64_T)-1;
kusano fc6ab3
        }
kusano fc6ab3
        else
kusano fc6ab3
            ret=pos.QuadPart;
kusano fc6ab3
    }
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
kusano fc6ab3
{
kusano fc6ab3
    DWORD dwMoveMethod=0xFFFFFFFF;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
kusano fc6ab3
    long ret=-1;
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
kusano fc6ab3
    switch (origin)
kusano fc6ab3
    {
kusano fc6ab3
    case ZLIB_FILEFUNC_SEEK_CUR :
kusano fc6ab3
        dwMoveMethod = FILE_CURRENT;
kusano fc6ab3
        break;
kusano fc6ab3
    case ZLIB_FILEFUNC_SEEK_END :
kusano fc6ab3
        dwMoveMethod = FILE_END;
kusano fc6ab3
        break;
kusano fc6ab3
    case ZLIB_FILEFUNC_SEEK_SET :
kusano fc6ab3
        dwMoveMethod = FILE_BEGIN;
kusano fc6ab3
        break;
kusano fc6ab3
    default: return -1;
kusano fc6ab3
    }
kusano fc6ab3
kusano fc6ab3
    if (hFile != NULL)
kusano fc6ab3
    {
kusano fc6ab3
        LARGE_INTEGER pos;
kusano fc6ab3
        pos.QuadPart = offset;
kusano fc6ab3
        if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
kusano fc6ab3
        {
kusano fc6ab3
            DWORD dwErr = GetLastError();
kusano fc6ab3
            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
kusano fc6ab3
            ret = -1;
kusano fc6ab3
        }
kusano fc6ab3
        else
kusano fc6ab3
            ret=0;
kusano fc6ab3
    }
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
kusano fc6ab3
{
kusano fc6ab3
    DWORD dwMoveMethod=0xFFFFFFFF;
kusano fc6ab3
    HANDLE hFile = NULL;
kusano fc6ab3
    long ret=-1;
kusano fc6ab3
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
        hFile = ((WIN32FILE_IOWIN*)stream)->hf;
kusano fc6ab3
kusano fc6ab3
    switch (origin)
kusano fc6ab3
    {
kusano fc6ab3
        case ZLIB_FILEFUNC_SEEK_CUR :
kusano fc6ab3
            dwMoveMethod = FILE_CURRENT;
kusano fc6ab3
            break;
kusano fc6ab3
        case ZLIB_FILEFUNC_SEEK_END :
kusano fc6ab3
            dwMoveMethod = FILE_END;
kusano fc6ab3
            break;
kusano fc6ab3
        case ZLIB_FILEFUNC_SEEK_SET :
kusano fc6ab3
            dwMoveMethod = FILE_BEGIN;
kusano fc6ab3
            break;
kusano fc6ab3
        default: return -1;
kusano fc6ab3
    }
kusano fc6ab3
kusano fc6ab3
    if (hFile)
kusano fc6ab3
    {
kusano fc6ab3
        LARGE_INTEGER pos;
kusano fc6ab3
        pos.QuadPart = offset;
kusano fc6ab3
        if (!MySetFilePointerEx(hFile, pos, NULL, FILE_CURRENT))
kusano fc6ab3
        {
kusano fc6ab3
            DWORD dwErr = GetLastError();
kusano fc6ab3
            ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
kusano fc6ab3
            ret = -1;
kusano fc6ab3
        }
kusano fc6ab3
        else
kusano fc6ab3
            ret=0;
kusano fc6ab3
    }
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
kusano fc6ab3
{
kusano fc6ab3
    int ret=-1;
kusano fc6ab3
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
    {
kusano fc6ab3
        HANDLE hFile;
kusano fc6ab3
        hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
kusano fc6ab3
        if (hFile != NULL)
kusano fc6ab3
        {
kusano fc6ab3
            CloseHandle(hFile);
kusano fc6ab3
            ret=0;
kusano fc6ab3
        }
kusano fc6ab3
        free(stream);
kusano fc6ab3
    }
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
kusano fc6ab3
{
kusano fc6ab3
    int ret=-1;
kusano fc6ab3
    if (stream!=NULL)
kusano fc6ab3
    {
kusano fc6ab3
        ret = ((WIN32FILE_IOWIN*)stream) -> error;
kusano fc6ab3
    }
kusano fc6ab3
    return ret;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
kusano fc6ab3
{
kusano fc6ab3
    pzlib_filefunc_def->zopen_file = win32_open_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zread_file = win32_read_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
kusano fc6ab3
    pzlib_filefunc_def->ztell_file = win32_tell_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zseek_file = win32_seek_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zclose_file = win32_close_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zerror_file = win32_error_file_func;
kusano fc6ab3
    pzlib_filefunc_def->opaque = NULL;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
kusano fc6ab3
{
kusano fc6ab3
    pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zread_file = win32_read_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
kusano fc6ab3
    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zclose_file = win32_close_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zerror_file = win32_error_file_func;
kusano fc6ab3
    pzlib_filefunc_def->opaque = NULL;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
kusano fc6ab3
{
kusano fc6ab3
    pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
kusano fc6ab3
    pzlib_filefunc_def->zread_file = win32_read_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
kusano fc6ab3
    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zclose_file = win32_close_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zerror_file = win32_error_file_func;
kusano fc6ab3
    pzlib_filefunc_def->opaque = NULL;
kusano fc6ab3
}
kusano fc6ab3
kusano fc6ab3
kusano fc6ab3
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
kusano fc6ab3
{
kusano fc6ab3
    pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
kusano fc6ab3
    pzlib_filefunc_def->zread_file = win32_read_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zwrite_file = win32_write_file_func;
kusano fc6ab3
    pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zclose_file = win32_close_file_func;
kusano fc6ab3
    pzlib_filefunc_def->zerror_file = win32_error_file_func;
kusano fc6ab3
    pzlib_filefunc_def->opaque = NULL;
kusano fc6ab3
}