Path: utzoo!attcan!uunet!zephyr.ens.tek.com!uw-beaver!milton!dali.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpl-opus!hpnmdla!hpmwtd!davem From: davem@hpmwtd.HP.COM (Dave McQuate) Newsgroups: comp.sources.d Subject: Re: Uuencode Message-ID: <940005@hpmwdjm.HP.COM> Date: 17 Jul 90 22:58:06 GMT References: <148@ncratl.Atlanta.NCR.COM> Organization: HP Microwave Tech. - Santa Rosa, Ca. Lines: 42 Here's a quickie, no-frills version I wrote--it will encode each file listed on the command line, sending all the encoded stuff to standard out. I've used it in HP's version of unix but it should compile under Turbo C (link with "wildargs.obj" to get command line wild cards to work, tho I'm not sure why one would want to encode several files into one) or ... /* uuencode.c */ #include #define add(c) ((c & 077) + ' ') int main(argc, argv) int argc; char *argv[]; { FILE *file; int i, j, k, l, m, bytes; char buffer[50]; for ( ++argv; argc-- && *argv; ++argv) { file = fopen(*argv, "rb"); printf("begin 777 %s\n", *argv); for ( ; ; ) { bytes = fread(buffer, 1, 45, file); buffer[bytes] = buffer[bytes + 1] = 0; printf("%c", add(bytes)); for (i = 0; i < bytes; i +=3) { j = buffer[i] >> 2; k = (buffer[i] << 4) & 060 | (buffer[i+1] >> 4) & 017; l = (buffer[i+1] << 2) & 074 | (buffer[i+2] >> 6) & 3; m = buffer[i+2] & 077; printf("%c%c%c%c", add(j), add(k), add(l), add(m)); } printf("\n"); if (bytes != 45) break; } printf("`\nend\n"); fclose(file); } } ___________________________________________________________________________ _