Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!aurora!jaw From: jaw@aurora.UUCP Newsgroups: comp.sources.d Subject: Re: Towards minimalist self-decompressing 'shar'chives Message-ID: <688@aurora.UUCP> Date: Tue, 2-Jun-87 20:24:52 EDT Article-I.D.: aurora.688 Posted: Tue Jun 2 20:24:52 1987 Date-Received: Fri, 5-Jun-87 01:22:05 EDT References: <736@bloom-beacon.MIT.EDU> Organization: NASA Ames Research Center, Mt. View, Ca. Lines: 72 # "Invest in dada." -- subliminal, anon. The fix to W. Sommerfeld's quandry (leaving "dot" out of PATH is indeed strange for California) is incorporated below. Also another ~30-byte shortening, in the style to which I would not want to get accustomed. I'm not sure if I've "re-used" every possible variable, but you (or your globally-optimizing compiler) may go blind finding out. For the newcomer, this script is like 'tarmail', but with *no* requirement for the recipient to have 'untarmail', 'zcat', or 'atob'. It's useful enough here at ames-aurora.arpa to simply replace 'shar'. The sender, of course, still must have an executable 'compress' and 'btoa'. E.g. sender: 'shark file1 file2 ... | mail santa\!northpole' (~30% compression for sufficiently large e-mail) receiver: 'sh mailarchive' (look ma, no pre-installed decoder!) ames!jaw ----------------------- cut here for a new-wave 'shar' ------------------ echo '#!/bin/sh # "Cleverly he dialed from within." -- D. Van Vliet, "Trout Mask Replica" PATH=$PATH:. trap "rm -f zcat atob az$$*;exit" 0 1 2 3 15 echo decoding... cat>az$$.c<<\_' cat<<'TROUSER PRESS' #include #define d define #d I if #d E else #d W while #d C char #d L long #d U unsigned #d B(n) (1<<(n)) #d K bcount #d G getchar() #d P putchar #d X return #d H(n) ((C*)h)[n] #d V(a,b) (B(b)-1&a) #d Q 256 #d Y w=w*85+c-33, #d Z w=Q;W(w--)t[w]=0 #d x break; #d F {X(write(2,"shar botch: resend\n",19));} L K,o,v,w,c,m,M=B(16),f;int i,q,b,n,k=16,e=128,j,O,S;U short t[69001];FILE*T;U L h[69001];C D[255];d(c)int c;{I(c=='z'){I(K)F E{c=4;W(c--)y(0);}}E I(c>32&&c< 118){I(!K)w=c-33,++K;E I(K<4)Y++K;E Y y(w>>24),y(w>>16),y(w>>8),y(w),w=K=0;}E F;}y(l)L l;{c=(int)(l&255);o^=c;m+=c;m++;I(1<<31&f)f*=2,f++;E f*=2;f+=c;putc(c ,T);}main(g,v)C**v;{int c;L i,A,h,y,s,r;I(**v!=97)X(a());sprintf(D,mktemp( "azXXXXXX"));I(T=fopen(D,"w+"))unlink(D);E F;W(1){I(!fgets(D,255,stdin))F;I(! strcmp(D,"xbtoa Begin\n"))x}W((c=G)>=0){I(c==10)continue;E I(c=='x')x E d(c);} I(scanf("btoa End N %ld %lx E %lx S %lx R %lx\n",&A,&h,&y,&s,&r)!=5)F;I(A!=h|| y!=o||s!=m||r!=f)F E{fseek(T,0L,0);i=A;W(i--)P(getc(T));}}L g(){C*p=D;I(j>0||O >=S||f>m){I(f>m)m= ++n==k?M:B(n)-1;I(j>0)m=B(n=9)-1,j=0;S=fread(D,1,n,stdin);I (S<1)X-1;O=0;S=S*8-n+1;}q=O;b=n;p+=q>>3;q&=7;c=V(*p++>>q,8-q);q=8-q;b-=q;I(b>7 )c|=(*p++&255)<16)F;z();}z(){L w;C*s;m=B(n=9)-1;Z,H(w)=(C)w;f=e?257: Q;i=o=g();I(o==-1)X;P((C)i);s=(C*)&H(B(16));W((w=g())>=0){I(w==Q&&e){Z;j=1;f=Q ;I((w=g())==-1)x}v=w;I(w>=f)*s++=i,w=o;W((U L)w>=(U L)Q)*s++=H(w),w=t[w];*s++= i=H(w);do P(*--s);W(s>&H(B(16)));I((w=f)/dev/null 1>&2|| (cc -o zcat az$$.c;ln zcat atob) (atob|zcat|tar xvf -)<<\TROUSERS' tar cf - $*|compress|btoa echo TROUSERS