You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.3 KiB

  1. unit zlibdef;
  2. interface
  3. uses
  4. Windows;
  5. const
  6. ZLIB_VERSION = '1.1.3';
  7. type
  8. voidpf = Pointer;
  9. int = Integer;
  10. uInt = Cardinal;
  11. pBytef = PChar;
  12. uLong = Cardinal;
  13. alloc_func = function(opaque: voidpf; items, size: uInt): voidpf;
  14. stdcall;
  15. free_func = procedure(opaque, address: voidpf);
  16. stdcall;
  17. internal_state = Pointer;
  18. z_streamp = ^z_stream;
  19. z_stream = packed record
  20. next_in: pBytef; // next input byte
  21. avail_in: uInt; // number of bytes available at next_in
  22. total_in: uLong; // total nb of input bytes read so far
  23. next_out: pBytef; // next output byte should be put there
  24. avail_out: uInt; // remaining free space at next_out
  25. total_out: uLong; // total nb of bytes output so far
  26. msg: PChar; // last error message, NULL if no error
  27. state: internal_state; // not visible by applications
  28. zalloc: alloc_func; // used to allocate the internal state
  29. zfree: free_func; // used to free the internal state
  30. opaque: voidpf; // private data object passed to zalloc and zfree
  31. data_type: int; // best guess about the data type: ascii or binary
  32. adler: uLong; // adler32 value of the uncompressed data
  33. reserved: uLong; // reserved for future use
  34. end;
  35. const
  36. Z_NO_FLUSH = 0;
  37. Z_SYNC_FLUSH = 2;
  38. Z_FULL_FLUSH = 3;
  39. Z_FINISH = 4;
  40. Z_OK = 0;
  41. Z_STREAM_END = 1;
  42. Z_NO_COMPRESSION = 0;
  43. Z_BEST_SPEED = 1;
  44. Z_BEST_COMPRESSION = 9;
  45. Z_DEFAULT_COMPRESSION = -1;
  46. Z_FILTERED = 1;
  47. Z_HUFFMAN_ONLY = 2;
  48. Z_DEFAULT_STRATEGY = 0;
  49. Z_BINARY = 0;
  50. Z_ASCII = 1;
  51. Z_UNKNOWN = 2;
  52. Z_DEFLATED = 8;
  53. MAX_MEM_LEVEL = 9;
  54. function adler32(adler: uLong; const buf: pBytef; len: uInt): uLong;
  55. stdcall;
  56. function crc32(crc: uLong; const buf: pBytef; len: uInt): uLong;
  57. stdcall;
  58. function deflate(strm: z_streamp; flush: int): int;
  59. stdcall;
  60. function deflateCopy(dest, source: z_streamp): int;
  61. stdcall;
  62. function deflateEnd(strm: z_streamp): int;
  63. stdcall;
  64. function deflateInit2_(strm: z_streamp; level, method,
  65. windowBits, memLevel, strategy: int;
  66. const version: PChar; stream_size: int): int;
  67. stdcall;
  68. function deflateInit_(strm: z_streamp; level: int;
  69. const version: PChar; stream_size: int): int;
  70. stdcall;
  71. function deflateParams(strm: z_streamp; level, strategy: int): int;
  72. stdcall;
  73. function deflateReset(strm: z_streamp): int;
  74. stdcall;
  75. function deflateSetDictionary(strm: z_streamp;
  76. const dictionary: pBytef;
  77. dictLength: uInt): int;
  78. stdcall;
  79. function inflate(strm: z_streamp; flush: int): int;
  80. stdcall;
  81. function inflateEnd(strm: z_streamp): int;
  82. stdcall;
  83. function inflateInit2_(strm: z_streamp; windowBits: int;
  84. const version: PChar; stream_size: int): int;
  85. stdcall;
  86. function inflateInit_(strm: z_streamp; const version: PChar;
  87. stream_size: int): int;
  88. stdcall;
  89. function inflateReset(strm: z_streamp): int;
  90. stdcall;
  91. function inflateSetDictionary(strm: z_streamp;
  92. const dictionary: pBytef;
  93. dictLength: uInt): int;
  94. stdcall;
  95. function inflateSync(strm: z_streamp): int;
  96. stdcall;
  97. function deflateInit(strm: z_streamp; level: int): int;
  98. function deflateInit2(strm: z_streamp; level, method, windowBits,
  99. memLevel, strategy: int): int;
  100. function inflateInit(strm: z_streamp): int;
  101. function inflateInit2(strm: z_streamp; windowBits: int): int;
  102. implementation
  103. function deflateInit(strm: z_streamp; level: int): int;
  104. begin
  105. Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
  106. end;
  107. function deflateInit2(strm: z_streamp; level, method, windowBits,
  108. memLevel, strategy: int): int;
  109. begin
  110. Result := deflateInit2_(strm, level, method, windowBits, memLevel,
  111. strategy, ZLIB_VERSION, sizeof(z_stream));
  112. end;
  113. function inflateInit(strm: z_streamp): int;
  114. begin
  115. Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
  116. end;
  117. function inflateInit2(strm: z_streamp; windowBits: int): int;
  118. begin
  119. Result := inflateInit2_(strm, windowBits, ZLIB_VERSION,
  120. sizeof(z_stream));
  121. end;
  122. const
  123. zlibDLL = 'png32bd.dll';
  124. function adler32; external zlibDLL;
  125. function crc32; external zlibDLL;
  126. function deflate; external zlibDLL;
  127. function deflateCopy; external zlibDLL;
  128. function deflateEnd; external zlibDLL;
  129. function deflateInit2_; external zlibDLL;
  130. function deflateInit_; external zlibDLL;
  131. function deflateParams; external zlibDLL;
  132. function deflateReset; external zlibDLL;
  133. function deflateSetDictionary; external zlibDLL;
  134. function inflate; external zlibDLL;
  135. function inflateEnd; external zlibDLL;
  136. function inflateInit2_; external zlibDLL;
  137. function inflateInit_; external zlibDLL;
  138. function inflateReset; external zlibDLL;
  139. function inflateSetDictionary; external zlibDLL;
  140. function inflateSync; external zlibDLL;
  141. end.