paszlib.pas 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. unit paszlib;
  2. interface
  3. uses
  4. zbase;
  5. const
  6. ZLIB_VERSION = '1.1.2';
  7. type
  8. { Compatibility types }
  9. PByte = ^Byte;
  10. Uint = Cardinal;
  11. Ulong = Cardinal;
  12. Ulongf = ULong;
  13. Pulongf = ^Ulongf;
  14. z_off_t = longint;
  15. TAllocfunc = function (opaque:pointer; items:uInt; size:uInt):pointer;
  16. TFreeFunc = procedure (opaque:pointer; address:pointer);
  17. TInternalState = record
  18. end;
  19. PInternalState = ^TInternalstate;
  20. TZStream = z_stream;
  21. PZstream = ^TZStream;
  22. gzFile = pointer;
  23. const
  24. Z_NO_FLUSH = 0;
  25. Z_PARTIAL_FLUSH = 1;
  26. Z_SYNC_FLUSH = 2;
  27. Z_FULL_FLUSH = 3;
  28. Z_FINISH = 4;
  29. Z_OK = 0;
  30. Z_STREAM_END = 1;
  31. Z_NEED_DICT = 2;
  32. Z_ERRNO = -(1);
  33. Z_STREAM_ERROR = -(2);
  34. Z_DATA_ERROR = -(3);
  35. Z_MEM_ERROR = -(4);
  36. Z_BUF_ERROR = -(5);
  37. Z_VERSION_ERROR = -(6);
  38. Z_NO_COMPRESSION = 0;
  39. Z_BEST_SPEED = 1;
  40. Z_BEST_COMPRESSION = 9;
  41. Z_DEFAULT_COMPRESSION = -(1);
  42. Z_FILTERED = 1;
  43. Z_HUFFMAN_ONLY = 2;
  44. Z_DEFAULT_STRATEGY = 0;
  45. Z_BINARY = 0;
  46. Z_ASCII = 1;
  47. Z_UNKNOWN = 2;
  48. Z_DEFLATED = 8;
  49. Z_NULL = 0;
  50. function zlibVersion:string;
  51. function deflate(var strm:TZstream; flush:longint):longint;
  52. function deflateEnd(var strm:TZstream):longint;
  53. function inflate(var strm:TZstream; flush:longint):longint;
  54. function inflateEnd(var strm:TZstream):longint;
  55. function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
  56. function deflateCopy(var dest,source:TZstream):longint;
  57. function deflateReset(var strm:TZstream):longint;
  58. function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
  59. function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
  60. function inflateSync(var strm:TZStream):longint;
  61. function inflateReset(var strm:TZStream):longint;
  62. function compress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
  63. function compress2(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
  64. function uncompress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
  65. function gzopen(path:pchar; mode:pchar):gzFile;
  66. function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
  67. function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
  68. function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
  69. function gzputs(thefile:gzFile; s:pchar):longint;
  70. function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
  71. function gzputc(thefile:gzFile; c:char):longint;
  72. function gzgetc(thefile:gzFile):char;
  73. function gzflush(thefile:gzFile; flush:longint):longint;
  74. function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;
  75. function gzrewind(thefile:gzFile):longint;
  76. function gztell(thefile:gzFile):z_off_t;
  77. function gzeof(thefile:gzFile):longbool;
  78. function gzclose(thefile:gzFile):longint;
  79. function gzerror(thefile:gzFile; var errnum:longint):string;
  80. function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
  81. function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
  82. function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
  83. function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
  84. function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
  85. function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;
  86. function deflateInit(var strm:TZStream;level : longint) : longint;
  87. function inflateInit(var strm:TZStream) : longint;
  88. function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
  89. function inflateInit2(var strm:TZStream; windowBits : longint) : longint;
  90. function zError(err:longint):string;
  91. function inflateSyncPoint(z:PZstream):longint;
  92. function get_crc_table:pointer;
  93. implementation
  94. uses
  95. zutil,zdeflate,zinflate,zcompres,zuncompr,gzio,adler,gzcrc;
  96. function zlibVersion:string;
  97. begin
  98. zlibversion:=zbase.zlibversion;
  99. end;
  100. function deflate(var strm:TZstream; flush:longint):longint;
  101. begin
  102. deflate:=zdeflate.deflate(strm,flush);
  103. end;
  104. function deflateEnd(var strm:TZstream):longint;
  105. begin
  106. deflateEnd:=zdeflate.deflateEnd(strm);
  107. end;
  108. function inflate(var strm:TZstream; flush:longint):longint;
  109. begin
  110. inflate:=zinflate.inflate(strm,flush);
  111. end;
  112. function inflateEnd(var strm:TZstream):longint;
  113. begin
  114. inflateEnd:=zinflate.inflateEnd(strm);
  115. end;
  116. function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
  117. begin
  118. deflateSetDictionary:=zdeflate.deflateSetDictionary(strm,pbytef(dictionary),dictlength);
  119. end;
  120. function deflateCopy(var dest,source:TZstream):longint;
  121. begin
  122. deflateCopy:=zdeflate.deflateCopy(@dest,@source);
  123. end;
  124. function deflateReset(var strm:TZstream):longint;
  125. begin
  126. deflateReset:=zdeflate.deflateReset(strm);
  127. end;
  128. function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
  129. begin
  130. deflateParams:=zdeflate.deflateParams(strm,level,strategy);
  131. end;
  132. function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
  133. begin
  134. inflateSetDictionary:=zinflate.inflateSetDictionary(strm,pbytef(dictionary),dictlength);
  135. end;
  136. function inflateSync(var strm:TZStream):longint;
  137. begin
  138. inflateSync:=zinflate.inflateSync(strm);
  139. end;
  140. function inflateReset(var strm:TZStream):longint;
  141. begin
  142. inflateReset:=zinflate.inflateReset(strm);
  143. end;
  144. function compress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
  145. begin
  146. compress:=zcompres.compress(pbytef(dest),destlen,pbytef(source),sourcelen);
  147. end;
  148. function compress2(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
  149. begin
  150. compress2:=zcompres.compress2(pbytef(dest),destlen,pbytef(source),sourcelen,level);
  151. end;
  152. function uncompress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
  153. begin
  154. uncompress:=zuncompr.uncompress(pbytef(dest),destlen,pbytef(source),sourcelen);
  155. end;
  156. function gzopen(path:pchar; mode:pchar):gzFile;
  157. begin
  158. gzopen:=gzio.gzopen(path,mode);
  159. end;
  160. function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
  161. begin
  162. gzsetparams:=gzio.gzsetparams(thefile,level,strategy);
  163. end;
  164. function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
  165. begin
  166. gzread:=gzio.gzread(thefile,buf,len);
  167. end;
  168. function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
  169. begin
  170. gzwrite:=gzio.gzwrite(thefile,buf,len);
  171. end;
  172. function gzputs(thefile:gzFile; s:pchar):longint;
  173. begin
  174. gzputs:=gzio.gzputs(thefile,s);
  175. end;
  176. function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
  177. begin
  178. gzgets:=gzio.gzgets(thefile,buf,len);
  179. end;
  180. function gzputc(thefile:gzFile; c:char):longint;
  181. begin
  182. gzputc:=gzio.gzputc(thefile,c);
  183. end;
  184. function gzgetc(thefile:gzFile):char;
  185. begin
  186. gzgetc:=chr(gzio.gzgetc(thefile));
  187. end;
  188. function gzflush(thefile:gzFile; flush:longint):longint;
  189. begin
  190. gzflush:=gzio.gzflush(thefile,flush);
  191. end;
  192. function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;
  193. begin
  194. gzseek:=gzio.gzseek(thefile,offset,whence);
  195. end;
  196. function gzrewind(thefile:gzFile):longint;
  197. begin
  198. gzrewind:=gzio.gzrewind(thefile);
  199. end;
  200. function gztell(thefile:gzFile):z_off_t;
  201. begin
  202. gztell:=gzio.gztell(thefile);
  203. end;
  204. function gzeof(thefile:gzFile):longbool;
  205. begin
  206. gzeof:=gzio.gzeof(thefile);
  207. end;
  208. function gzclose(thefile:gzFile):longint;
  209. begin
  210. gzclose:=gzio.gzclose(thefile);
  211. end;
  212. function gzerror(thefile:gzFile; var errnum:longint):string;
  213. begin
  214. gzerror:=gzio.gzerror(thefile,errnum);
  215. end;
  216. function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
  217. begin
  218. adler32:=adler.adler32(theadler,pbytef(buf),len);
  219. end;
  220. function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
  221. begin
  222. crc32:=gzcrc.crc32(thecrc,pbytef(buf),len);
  223. end;
  224. function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
  225. begin
  226. deflateInit_:=zdeflate.deflateInit_(@strm,level,version,stream_size);
  227. end;
  228. function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
  229. begin
  230. inflateInit_:=zinflate.inflateInit_(@strm,version,stream_size);
  231. end;
  232. function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
  233. begin
  234. deflateInit2_:=zdeflate.deflateInit2_(strm,level,method,windowBits,memlevel,strategy,version,stream_size);
  235. end;
  236. function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;
  237. begin
  238. inflateInit2_:=zinflate.inflateInit2_(strm,windowBits,version,stream_size);
  239. end;
  240. function deflateInit(var strm:TZStream;level : longint) : longint;
  241. begin
  242. deflateInit:=zdeflate.deflateInit(strm,level);
  243. end;
  244. function inflateInit(var strm:TZStream) : longint;
  245. begin
  246. inflateInit:=zinflate.inflateInit(strm);
  247. end;
  248. function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
  249. begin
  250. deflateInit2:=zdeflate.deflateInit2(strm,level,method,windowbits,memlevel,strategy);
  251. end;
  252. function inflateInit2(var strm:TZStream; windowBits : longint) : longint;
  253. begin
  254. inflateInit2:=zinflate.inflateInit2_(strm,windowBits,ZLIB_VERSION,sizeof(TZStream));
  255. end;
  256. function zError(err:longint):string;
  257. begin
  258. zerror:=zbase.zerror(err);
  259. end;
  260. function inflateSyncPoint(z:PZstream):longint;
  261. begin
  262. inflateSyncPoint:=zinflate.inflateSyncPoint(z^);
  263. end;
  264. function get_crc_table:pointer;
  265. begin
  266. get_crc_table:=gzcrc.get_crc_table;
  267. end;
  268. end.