Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: comp.compression Subject: uncompress.c - uncompress files in Unix `compress' format Message-ID: <1991May3.170423.13710@twinsun.com> Date: 3 May 91 17:04:23 GMT Sender: usenet@twinsun.com Organization: Twin Sun, Inc Lines: 24 Nntp-Posting-Host: ata Here is a short C program that accepts standard input in Unix `compress' format and generates the corresponding uncompressed standard output. It is a strictly conforming ANSI C program, compiles in traditional C, and is portable to a wide variety of machines. It is derived from code in the compressed archiving program `shark', in which understandability has been sacrificed for brevity. /*uncompress.c by James A. Woods and Paul Eggert*/ #include #define G getchar() #define H (w=g()) #define K [69001] #define P putchar #define Q 256 #define W while #define X return 0 #define Z w=Q;W(w--)t[w]=0 long c,f,m,o,w;int O,S,e,i,k,n,q,t K;char D K,h K;long g(){char*p;if(m=S){O=0;S=fread(D,1,n,stdin)*8;if(S<8 )X-1;S-=n-1;}p=D+O/8;q=O&7;O+=n;X,(1<<8-q)-1&*p>>q|m&((15>7&1;k&=31;if(k>16)X,perror("uncompress"), 1;Z,h[w]=w;n=8;f=Q+e;i=o=H;if(o<0)X,1;P(i);W(H+1){if(w==Q&e){Z;m=n=8;f=Q;if(H<0 )X;}c=w;if(w>=f)*p++=i,w=o;W(w>=Q)*p++=h[w],w=t[w];P(i=h[w]);W(p>D+Q)P(*--p);if ((w=f)<1l<