#!/bin/rc # # command: /bin/boddle /n/juke/plan_9/sys/src/libfb /sys/src/libfb # srcdir: /n/juke/plan_9/sys/src/libfb # version: 836402968 # date: Wed Jul 3 10:09:28 EDT 1996 # myname=$0 doextract=no fn usage{ echo $myname: usage: $myname '[-X] [src-directory]' >[1=2] exit usage } fn sigint{ rm -rf 836402968 exit interrupt } while(~ $1 -*){ switch($1){ case -X doextract=yes case -* usage } shift } switch($#*){ case 0 srcdir=/sys/src/libfb case 1 srcdir=$1 case * usage } if(! ~ $doextract yes){ echo This shell file contains a bundle of diffs representing changes echo to original source files in the Plan 9 distribution. It will run echo against the files in echo ' ' $srcdir echo '(unless overridden by the optional source directory argument)' echo and create a directory 836402968 containing the updated files. echo It will NOT automatically update the original files. echo echo Invoke with argument -X to perform the actual extraction. exit 0 } rm -rf 836402968 mkdir 836402968 target=836402968/getcmap.c echo -n '836402968/getcmap.c: ' if(! test -f $srcdir/getcmap.c || ! test -r $srcdir/getcmap.c){ echo $srcdir/getcmap.c unreadable exit unreadable } sum=`{sum < $srcdir/getcmap.c} if(! ~ d64489682079 $sum(1)^$sum(2)){ echo $srcdir/getcmap.c is not the original distribution file exit original } cp $srcdir/getcmap.c 836402968/getcmap.c ed 836402968/getcmap.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM getcmap.c' 53c v=255.*pow(i/255., 1./gamma); if(rev) v=255-v; buf[0]=buf[1]=buf[2]=v; . 45,46c if(strncmp(f, "gamma", 5)==0){ rev=0; f+=5; }else if(strncmp(f, "rgamma", 6)==0){ rev = 1; f+=6; }else return 0; . 26c int cmap, i, n, v, rev; . wq //GO.SYSIN DD VADIM getcmap.c sum=`{sum < 836402968/getcmap.c} if(~ fdf380342199 $sum(1)^$sum(2)) echo if not{ echo 836402968/getcmap.c checksum error creating updated file exit checksum } target=836402968/mkfile echo -n '836402968/mkfile: ' if(! test -f $srcdir/mkfile || ! test -r $srcdir/mkfile){ echo $srcdir/mkfile unreadable exit unreadable } sum=`{sum < $srcdir/mkfile} if(! ~ e3dfdfc5418 $sum(1)^$sum(2)){ echo $srcdir/mkfile is not the original distribution file exit original } cp $srcdir/mkfile 836402968/mkfile ed 836402968/mkfile >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM mkfile' 24a CFLAGS=-w -I/sys/include/ape . wq //GO.SYSIN DD VADIM mkfile sum=`{sum < 836402968/mkfile} if(~ f6443b50448 $sum(1)^$sum(2)) echo if not{ echo 836402968/mkfile checksum error creating updated file exit checksum } target=836402968/pic.pl9.c echo -n '836402968/pic.pl9.c: ' if(! test -f $srcdir/pic.pl9.c || ! test -r $srcdir/pic.pl9.c){ echo $srcdir/pic.pl9.c unreadable exit unreadable } sum=`{sum < $srcdir/pic.pl9.c} if(! ~ b09cc73c2332 $sum(1)^$sum(2)){ echo $srcdir/pic.pl9.c is not the original distribution file exit original } cp $srcdir/pic.pl9.c 836402968/pic.pl9.c ed 836402968/pic.pl9.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM pic.pl9.c' 98,105c return _PICheader(p, buf, "plan9"); } int _PICcompressedheader(PICFILE *p, char *buf){ char hbuf[5*12+1]; if(memcmp(buf, "compressed\n", 11)!=0) return 0; if(_PICread(p->fd, hbuf, 5*12)<=0) return 0; return _PICheader(p, hbuf, "compressed"); } int _PRDpl9(PICFILE *f, void *vbuf){ return _PRDplan9(f, vbuf, 0); } int _PRDcmp(PICFILE *f, void *vbuf){ return _PRDplan9(f, vbuf, 1); } int _PWRpl9(PICFILE *f, void *vbuf){ return _PWRplan9(f, vbuf, 0); } int _PWRcmp(PICFILE *f, void *vbuf){ return _PWRplan9(f, vbuf, 1); } void _PCLpl9(PICFILE *f){ if(f->buf) free(f->buf); } void _PCLcmp(PICFILE *f){ if(f->buf) free(f->buf); . 91,92c static char rgbvmap[256*3]={ 0, 0, 0, 0, 0, 68, 0, 0, 136, 0, 0, 204, 0, 68, 0, 0, 68, 68, 0, 68, 136, 0, 68, 204, 0, 136, 0, 0, 136, 68, 0, 136, 136, 0, 136, 204, 0, 204, 0, 0, 204, 68, 0, 204, 136, 0, 204, 204, 0, 221, 221, 17, 17, 17, 0, 0, 85, 0, 0, 153, 0, 0, 221, 0, 85, 0, 0, 85, 85, 0, 76, 153, 0, 73, 221, 0, 153, 0, 0, 153, 76, 0, 153, 153, 0, 147, 221, 0, 221, 0, 0, 221, 73, 0, 221, 147, 0, 238, 158, 0, 238, 238, 34, 34, 34, 0, 0, 102, 0, 0, 170, 0, 0, 238, 0, 102, 0, 0, 102, 102, 0, 85, 170, 0, 79, 238, 0, 170, 0, 0, 170, 85, 0, 170, 170, 0, 158, 238, 0, 238, 0, 0, 238, 79, 0, 255, 85, 0, 255, 170, 0, 255, 255, 51, 51, 51, 0, 0, 119, 0, 0, 187, 0, 0, 255, 0, 119, 0, 0, 119, 119, 0, 93, 187, 0, 85, 255, 0, 187, 0, 0, 187, 93, 0, 187, 187, 0, 170, 255, 0, 255, 0, 68, 0, 68, 68, 0, 136, 68, 0, 204, 68, 68, 0, 68, 68, 68, 68, 68, 136, 68, 68, 204, 68, 136, 0, 68, 136, 68, 68, 136, 136, 68, 136, 204, 68, 204, 0, 68, 204, 68, 68, 204, 136, 68, 204, 204, 68, 0, 0, 85, 0, 0, 85, 0, 85, 76, 0, 153, 73, 0, 221, 85, 85, 0, 85, 85, 85, 76, 76, 153, 73, 73, 221, 76, 153, 0, 76, 153, 76, 76, 153, 153, 73, 147, 221, 73, 221, 0, 73, 221, 73, 73, 221, 147, 73, 221, 221, 79, 238, 238, 102, 0, 0, 102, 0, 102, 85, 0, 170, 79, 0, 238, 102, 102, 0, 102, 102, 102, 85, 85, 170, 79, 79, 238, 85, 170, 0, 85, 170, 85, 85, 170, 170, 79, 158, 238, 79, 238, 0, 79, 238, 79, 79, 238, 158, 85, 255, 170, 85, 255, 255, 119, 0, 0, 119, 0, 119, 93, 0, 187, 85, 0, 255, 119, 119, 0, 119, 119, 119, 93, 93, 187, 85, 85, 255, 93, 187, 0, 93, 187, 93, 93, 187, 187, 85, 170, 255, 85, 255, 0, 85, 255, 85, 136, 0, 136, 136, 0, 204, 136, 68, 0, 136, 68, 68, 136, 68, 136, 136, 68, 204, 136, 136, 0, 136, 136, 68, 136, 136, 136, 136, 136, 204, 136, 204, 0, 136, 204, 68, 136, 204, 136, 136, 204, 204, 136, 0, 0, 136, 0, 68, 153, 0, 76, 153, 0, 153, 147, 0, 221, 153, 76, 0, 153, 76, 76, 153, 76, 153, 147, 73, 221, 153, 153, 0, 153, 153, 76, 153, 153, 153, 147, 147, 221, 147, 221, 0, 147, 221, 73, 147, 221, 147, 147, 221, 221, 153, 0, 0, 170, 0, 0, 170, 0, 85, 170, 0, 170, 158, 0, 238, 170, 85, 0, 170, 85, 85, 170, 85, 170, 158, 79, 238, 170, 170, 0, 170, 170, 85, 170, 170, 170, 158, 158, 238, 158, 238, 0, 158, 238, 79, 158, 238, 158, 158, 238, 238, 170, 255, 255, 187, 0, 0, 187, 0, 93, 187, 0, 187, 170, 0, 255, 187, 93, 0, 187, 93, 93, 187, 93, 187, 170, 85, 255, 187, 187, 0, 187, 187, 93, 187, 187, 187, 170, 170, 255, 170, 255, 0, 170, 255, 85, 170, 255, 170, 204, 0, 204, 204, 68, 0, 204, 68, 68, 204, 68, 136, 204, 68, 204, 204, 136, 0, 204, 136, 68, 204, 136, 136, 204, 136, 204, 204, 204, 0, 204, 204, 68, 204, 204, 136, 204, 204, 204, 204, 0, 0, 204, 0, 68, 204, 0, 136, 221, 0, 147, 221, 0, 221, 221, 73, 0, 221, 73, 73, 221, 73, 147, 221, 73, 221, 221, 147, 0, 221, 147, 73, 221, 147, 147, 221, 147, 221, 221, 221, 0, 221, 221, 73, 221, 221, 147, 221, 221, 221, 221, 0, 0, 221, 0, 73, 238, 0, 79, 238, 0, 158, 238, 0, 238, 238, 79, 0, 238, 79, 79, 238, 79, 158, 238, 79, 238, 238, 158, 0, 238, 158, 79, 238, 158, 158, 238, 158, 238, 238, 238, 0, 238, 238, 79, 238, 238, 158, 238, 238, 238, 238, 0, 0, 255, 0, 0, 255, 0, 85, 255, 0, 170, 255, 0, 255, 255, 85, 0, 255, 85, 85, 255, 85, 170, 255, 85, 255, 255, 170, 0, 255, 170, 85, 255, 170, 170, 255, 170, 255, 255, 255, 0, 255, 255, 85, 255, 255, 170, 255, 255, 255, }; static int _PICheader(PICFILE *p, char *hbuf, char *type){ char *l; hbuf[12*5]='\0'; picputprop(p, "TYPE", type); picputprop(p, "WINDOW", hbuf+12); picputprop(p, "NCHAN", "1"); picputprop(p, "CHAN", "m"); hbuf[12]='\0'; l=hbuf; while(*l==' ') l++; picputprop(p, "LDEPTH", l); picputprop(p, "CMAP", ""); p->cmap=malloc(3*256); if(p->cmap==0){ werrstr("Can't allocate color map"); return 0; } memcpy(p->cmap, rgbvmap, 3*256); return 1; . 89c if(compressed){ f->bufp+=nbl; if(f->line!=f->height) return 1; return _PICcompress(f->fd, Rect(f->x, f->y, f->x+f->width, f->y+f->height), f->buf, nbl); } else return write(f->fd, f->buf, nbl)==nbl; . 78c bp=f->bufp; . 75a f->bufp=f->buf; . 71c if(compressed) f->buf=malloc(nbl*f->height+1); else f->buf=malloc(nbl+1); /* +1 because loop below is sloppy */ . 62a if(compressed) write(f->fd, "compressed\n", 11); . 51c #define HSHIFT 3 /* HSHIFT==5 runs slightly faster, but hash table is 64x bigger */ #define NHASH (1<<(HSHIFT*NMATCH)) #define HMASK (NHASH-1) #define hupdate(h, c) ((((h)<next){ for(s=p,t=hp->s;s!=es;s++,t++) if(*s!=*t) break; n=s-p; if(n>runlen){ runlen=n; q=hp->s; if(n==NRUN) break; } } if(runlen>8); *outp++=offs&255; } for(q=p+runlen;p!=q;p++){ if(cp->prev) cp->prev->next=0; cp->next=hash[h].next; cp->prev=&hash[h]; if(cp->next) cp->next->prev=cp; cp->prev->next=cp; cp->s=p; if(++cp==&chain[NMEM]) cp=chain; if(edata-p>=NMATCH) h=hupdate(h, p[NMATCH]); } } if(ndump!=0){ if(eout-outpline++; . 37,39d 35a if(_PICread(f->fd, f->buf, nbl)<=0) return 0; bp=f->buf; . 33,34c f->buf=malloc(nbl); if(f->buf==0){ werrstr("Can't allocate read buffer"); return 0; } . 30,31c if(compressed){ bp=_PICdecompressline(f, nbl); if(bp==0) return 0; } else{ . 10c /* * Compressed bitmap parameters, copied from /usr/inferno/include/image.h */ #define NMATCH 3 /* shortest match possible */ #define NRUN (NMATCH+31) /* longest match possible */ #define NMEM 1024 /* window size */ #define NDUMP 128 /* maximum length of dump */ #define NCBLOCK 6000 /* size of compressed blocks */ static unsigned char *_PICdecompressline(PICFILE *f, int nbl){ unsigned char *v; unsigned char cblock[NCBLOCK]; int ncblock; int ny; char blkheader[2*12]; unsigned char *data, *edata; unsigned char *bufp, *memp; int c, n, offs; if(f->buf==0 || f->bufp==f->ebuf){ if(f->buf!=0){ free(f->buf); f->buf=0; } if(_PICread(f->fd, blkheader, 2*12)<=0) return 0; ny=atoi(blkheader)-f->y-f->line; ncblock=atoi(blkheader+12); if(_PICread(f->fd, cblock, ncblock)<=0) return 0; f->buf=malloc(ny*nbl); if(f->buf==0) return 0; f->bufp=f->buf; f->ebuf=f->buf+ny*nbl; bufp=f->buf; data=cblock; edata=data+ncblock; while(data!=edata){ c=*data++; if(c>=128){ for(n=c-128+1;n!=0;--n){ if(data==edata || bufp==f->ebuf) goto Done; *bufp++=*data++; } } else{ if(data==edata) break; offs=*data++ + ((c&3)<<8)+1; if(offs>bufp-f->buf){ werrstr("bad offset in compressed block"); return 0; } memp=bufp-offs; for(n=(c>>2)+NMATCH;n!=0;--n){ if(bufp==f->ebuf) goto Done; *bufp++=*memp++; } } } Done: if(data!=edata){ werrstr("extra data at end of compressed block"); return 0; } if(bufp!=f->ebuf){ werrstr("short compressed block"); return 0; } } v=f->bufp; f->bufp+=nbl; return v; } static int _PRDplan9(PICFILE *f, void *vbuf, int compressed){ . 2c * Type-specific code for TYPE=plan9 and TYPE=compressed * Bug: * when writing a compressed file, we accumulate the whole image in * a buffer before writing anything, possibly wasting a good lot of space. . wq //GO.SYSIN DD VADIM pic.pl9.c sum=`{sum < 836402968/pic.pl9.c} if(~ 1ff344c611703 $sum(1)^$sum(2)) echo if not{ echo 836402968/pic.pl9.c checksum error creating updated file exit checksum } target=836402968/picconf.c echo -n '836402968/picconf.c: ' if(! test -f $srcdir/picconf.c || ! test -r $srcdir/picconf.c){ echo $srcdir/picconf.c unreadable exit unreadable } sum=`{sum < $srcdir/picconf.c} if(! ~ 3205a8cc1200 $sum(1)^$sum(2)){ echo $srcdir/picconf.c is not the original distribution file exit original } cp $srcdir/picconf.c 836402968/picconf.c ed 836402968/picconf.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM picconf.c' 18a "compressed", _PRDcmp, _PWRcmp, _PCLcmp, 1, . 3a int _PRDcmp(PICFILE *, void *), _PWRcmp(PICFILE *, void *), _PCLcmp(PICFILE *); . wq //GO.SYSIN DD VADIM picconf.c sum=`{sum < 836402968/picconf.c} if(~ 8babb9cc1325 $sum(1)^$sum(2)) echo if not{ echo 836402968/picconf.c checksum error creating updated file exit checksum } target=836402968/picopen_r.c echo -n '836402968/picopen_r.c: ' if(! test -f $srcdir/picopen_r.c || ! test -r $srcdir/picopen_r.c){ echo $srcdir/picopen_r.c unreadable exit unreadable } sum=`{sum < $srcdir/picopen_r.c} if(! ~ af35f8483770 $sum(1)^$sum(2)){ echo $srcdir/picopen_r.c is not the original distribution file exit original } cp $srcdir/picopen_r.c 836402968/picopen_r.c ed 836402968/picopen_r.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM picopen_r.c' 161a } for(i=3*256,lp=p->cmap;i!=0;i-=n,lp+=n){ n=read(p->fd, lp, i); if(n<=0){ werrstr("Can't read color map"); goto Error; } . 154,160c p->cmap=malloc(3*256); if(p->cmap==0){ werrstr("Can't allocate color map"); . 152d 73a if(first && _PICcompressedheader(p, line)) goto AllRead; . 6,7c int _PWRerror(PICFILE *f, void *buf){ USED(f); USED(buf); . 4a char *_PICcommand; . wq //GO.SYSIN DD VADIM picopen_r.c sum=`{sum < 836402968/picopen_r.c} if(~ ac2820863897 $sum(1)^$sum(2)) echo if not{ echo 836402968/picopen_r.c checksum error creating updated file exit checksum } target=836402968/picopen_w.c echo -n '836402968/picopen_w.c: ' if(! test -f $srcdir/picopen_w.c || ! test -r $srcdir/picopen_w.c){ echo $srcdir/picopen_w.c unreadable exit unreadable } sum=`{sum < $srcdir/picopen_w.c} if(! ~ 2b00b3d12554 $sum(1)^$sum(2)){ echo $srcdir/picopen_w.c is not the original distribution file exit original } cp $srcdir/picopen_w.c 836402968/picopen_w.c ed 836402968/picopen_w.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM picopen_w.c' 10d 6,7c int _PRDerror(PICFILE *f, void *buf){ USED(f); USED(buf); . wq //GO.SYSIN DD VADIM picopen_w.c sum=`{sum < 836402968/picopen_w.c} if(~ 56f5f7ce2526 $sum(1)^$sum(2)) echo if not{ echo 836402968/picopen_w.c checksum error creating updated file exit checksum } target=836402968/picpack.c echo -n '836402968/picpack.c: ' if(! test -f $srcdir/picpack.c || ! test -r $srcdir/picpack.c){ echo $srcdir/picpack.c unreadable exit unreadable } sum=`{sum < $srcdir/picpack.c} if(! ~ 7918c4121419 $sum(1)^$sum(2)){ echo $srcdir/picpack.c is not the original distribution file exit original } cp $srcdir/picpack.c 836402968/picpack.c ed 836402968/picpack.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM picpack.c' 10d wq //GO.SYSIN DD VADIM picpack.c sum=`{sum < 836402968/picpack.c} if(~ 4f863c4d1395 $sum(1)^$sum(2)) echo if not{ echo 836402968/picpack.c checksum error creating updated file exit checksum } target=836402968/picunpack.c echo -n '836402968/picunpack.c: ' if(! test -f $srcdir/picunpack.c || ! test -r $srcdir/picunpack.c){ echo $srcdir/picunpack.c unreadable exit unreadable } sum=`{sum < $srcdir/picunpack.c} if(! ~ 65e67fd21417 $sum(1)^$sum(2)){ echo $srcdir/picunpack.c is not the original distribution file exit original } cp $srcdir/picunpack.c 836402968/picunpack.c ed 836402968/picunpack.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM picunpack.c' 10d wq //GO.SYSIN DD VADIM picunpack.c sum=`{sum < 836402968/picunpack.c} if(~ 7ca6538f1393 $sum(1)^$sum(2)) echo if not{ echo 836402968/picunpack.c checksum error creating updated file exit checksum } target=836402968/rdpicfile.c echo -n '836402968/rdpicfile.c: ' if(! test -f $srcdir/rdpicfile.c || ! test -r $srcdir/rdpicfile.c){ echo $srcdir/rdpicfile.c unreadable exit unreadable } sum=`{sum < $srcdir/rdpicfile.c} if(! ~ 6fb593a71623 $sum(1)^$sum(2)){ echo $srcdir/rdpicfile.c is not the original distribution file exit original } cp $srcdir/rdpicfile.c 836402968/rdpicfile.c ed 836402968/rdpicfile.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM rdpicfile.c' 39c if(f->cmap && ldepth!=3){ . wq //GO.SYSIN DD VADIM rdpicfile.c sum=`{sum < 836402968/rdpicfile.c} if(~ 831542271636 $sum(1)^$sum(2)) echo if not{ echo 836402968/rdpicfile.c checksum error creating updated file exit checksum } target=836402968/junk.c echo -n '836402968/junk.c (new): ' cat > 836402968/junk.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/libfb' #include #include #include #include void main(void){ PICFILE *f, *g; char line[1024]; int y; f=picopen_r("/usr/inferno/icons/att.bit"); g=picopen_w("OUT", "runcode", 0, 0, f->width, f->height, "m", 0, 0); for(y=0;y!=f->height;y++){ picread(f, line); picwrite(g, line); } exits(0); } //GO.SYSIN DD VADIM /sys/src/libfb sum=`{sum < 836402968/junk.c} if(~ b0560800326 $sum(1)^$sum(2)) echo if not{ echo 836402968/junk.c checksum error extracting new file exit checksum }