ioapi.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* ioapi.h -- IO base function header for compress/uncompress .zip
  2. files using zlib + zip or unzip API
  3. Version 1.01e, February 12th, 2005
  4. Copyright (C) 1998-2005 Gilles Vollant
  5. Modified by Sergey A. Tachenov to integrate with Qt.
  6. */
  7. #ifndef _ZLIBIOAPI_H
  8. #define _ZLIBIOAPI_H
  9. #define ZLIB_FILEFUNC_SEEK_CUR (1)
  10. #define ZLIB_FILEFUNC_SEEK_END (2)
  11. #define ZLIB_FILEFUNC_SEEK_SET (0)
  12. #define ZLIB_FILEFUNC_MODE_READ (1)
  13. #define ZLIB_FILEFUNC_MODE_WRITE (2)
  14. #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
  15. #define ZLIB_FILEFUNC_MODE_EXISTING (4)
  16. #define ZLIB_FILEFUNC_MODE_CREATE (8)
  17. #ifndef ZCALLBACK
  18. #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
  19. #define ZCALLBACK CALLBACK
  20. #else
  21. #define ZCALLBACK
  22. #endif
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, voidpf file, int mode));
  28. typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
  29. typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
  30. typedef uLong (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
  31. typedef int (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
  32. typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
  33. typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
  34. typedef struct zlib_filefunc_def_s
  35. {
  36. open_file_func zopen_file;
  37. read_file_func zread_file;
  38. write_file_func zwrite_file;
  39. tell_file_func ztell_file;
  40. seek_file_func zseek_file;
  41. close_file_func zclose_file;
  42. testerror_file_func zerror_file;
  43. voidpf opaque;
  44. } zlib_filefunc_def;
  45. void fill_qiodevice_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
  46. #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
  47. #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
  48. #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
  49. #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
  50. #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
  51. #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif