5 #define OUT(X) if(out < outend) *(out++) = X; else return 0;
7 int lzwdecomp(unsigned char* in
, unsigned long insz
,
8 unsigned char* out
, unsigned long outsz
)
11 unsigned char *inend
= in
+insz
, *outend
= out
+outsz
;
12 int bits
, len
, mask
, i
= N
- 16;
14 if(in
>= inend
) return 0;
16 for (mask
= 1; mask
& 0xFF; mask
<<= 1) {
18 if(in
+2>inend
) return 0;
24 len
= ((j
>> 12) & 15) + 3;
25 j
= (i
- j
- 1) & (N
- 1);
30 j
= (j
+ 1) & (N
- 1);
31 i
= (i
+ 1) & (N
- 1);
34 if(in
>= inend
) return 0;
37 i
= (i
+ 1) & (N
- 1);
39 if(out
== outend
) break;
41 if(out
== outend
) break;