Home | History | Annotate | Line # | Download | only in minizip
      1      1.1  christos /* ioapi.h -- IO base function header for compress/uncompress .zip
      2  1.1.1.2  christos    part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
      3  1.1.1.2  christos 
      4  1.1.1.2  christos          Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
      5  1.1.1.2  christos 
      6  1.1.1.2  christos          Modifications for Zip64 support
      7  1.1.1.2  christos          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
      8  1.1.1.2  christos 
      9  1.1.1.2  christos          For more info read MiniZip_info.txt
     10      1.1  christos 
     11  1.1.1.2  christos          Changes
     12  1.1.1.2  christos 
     13  1.1.1.2  christos     Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
     14  1.1.1.2  christos     Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
     15  1.1.1.2  christos                More if/def section may be needed to support other platforms
     16  1.1.1.2  christos     Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
     17  1.1.1.2  christos                           (but you should use iowin32.c for windows instead)
     18      1.1  christos 
     19      1.1  christos */
     20      1.1  christos 
     21  1.1.1.2  christos #ifndef _ZLIBIOAPI64_H
     22  1.1.1.2  christos #define _ZLIBIOAPI64_H
     23  1.1.1.2  christos 
     24  1.1.1.2  christos #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
     25  1.1.1.2  christos 
     26  1.1.1.2  christos   // Linux needs this to support file operation on files larger then 4+GB
     27  1.1.1.2  christos   // But might need better if/def to select just the platforms that needs them.
     28  1.1.1.2  christos 
     29  1.1.1.2  christos         #ifndef __USE_FILE_OFFSET64
     30  1.1.1.2  christos                 #define __USE_FILE_OFFSET64
     31  1.1.1.2  christos         #endif
     32  1.1.1.2  christos         #ifndef __USE_LARGEFILE64
     33  1.1.1.2  christos                 #define __USE_LARGEFILE64
     34  1.1.1.2  christos         #endif
     35  1.1.1.2  christos         #ifndef _LARGEFILE64_SOURCE
     36  1.1.1.2  christos                 #define _LARGEFILE64_SOURCE
     37  1.1.1.2  christos         #endif
     38  1.1.1.2  christos         #ifndef _FILE_OFFSET_BIT
     39  1.1.1.2  christos                 #define _FILE_OFFSET_BIT 64
     40  1.1.1.2  christos         #endif
     41  1.1.1.2  christos 
     42  1.1.1.2  christos #endif
     43  1.1.1.2  christos 
     44  1.1.1.2  christos #include <stdio.h>
     45  1.1.1.2  christos #include <stdlib.h>
     46  1.1.1.2  christos #include "zlib.h"
     47  1.1.1.2  christos 
     48  1.1.1.2  christos #if defined(USE_FILE32API)
     49  1.1.1.2  christos #define fopen64 fopen
     50  1.1.1.2  christos #define ftello64 ftell
     51  1.1.1.2  christos #define fseeko64 fseek
     52  1.1.1.2  christos #else
     53  1.1.1.4  christos #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
     54  1.1.1.2  christos #define fopen64 fopen
     55  1.1.1.2  christos #define ftello64 ftello
     56  1.1.1.2  christos #define fseeko64 fseeko
     57  1.1.1.2  christos #endif
     58  1.1.1.2  christos #ifdef _MSC_VER
     59  1.1.1.2  christos  #define fopen64 fopen
     60  1.1.1.2  christos  #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
     61  1.1.1.2  christos   #define ftello64 _ftelli64
     62  1.1.1.2  christos   #define fseeko64 _fseeki64
     63  1.1.1.2  christos  #else // old MSC
     64  1.1.1.2  christos   #define ftello64 ftell
     65  1.1.1.2  christos   #define fseeko64 fseek
     66  1.1.1.2  christos  #endif
     67  1.1.1.2  christos #endif
     68  1.1.1.2  christos #endif
     69  1.1.1.2  christos 
     70  1.1.1.2  christos /*
     71  1.1.1.2  christos #ifndef ZPOS64_T
     72  1.1.1.2  christos   #ifdef _WIN32
     73  1.1.1.2  christos                 #define ZPOS64_T fpos_t
     74  1.1.1.2  christos   #else
     75  1.1.1.2  christos     #include <stdint.h>
     76  1.1.1.2  christos     #define ZPOS64_T uint64_t
     77  1.1.1.2  christos   #endif
     78  1.1.1.2  christos #endif
     79  1.1.1.2  christos */
     80  1.1.1.2  christos 
     81  1.1.1.2  christos #ifdef HAVE_MINIZIP64_CONF_H
     82  1.1.1.2  christos #include "mz64conf.h"
     83  1.1.1.2  christos #endif
     84  1.1.1.2  christos 
     85  1.1.1.4  christos /* a type chosen by DEFINE */
     86  1.1.1.2  christos #ifdef HAVE_64BIT_INT_CUSTOM
     87  1.1.1.2  christos typedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;
     88  1.1.1.2  christos #else
     89  1.1.1.2  christos #ifdef HAS_STDINT_H
     90  1.1.1.2  christos #include "stdint.h"
     91  1.1.1.2  christos typedef uint64_t ZPOS64_T;
     92  1.1.1.2  christos #else
     93  1.1.1.2  christos 
     94  1.1.1.3  christos 
     95  1.1.1.2  christos 
     96  1.1.1.2  christos #if defined(_MSC_VER) || defined(__BORLANDC__)
     97  1.1.1.2  christos typedef unsigned __int64 ZPOS64_T;
     98  1.1.1.2  christos #else
     99  1.1.1.2  christos typedef unsigned long long int ZPOS64_T;
    100  1.1.1.2  christos #endif
    101  1.1.1.2  christos #endif
    102  1.1.1.2  christos #endif
    103  1.1.1.2  christos 
    104  1.1.1.3  christos /* Maximum unsigned 32-bit value used as placeholder for zip64 */
    105  1.1.1.3  christos #ifndef MAXU32
    106  1.1.1.3  christos #define MAXU32 (0xffffffff)
    107  1.1.1.3  christos #endif
    108  1.1.1.2  christos 
    109  1.1.1.2  christos #ifdef __cplusplus
    110  1.1.1.2  christos extern "C" {
    111  1.1.1.2  christos #endif
    112      1.1  christos 
    113      1.1  christos 
    114      1.1  christos #define ZLIB_FILEFUNC_SEEK_CUR (1)
    115      1.1  christos #define ZLIB_FILEFUNC_SEEK_END (2)
    116      1.1  christos #define ZLIB_FILEFUNC_SEEK_SET (0)
    117      1.1  christos 
    118      1.1  christos #define ZLIB_FILEFUNC_MODE_READ      (1)
    119      1.1  christos #define ZLIB_FILEFUNC_MODE_WRITE     (2)
    120      1.1  christos #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
    121      1.1  christos 
    122      1.1  christos #define ZLIB_FILEFUNC_MODE_EXISTING (4)
    123      1.1  christos #define ZLIB_FILEFUNC_MODE_CREATE   (8)
    124      1.1  christos 
    125      1.1  christos 
    126      1.1  christos #ifndef ZCALLBACK
    127  1.1.1.2  christos  #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
    128  1.1.1.2  christos    #define ZCALLBACK CALLBACK
    129  1.1.1.2  christos  #else
    130  1.1.1.2  christos    #define ZCALLBACK
    131  1.1.1.2  christos  #endif
    132      1.1  christos #endif
    133      1.1  christos 
    134      1.1  christos 
    135      1.1  christos 
    136  1.1.1.2  christos 
    137  1.1.1.4  christos typedef voidpf   (ZCALLBACK *open_file_func)      (voidpf opaque, const char* filename, int mode);
    138  1.1.1.4  christos typedef uLong    (ZCALLBACK *read_file_func)      (voidpf opaque, voidpf stream, void* buf, uLong size);
    139  1.1.1.4  christos typedef uLong    (ZCALLBACK *write_file_func)     (voidpf opaque, voidpf stream, const void* buf, uLong size);
    140  1.1.1.4  christos typedef int      (ZCALLBACK *close_file_func)     (voidpf opaque, voidpf stream);
    141  1.1.1.4  christos typedef int      (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
    142  1.1.1.2  christos 
    143  1.1.1.4  christos typedef long     (ZCALLBACK *tell_file_func)      (voidpf opaque, voidpf stream);
    144  1.1.1.4  christos typedef long     (ZCALLBACK *seek_file_func)      (voidpf opaque, voidpf stream, uLong offset, int origin);
    145  1.1.1.2  christos 
    146  1.1.1.2  christos 
    147  1.1.1.4  christos /* here is the "old" 32 bits structure */
    148      1.1  christos typedef struct zlib_filefunc_def_s
    149      1.1  christos {
    150      1.1  christos     open_file_func      zopen_file;
    151      1.1  christos     read_file_func      zread_file;
    152      1.1  christos     write_file_func     zwrite_file;
    153      1.1  christos     tell_file_func      ztell_file;
    154      1.1  christos     seek_file_func      zseek_file;
    155      1.1  christos     close_file_func     zclose_file;
    156      1.1  christos     testerror_file_func zerror_file;
    157      1.1  christos     voidpf              opaque;
    158      1.1  christos } zlib_filefunc_def;
    159      1.1  christos 
    160  1.1.1.4  christos typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    (voidpf opaque, voidpf stream);
    161  1.1.1.4  christos typedef long     (ZCALLBACK *seek64_file_func)    (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
    162  1.1.1.4  christos typedef voidpf   (ZCALLBACK *open64_file_func)    (voidpf opaque, const void* filename, int mode);
    163      1.1  christos 
    164  1.1.1.2  christos typedef struct zlib_filefunc64_def_s
    165  1.1.1.2  christos {
    166  1.1.1.2  christos     open64_file_func    zopen64_file;
    167  1.1.1.2  christos     read_file_func      zread_file;
    168  1.1.1.2  christos     write_file_func     zwrite_file;
    169  1.1.1.2  christos     tell64_file_func    ztell64_file;
    170  1.1.1.2  christos     seek64_file_func    zseek64_file;
    171  1.1.1.2  christos     close_file_func     zclose_file;
    172  1.1.1.2  christos     testerror_file_func zerror_file;
    173  1.1.1.2  christos     voidpf              opaque;
    174  1.1.1.2  christos } zlib_filefunc64_def;
    175      1.1  christos 
    176  1.1.1.4  christos void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def);
    177  1.1.1.4  christos void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
    178      1.1  christos 
    179  1.1.1.2  christos /* now internal definition, only for zip.c and unzip.h */
    180  1.1.1.2  christos typedef struct zlib_filefunc64_32_def_s
    181  1.1.1.2  christos {
    182  1.1.1.2  christos     zlib_filefunc64_def zfile_func64;
    183  1.1.1.2  christos     open_file_func      zopen32_file;
    184  1.1.1.2  christos     tell_file_func      ztell32_file;
    185  1.1.1.2  christos     seek_file_func      zseek32_file;
    186  1.1.1.2  christos } zlib_filefunc64_32_def;
    187  1.1.1.2  christos 
    188  1.1.1.2  christos 
    189  1.1.1.2  christos #define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))
    190  1.1.1.2  christos #define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))
    191  1.1.1.2  christos //#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
    192  1.1.1.2  christos //#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
    193  1.1.1.2  christos #define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
    194  1.1.1.2  christos #define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
    195  1.1.1.2  christos 
    196  1.1.1.4  christos voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
    197  1.1.1.4  christos long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
    198  1.1.1.4  christos ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
    199  1.1.1.2  christos 
    200  1.1.1.4  christos void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
    201  1.1.1.2  christos 
    202  1.1.1.2  christos #define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))
    203  1.1.1.2  christos #define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))
    204  1.1.1.2  christos #define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
    205      1.1  christos 
    206      1.1  christos #ifdef __cplusplus
    207      1.1  christos }
    208      1.1  christos #endif
    209      1.1  christos 
    210      1.1  christos #endif
    211