ioapi.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. */
  6. #ifndef _ZLIBIOAPI_H
  7. #define _ZLIBIOAPI_H
  8. #define ZLIB_FILEFUNC_SEEK_CUR (1)
  9. #define ZLIB_FILEFUNC_SEEK_END (2)
  10. #define ZLIB_FILEFUNC_SEEK_SET (0)
  11. #define ZLIB_FILEFUNC_MODE_READ (1)
  12. #define ZLIB_FILEFUNC_MODE_WRITE (2)
  13. #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
  14. #define ZLIB_FILEFUNC_MODE_EXISTING (4)
  15. #define ZLIB_FILEFUNC_MODE_CREATE (8)
  16. #ifndef ZCALLBACK
  17. #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
  18. #define ZCALLBACK CALLBACK
  19. #else
  20. #define ZCALLBACK
  21. #endif
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
  27. typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
  28. typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
  29. typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
  30. typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
  31. typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
  32. typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
  33. typedef struct zlib_filefunc_def_s
  34. {
  35. open_file_func zopen_file;
  36. read_file_func zread_file;
  37. write_file_func zwrite_file;
  38. tell_file_func ztell_file;
  39. seek_file_func zseek_file;
  40. close_file_func zclose_file;
  41. testerror_file_func zerror_file;
  42. voidpf opaque;
  43. } zlib_filefunc_def;
  44. void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def);
  45. #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
  46. #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
  47. #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
  48. #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
  49. #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
  50. #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif