zlib.pp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. unit zlib;
  2. interface
  3. { Needed for array of const }
  4. {$mode objfpc}
  5. {$PACKRECORDS 4}
  6. const
  7. SZLIB_VERSION = '1.1.3';
  8. type
  9. { Compatibility types }
  10. Uint = cardinal;
  11. Ulong = Cardinal;
  12. Ulongf = Cardinal;
  13. Pulongf = ^Ulongf;
  14. z_off_t = longint;
  15. TAllocfunc = function (opaque:pointer; items:uInt; size:uInt):pointer;cdecl;
  16. TFreeFunc = procedure (opaque:pointer; address:pointer);cdecl;
  17. TInternalState = record
  18. end;
  19. PInternalState = ^TInternalstate;
  20. TZStream = record
  21. next_in : pchar;
  22. avail_in : uInt;
  23. total_in : uLong;
  24. next_out : pchar;
  25. avail_out : uInt;
  26. total_out : uLong;
  27. msg : pchar;
  28. state : PInternalState;
  29. zalloc : TAllocFunc;
  30. zfree : TFreeFunc;
  31. opaque : pointer;
  32. data_type : longint;
  33. adler : uLong;
  34. reserved : uLong;
  35. end;
  36. PZstream = ^TZStream;
  37. gzFile = pointer;
  38. const
  39. Z_NO_FLUSH = 0;
  40. Z_PARTIAL_FLUSH = 1;
  41. Z_SYNC_FLUSH = 2;
  42. Z_FULL_FLUSH = 3;
  43. Z_FINISH = 4;
  44. Z_OK = 0;
  45. Z_STREAM_END = 1;
  46. Z_NEED_DICT = 2;
  47. Z_ERRNO = -(1);
  48. Z_STREAM_ERROR = -(2);
  49. Z_DATA_ERROR = -(3);
  50. Z_MEM_ERROR = -(4);
  51. Z_BUF_ERROR = -(5);
  52. Z_VERSION_ERROR = -(6);
  53. Z_NO_COMPRESSION = 0;
  54. Z_BEST_SPEED = 1;
  55. Z_BEST_COMPRESSION = 9;
  56. Z_DEFAULT_COMPRESSION = -(1);
  57. Z_FILTERED = 1;
  58. Z_HUFFMAN_ONLY = 2;
  59. Z_DEFAULT_STRATEGY = 0;
  60. Z_BINARY = 0;
  61. Z_ASCII = 1;
  62. Z_UNKNOWN = 2;
  63. Z_DEFLATED = 8;
  64. Z_NULL = 0;
  65. function zlibVersion:pchar;cdecl;
  66. function deflate(var strm:TZstream; flush:longint):longint;cdecl;
  67. function deflateEnd(var strm:TZstream):longint;cdecl;
  68. function inflate(var strm:TZstream; flush:longint):longint;cdecl;
  69. function inflateEnd(var strm:TZstream):longint;cdecl;
  70. function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;cdecl;
  71. function deflateCopy(var dest,source:TZstream):longint;cdecl;
  72. function deflateReset(var strm:TZstream):longint;cdecl;
  73. function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;cdecl;
  74. function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;cdecl;
  75. function inflateSync(var strm:TZStream):longint;cdecl;
  76. function inflateReset(var strm:TZStream):longint;cdecl;
  77. function compress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;cdecl;
  78. function compress2(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;cdecl;
  79. function uncompress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;cdecl;
  80. function gzopen(path:pchar; mode:pchar):gzFile;cdecl;
  81. function gzdopen(fd:longint; mode:pchar):gzFile;cdecl;
  82. function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;cdecl;
  83. function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;cdecl;
  84. function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;cdecl;
  85. function gzprintf(thefile:gzFile; format:pchar; args:array of const):longint;cdecl;
  86. function gzputs(thefile:gzFile; s:pchar):longint;cdecl;
  87. function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;cdecl;
  88. function gzputc(thefile:gzFile; c:longint):longint;cdecl;
  89. function gzgetc(thefile:gzFile):longint;cdecl;
  90. function gzflush(thefile:gzFile; flush:longint):longint;cdecl;
  91. function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;cdecl;
  92. function gzrewind(thefile:gzFile):longint;cdecl;
  93. function gztell(thefile:gzFile):z_off_t;cdecl;
  94. function gzeof(thefile:gzFile):longint;cdecl;
  95. function gzclose(thefile:gzFile):longint;cdecl;
  96. function gzerror(thefile:gzFile; var errnum:longint):pchar;cdecl;
  97. function adler32(adler:uLong;buf : pchar; len:uInt):uLong;cdecl;
  98. function crc32(crc:uLong;buf : pchar; len:uInt):uLong;cdecl;
  99. function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;cdecl;
  100. function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;cdecl;
  101. function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;
  102. strategy:longint; version:pchar; stream_size:longint):longint;cdecl;
  103. function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;cdecl;
  104. function deflateInit(var strm:TZStream;level : longint) : longint;
  105. function inflateInit(var strm:TZStream) : longint;
  106. function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
  107. function inflateInit2(var strm:TZStream; windowBits : longint) : longint;
  108. function zError(err:longint):pchar;cdecl;
  109. function inflateSyncPoint(z:PZstream):longint;cdecl;
  110. function get_crc_table:puLongf;cdecl;
  111. implementation
  112. {$ifndef win32}
  113. const External_library='z';
  114. {$else}
  115. const External_library='z';
  116. {$endif}
  117. function zlibVersion:pchar;cdecl;external External_library name 'zlibVersion';
  118. function deflate(var strm:TZStream; flush:longint):longint;cdecl;external External_library name 'deflate';
  119. function deflateEnd(var strm:TZStream):longint;cdecl;external External_library name 'deflateEnd';
  120. function inflate(var strm:TZStream; flush:longint):longint;cdecl;external External_library name 'inflate';
  121. function inflateEnd(var strm:TZStream):longint;cdecl;external External_library name 'inflateEnd';
  122. function deflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;cdecl;external External_library name 'deflateSetDictionary';
  123. function deflateCopy(var dest,source:TZstream):longint;cdecl;external External_library name 'deflateCopy';
  124. function deflateReset(var strm:TZStream):longint;cdecl;external External_library name 'deflateReset';
  125. function deflateParams(var strm:TZStream; level:longint; strategy:longint):longint;cdecl;external External_library name 'deflateParams';
  126. function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;cdecl;external External_library name 'inflateSetDictionary';
  127. function inflateSync(var strm:TZStream):longint;cdecl;external External_library name 'inflateSync';
  128. function inflateReset(var strm:TZStream):longint;cdecl;external External_library name 'inflateReset';
  129. function compress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;cdecl;external External_library name 'compress';
  130. function compress2(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;cdecl;external External_library name 'compress2';
  131. function uncompress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;cdecl;external External_library name 'uncompress';
  132. function gzopen(path:pchar; mode:pchar):gzFile;cdecl;external External_library name 'gzopen';
  133. function gzdopen(fd:longint; mode:pchar):gzFile;cdecl;external External_library name 'gzdopen';
  134. function gzsetparams(thefile:gzFile; level:longint; strategy:longint):longint;cdecl;external External_library name 'gzsetparams';
  135. function gzread(thefile:gzFile; buf:pointer; len:cardinal):longint;cdecl;external External_library name 'gzread';
  136. function gzwrite(thefile:gzFile; buf:pointer; len:cardinal):longint;cdecl;external External_library name 'gzwrite';
  137. function gzprintf(thefile:gzFile; format:pchar; args:array of const):longint;cdecl;external External_library name 'gzprintf';
  138. function gzputs(thefile:gzFile; s:pchar):longint;cdecl;external External_library name 'gzputs';
  139. function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;cdecl;external External_library name 'gzgets';
  140. function gzputc(thefile:gzFile; c:longint):longint;cdecl;external External_library name 'gzputc';
  141. function gzgetc(thefile:gzFile):longint;cdecl;external External_library name 'gzgetc';
  142. function gzflush(thefile:gzFile; flush:longint):longint;cdecl;external External_library name 'gzflush';
  143. function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;cdecl;external External_library name 'gzseek';
  144. function gzrewind(thefile:gzFile):longint;cdecl;external External_library name 'gzrewind';
  145. function gztell(thefile:gzFile):z_off_t;cdecl;external External_library name 'gztell';
  146. function gzeof(thefile:gzFile):longint;cdecl;external External_library name 'gzeof';
  147. function gzclose(thefile:gzFile):longint;cdecl;external External_library name 'gzclose';
  148. function gzerror(thefile:gzFile; var errnum:longint):pchar;cdecl;external External_library name 'gzerror';
  149. function adler32(adler:uLong;buf : pchar; len:uInt):uLong;cdecl;external External_library name 'adler32';
  150. function crc32(crc:uLong;buf : pchar; len:uInt):uLong;cdecl;external External_library name 'crc32';
  151. function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;cdecl;external External_library name 'deflateInit_';
  152. function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;cdecl;external External_library name 'inflateInit_';
  153. function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;
  154. strategy:longint; version:pchar; stream_size:longint):longint;cdecl;external External_library name 'deflateInit2_';
  155. function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;cdecl;external External_library name 'inflateInit2_';
  156. function zError(err:longint):pchar;cdecl;external External_library name 'zError';
  157. function inflateSyncPoint(z:PZstream):longint;cdecl;external External_library name 'inflateSyncPoint';
  158. function get_crc_table:puLongf;cdecl;external External_library name 'get_crc_table';
  159. function zlib_version : pchar;
  160. begin
  161. zlib_version:=zlibVersion;
  162. end;
  163. function deflateInit(var strm:TZStream;level : longint) : longint;
  164. begin
  165. deflateInit:=deflateInit_(strm,level,ZLIB_VERSION,sizeof(TZStream));
  166. end;
  167. function inflateInit(var strm:TZStream) : longint;
  168. begin
  169. inflateInit:=inflateInit_(strm,ZLIB_VERSION,sizeof(TZStream));
  170. end;
  171. function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
  172. begin
  173. deflateInit2:=deflateInit2_(strm,level,method,windowBits,memLevel,strategy,ZLIB_VERSION,sizeof(TZStream));
  174. end;
  175. function inflateInit2(var strm:TZStream;windowBits : longint) : longint;
  176. begin
  177. inflateInit2:=inflateInit2_(strm,windowBits,ZLIB_VERSION,sizeof(TZStream));
  178. end;
  179. end.