3 { types and macros common to blocks and codes
4 Copyright (C) 1995-1998 Mark Adler
6 WARNING: this file should *not* be used by applications. It is
7 part of the implementation of the compression library and is
8 subject to change.
10 Pascal tranlastion
11 Copyright (C) 1998 by Jacques Nomssi Nzali
12 For conditions of distribution and use, see copyright notice in readme.txt
13 }
15 interface
17 {$I imzconf.inc}
19 uses
22 { copy as much as possible from the sliding window to the output area }
27 { And'ing with mask[n] masks the lower n bits }
28 const
34 {procedure GRABBITS(j : int);}
35 {procedure DUMPBITS(j : int);}
36 {procedure NEEDBITS(j : int);}
38 implementation
40 { macros for bit input with no checking and for returning unused bytes }
42 begin
43 {while (k < j) do
44 begin
45 Dec(z^.avail_in);
46 Inc(z^.total_in);
47 b := b or (uLong(z^.next_in^) shl k);
48 Inc(z^.next_in);
49 Inc(k, 8);
50 end;}
54 begin
55 {b := b shr j;
56 Dec(k, j);}
60 begin
61 (*
62 while (k < j) do
63 begin
64 {NEEDBYTE;}
65 if (n <> 0) then
66 r :=Z_OK
67 else
68 begin
69 {UPDATE}
70 s.bitb := b;
71 s.bitk := k;
72 z.avail_in := n;
73 Inc(z.total_in, LongInt(p)-LongInt(z.next_in));
74 z.next_in := p;
75 s.write := q;
76 result := inflate_flush(s,z,r);
77 exit;
78 end;
79 Dec(n);
80 b := b or (uLong(p^) shl k);
81 Inc(p);
82 Inc(k, 8);
83 end;
84 *)
88 begin
89 (*
90 if (m = 0) then
91 begin
92 {WRAP}
93 if (q = s.zend) and (s.read <> s.window) then
94 begin
95 q := s.window;
96 if LongInt(q) < LongInt(s.read) then
97 m := uInt(LongInt(s.read)-LongInt(q)-1)
98 else
99 m := uInt(LongInt(s.zend)-LongInt(q));
100 end;
102 if (m = 0) then
103 begin
104 {FLUSH}
105 s.write := q;
106 r := inflate_flush(s,z,r);
107 q := s.write;
108 if LongInt(q) < LongInt(s.read) then
109 m := uInt(LongInt(s.read)-LongInt(q)-1)
110 else
111 m := uInt(LongInt(s.zend)-LongInt(q));
113 {WRAP}
114 if (q = s.zend) and (s.read <> s.window) then
115 begin
116 q := s.window;
117 if LongInt(q) < LongInt(s.read) then
118 m := uInt(LongInt(s.read)-LongInt(q)-1)
119 else
120 m := uInt(LongInt(s.zend)-LongInt(q));
121 end;
123 if (m = 0) then
124 begin
125 {UPDATE}
126 s.bitb := b;
127 s.bitk := k;
128 z.avail_in := n;
129 Inc(z.total_in, LongInt(p)-LongInt(z.next_in));
130 z.next_in := p;
131 s.write := q;
132 result := inflate_flush(s,z,r);
133 exit;
134 end;
135 end;
136 end;
137 r := Z_OK;
138 *)
141 { copy as much as possible from the sliding window to the output area }
145 var
149 begin
150 { local copies of source and destination pointers }
154 { compute number of bytes to copy as far as end of window }
157 else
164 { update counters }
169 { update check information }
171 begin
176 { copy as far as end of window }
181 { see if more to copy at beginning of window }
183 begin
184 { wrap pointers }
189 { compute bytes to copy }
196 { update counters }
200 { update check information }
202 begin
207 { copy }
214 { update pointers }
218 { done }