cpl_minizip_ioapi.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Modified version by Even Rouault. :
  2. - change fill_fopen_filefunc to cpl_fill_fopen_filefunc
  3. - Add support for ZIP64
  4. * Copyright (c) 2008-2012, Even Rouault <even dot rouault at mines-paris dot org>
  5. Original licence available in port/LICENCE_minizip
  6. */
  7. /* ioapi.h -- IO base function header for compress/uncompress .zip
  8. files using zlib + zip or unzip API
  9. Version 1.01e, February 12th, 2005
  10. Copyright (C) 1998-2005 Gilles Vollant
  11. */
  12. #ifndef CPL_MINIZIP_IOAPI_H_INCLUDED
  13. #define CPL_MINIZIP_IOAPI_H_INCLUDED
  14. #include "cpl_vsi.h"
  15. #define uLong64 vsi_l_offset
  16. /* Gentoo removed OF from their copy of zconf.h (https://bugs.gentoo.org/show_bug.cgi?id=383179) */
  17. /* but our copy of minizip needs it. */
  18. #ifndef OF
  19. #define OF(args) args
  20. #endif
  21. #define ZLIB_FILEFUNC_SEEK_CUR (1)
  22. #define ZLIB_FILEFUNC_SEEK_END (2)
  23. #define ZLIB_FILEFUNC_SEEK_SET (0)
  24. #define ZLIB_FILEFUNC_MODE_READ (1)
  25. #define ZLIB_FILEFUNC_MODE_WRITE (2)
  26. #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
  27. #define ZLIB_FILEFUNC_MODE_EXISTING (4)
  28. #define ZLIB_FILEFUNC_MODE_CREATE (8)
  29. #ifndef ZCALLBACK
  30. #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
  31. #define ZCALLBACK CALLBACK
  32. #else
  33. #define ZCALLBACK
  34. #endif
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
  40. typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
  41. typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
  42. typedef uLong64 (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
  43. typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong64 offset, int origin));
  44. typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
  45. typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
  46. typedef struct zlib_filefunc_def_s
  47. {
  48. open_file_func zopen_file;
  49. read_file_func zread_file;
  50. write_file_func zwrite_file;
  51. tell_file_func ztell_file;
  52. seek_file_func zseek_file;
  53. close_file_func zclose_file;
  54. testerror_file_func zerror_file;
  55. voidpf opaque;
  56. } zlib_filefunc_def;
  57. void cpl_fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
  58. #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
  59. #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
  60. #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
  61. #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
  62. #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
  63. #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif /* CPL_MINIZIP_IOAPI_H_INCLUDED */