/* Return-Path: lou@metron.com Delivery-Date: Thu Aug 8 17:40:08 2002 Received: from metron.com (uucp@localhost) by toad.com (8.7.5/8.7.3) with UUCP id RAA19942 for hoptoad!gnu; Thu, 8 Aug 2002 17:40:03 -0700 (PDT) Received: from violet.metron.com (indigo.metron.com [192.160.193.52]) by ecotone.toad.com (8.8.7/8.8.7) with ESMTP id RAA32085 for ; Thu, 8 Aug 2002 17:32:02 -0700 Received: from violet.metron.com (violet.metron.com [127.0.0.1]) by violet.metron.com (8.12.3/8.11.6) with ESMTP id g790YcWw009804 for ; Thu, 8 Aug 2002 17:34:42 -0700 (PDT) (envelope-from lou@metron.com) Received: (from lou@localhost) by violet.metron.com (8.12.3/8.12.3/Submit) id g790YbhF009803 for gnu@toad.com; Thu, 8 Aug 2002 17:34:37 -0700 (PDT) (envelope-from lou@metron.com) Date: Thu, 8 Aug 2002 17:34:37 -0700 From: Lou Katz To: gnu@toad.com Message-ID: <20020808173437.A9797@metron.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i */ /* Read a hexified facesaver file and make into real binary pixels */ /* This also inverts the picture top to bottom, as the original were */ /* upside down. LK 08.15.93 */ /* usage: binarify < hexfile > binfile */ #include main(argc,argv) int argc; char **argv; { unsigned char inl[512]; unsigned char outl[512][512]; char sbuf[256], ptemp; register unsigned char *ip, *op; register i,j; int imax,total,fd,k; char *gets(); /* Throws away the newline */ j = 0; /* Count out lines for reversing */ total = 0; fd = open("xyzzy",O_CREAT | O_TRUNC | O_RDWR, 0666); if (fd < 0) { write(2,"Can't create xyxxy\n",19); exit (2); } for (i=0, ip=inl; i<512; i++) *ip++ = '\0'; while (gets(inl)) { ip = inl; op = &outl[j][0]; i=0; while (*ip) { *op = hv(*ip++) * 16; *op += hv(*ip++); op++; i++; } imax = i; total += i; write(fd,&outl[j][0],i); j++; for (i=0, ip=inl; i<512; i++) *ip++ = '\0'; } sprintf(sbuf,"Total bytes %d\n",total); write(2,sbuf,strlen(sbuf)); imax = total/128; k = imax - 1; for (i=127; i>=0 ; i--) { lseek(fd,(long)(imax * i), 0); read(fd,inl,imax); #ifdef REVERSE for (j=0; j< imax/2; j++) { ptemp = inl[j]; inl[j] = inl[k-j]; inl[k-j] = ptemp; } #endif write(1,inl,imax); } } /* Convert hex to decimal */ hv(ch) unsigned char ch; { if ((ch >= '0') && (ch <= '9')) return (ch - '0'); if ((ch >= 'A') && (ch <= 'F')) return (ch - 'A' + 10); if ((ch >= 'a') && (ch <= 'f')) return (ch - 'a' + 10); return 0; }