zlib.pp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. {
  2. $Id$
  3. }
  4. unit zlib;
  5. interface
  6. { Needed for array of const }
  7. {$mode objfpc}
  8. { for linux for linking with libc }
  9. {$ifdef unix}
  10. {$linklib c}
  11. {$endif}
  12. {$PACKRECORDS 4}
  13. const
  14. ZLIB_VERSION = '1.1.3';
  15. {$ifdef netware} {zlib.nlm comes with netware6}
  16. libz='zlib';
  17. {$else}
  18. libz='z';
  19. {$endif}
  20. type
  21. { Compatible with paszlib }
  22. Uint = Longint;
  23. Ulong = Longint;
  24. Ulongf = Longint;
  25. Pulongf = ^Ulongf;
  26. z_off_t = longint;
  27. pbyte = ^byte;
  28. pbytef = ^byte;
  29. TAllocfunc = function (opaque:pointer; items:uInt; size:uInt):pointer;cdecl;
  30. TFreeFunc = procedure (opaque:pointer; address:pointer);cdecl;
  31. TInternalState = record
  32. end;
  33. PInternalState = ^TInternalstate;
  34. TZStream = record
  35. next_in : pbytef;
  36. avail_in : uInt;
  37. total_in : uLong;
  38. next_out : pbytef;
  39. avail_out : uInt;
  40. total_out : uLong;
  41. msg : pbytef;
  42. state : PInternalState;
  43. zalloc : TAllocFunc;
  44. zfree : TFreeFunc;
  45. opaque : pointer;
  46. data_type : longint;
  47. adler : uLong;
  48. reserved : uLong;
  49. end;
  50. PZstream = ^TZStream;
  51. gzFile = pointer;
  52. const
  53. Z_NO_FLUSH = 0;
  54. Z_PARTIAL_FLUSH = 1;
  55. Z_SYNC_FLUSH = 2;
  56. Z_FULL_FLUSH = 3;
  57. Z_FINISH = 4;
  58. Z_OK = 0;
  59. Z_STREAM_END = 1;
  60. Z_NEED_DICT = 2;
  61. Z_ERRNO = -(1);
  62. Z_STREAM_ERROR = -(2);
  63. Z_DATA_ERROR = -(3);
  64. Z_MEM_ERROR = -(4);
  65. Z_BUF_ERROR = -(5);
  66. Z_VERSION_ERROR = -(6);
  67. Z_NO_COMPRESSION = 0;
  68. Z_BEST_SPEED = 1;
  69. Z_BEST_COMPRESSION = 9;
  70. Z_DEFAULT_COMPRESSION = -(1);
  71. Z_FILTERED = 1;
  72. Z_HUFFMAN_ONLY = 2;
  73. Z_DEFAULT_STRATEGY = 0;
  74. Z_BINARY = 0;
  75. Z_ASCII = 1;
  76. Z_UNKNOWN = 2;
  77. Z_DEFLATED = 8;
  78. Z_NULL = 0;
  79. function zlibVersionpchar:pchar;cdecl;external libz name 'zlibVersion';
  80. function zlibVersion:string;
  81. function deflate(var strm:TZStream; flush:longint):longint;cdecl;external libz name 'deflate';
  82. function deflateEnd(var strm:TZStream):longint;cdecl;external libz name 'deflateEnd';
  83. function inflate(var strm:TZStream; flush:longint):longint;cdecl;external libz name 'inflate';
  84. function inflateEnd(var strm:TZStream):longint;cdecl;external libz name 'inflateEnd';
  85. function deflateSetDictionary(var strm:TZStream;dictionary : pbytef; dictLength:uInt):longint;cdecl;external libz name 'deflateSetDictionary';
  86. function deflateCopy(var dest,source:TZstream):longint;cdecl;external libz name 'deflateCopy';
  87. function deflateReset(var strm:TZStream):longint;cdecl;external libz name 'deflateReset';
  88. function deflateParams(var strm:TZStream; level:longint; strategy:longint):longint;cdecl;external libz name 'deflateParams';
  89. function inflateSetDictionary(var strm:TZStream;dictionary : pbytef; dictLength:uInt):longint;cdecl;external libz name 'inflateSetDictionary';
  90. function inflateSync(var strm:TZStream):longint;cdecl;external libz name 'inflateSync';
  91. function inflateReset(var strm:TZStream):longint;cdecl;external libz name 'inflateReset';
  92. function compress(dest:pbytef;destLen:uLongf; source : pbytef; sourceLen:uLong):longint;cdecl;external libz name 'compress';
  93. function compress2(dest:pbytef;destLen:uLongf; source : pbytef; sourceLen:uLong; level:longint):longint;cdecl;external libz name 'compress2';
  94. function uncompress(dest:pbytef;destLen:uLongf; source : pbytef; sourceLen:uLong):longint;cdecl;external libz name 'uncompress';
  95. function gzopen(path:pchar; mode:pchar):gzFile;cdecl;external libz name 'gzopen';
  96. function gzdopen(fd:longint; mode:pchar):gzFile;cdecl;external libz name 'gzdopen';
  97. function gzsetparams(thefile:gzFile; level:longint; strategy:longint):longint;cdecl;external libz name 'gzsetparams';
  98. function gzread(thefile:gzFile; buf:pointer; len:cardinal):longint;cdecl;external libz name 'gzread';
  99. function gzwrite(thefile:gzFile; buf:pointer; len:cardinal):longint;cdecl;external libz name 'gzwrite';
  100. function gzprintf(thefile:gzFile; format:pbytef; args:array of const):longint;cdecl;external libz name 'gzprintf';
  101. function gzputs(thefile:gzFile; s:pbytef):longint;cdecl;external libz name 'gzputs';
  102. function gzgets(thefile:gzFile; buf:pbytef; len:longint):pbytef;cdecl;external libz name 'gzgets';
  103. function gzputc(thefile:gzFile; c:char):char;cdecl;external libz name 'gzputc';
  104. function gzgetc(thefile:gzFile):char;cdecl;external libz name 'gzgetc';
  105. function gzflush(thefile:gzFile; flush:longint):longint;cdecl;external libz name 'gzflush';
  106. function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;cdecl;external libz name 'gzseek';
  107. function gzrewind(thefile:gzFile):longint;cdecl;external libz name 'gzrewind';
  108. function gztell(thefile:gzFile):z_off_t;cdecl;external libz name 'gztell';
  109. function gzeof(thefile:gzFile):longbool;cdecl;external libz name 'gzeof';
  110. function gzclose(thefile:gzFile):longint;cdecl;external libz name 'gzclose';
  111. function gzerror(thefile:gzFile; var errnum:longint):pbytef;cdecl;external libz name 'gzerror';
  112. function adler32(adler:uLong;buf : pbytef; len:uInt):uLong;cdecl;external libz name 'adler32';
  113. function crc32(crc:uLong;buf : pbytef; len:uInt):uLong;cdecl;external libz name 'crc32';
  114. function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;cdecl;external libz name 'deflateInit_';
  115. function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;cdecl;external libz name 'inflateInit_';
  116. function deflateInit(var strm:TZStream;level : longint) : longint;
  117. function inflateInit(var strm:TZStream) : longint;
  118. function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;cdecl;external libz name 'deflateInit2_';
  119. function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;cdecl;external libz name 'inflateInit2_';
  120. function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
  121. function inflateInit2(var strm:TZStream;windowBits : longint) : longint;
  122. function zErrorpchar(err:longint):pchar;cdecl;external libz name 'zError';
  123. function zError(err:longint):string;
  124. function inflateSyncPoint(z:PZstream):longint;cdecl;external libz name 'inflateSyncPoint';
  125. function get_crc_table:pointer;cdecl;external libz name 'get_crc_table';
  126. implementation
  127. uses
  128. strings;
  129. function zlibversion : string;
  130. begin
  131. zlibversion:=strpas(zlibversionpchar);
  132. end;
  133. function deflateInit(var strm:TZStream;level : longint) : longint;
  134. begin
  135. deflateInit:=deflateInit_(strm,level,ZLIB_VERSION,sizeof(TZStream));
  136. end;
  137. function inflateInit(var strm:TZStream) : longint;
  138. begin
  139. inflateInit:=inflateInit_(strm,ZLIB_VERSION,sizeof(TZStream));
  140. end;
  141. function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
  142. begin
  143. deflateInit2:=deflateInit2_(strm,level,method,windowBits,memLevel,strategy,ZLIB_VERSION,sizeof(TZStream));
  144. end;
  145. function inflateInit2(var strm:TZStream;windowBits : longint) : longint;
  146. begin
  147. inflateInit2:=inflateInit2_(strm,windowBits,ZLIB_VERSION,sizeof(TZStream));
  148. end;
  149. function zError(err:longint):string;
  150. begin
  151. zerror:=Strpas(zErrorpchar(err));
  152. end;
  153. end.
  154. {
  155. $Log$
  156. Revision 1.4 2003-03-17 15:59:10 armin
  157. + zlib libname for netware
  158. Revision 1.3 2002/09/07 15:43:06 peter
  159. * old logs removed and tabs fixed
  160. Revision 1.2 2002/05/31 11:54:33 marco
  161. * Renamefest for 1.0, many 1.1.x spots patched also.
  162. Revision 1.1 2002/01/29 17:55:23 peter
  163. * splitted to base and extra
  164. }