Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 UW 5/3/83; site uw-beaver Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!info-mac From: info-mac@uw-beaver (info-mac) Newsgroups: fa.info-mac Subject: fromhex for UNIX Message-ID: <1337@uw-beaver> Date: Thu, 26-Jul-84 15:58:54 EDT Article-I.D.: uw-beaver>.1337 Posted: Thu Jul 26 15:58:54 1984 Date-Received: Fri, 27-Jul-84 07:31:47 EDT Sender: daemon@uw-beave Organization: U of Washington Computer Science Lines: 55 From: Bill Croft From: Mark H. Nodine and Bill Croft Back in the days before macput/macget, programs were downloaded to the Mac by saving the MacTerminal scrolloff in a file, and running a program on the Mac called "fromhex" that converted this hex file to a binary resource file. People still distribute their programs in this (.dl) format because it can be sent through the mail or ftped in ASCII mode. Here is a version of "fromhex" for UNIX: ---- /* fromhex.c, UNIX version */ #include int bytes,sum; main() { register i,v; register n; n = 0; v = 0; while ((i = getchar()) != EOF) { i &= 0177; if (i == '|') break; if (i < 0100 || i > 0117) continue; v = (v << 4) | (i & 0xF); if ((++n & 1) == 0) { putchar(v); sum += v; v = 0; bytes++; } } n = 0; for (i = 0 ; i < 8 ; i++) n = (n << 4) | (getchar() & 0xF); if (n != (bytes + sum)) fprintf(stderr, "bad checksum\n"); else fprintf(stderr, "checksum good!\n"); exit(0); } This program is a filter, so you should invoke it something like fromhex neatprog.rsrc macput -r neatprog.rsrc This halves the amount of time it takes to download neatprog. P.S. Thanks to so many of you who are providing programs for downloading!