Path: utzoo!attcan!uunet!snorkelwacker!usc!ucsd!sdd.hp.com!hplabs!hpcc01!azarian From: azarian@hpcc01.HP.COM (Randy Azarian) Newsgroups: comp.binaries.ibm.pc.d Subject: Re: uuENcode Message-ID: <11160001@hpcc01.HP.COM> Date: 11 Jun 90 23:19:26 GMT References: <31247@ut-emx.UUCP> Organization: HP Corporate Computing & Services Lines: 126 > I have uuDEcode running on my PC clone just fine. I'd like the source code to > uuENcode if anybody's got it. /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * Modified 12 April 1990 by Mark Adler for use on MSDOS systems with * Microsoft C and Turbo C. */ #ifndef lint static char sccsid[] = "@(#)uuencode.c 5.6 (Berkeley) 7/6/88"; #endif /* not lint */ #ifdef __MSDOS__ /* For Turbo C */ #define MSDOS 1 #endif /* * uuencode [input] output * * Encode a file so it can be mailed to a remote system. */ #include #include #include /* ENC is the basic 1 character encoding function to make a char printing */ #define ENC(c) ((c) ? ((c) & 077) + ' ': '`') main(argc, argv) char **argv; { FILE *in; struct stat sbuf; int mode; /* optional 1st argument */ if (argc > 2) { #ifdef MSDOS if ((in = fopen(argv[1], "rb")) == NULL) { /* Binary file */ #else if ((in = fopen(argv[1], "r")) == NULL) { #endif perror(argv[1]); exit(1); } argv++; argc--; } else in = stdin; if (argc != 2) { fprintf(stderr,"Usage: uuencode [infile] remotefile\n"); exit(2); } /* figure out the input file mode */ if (fstat(fileno(in), &sbuf) < 0 || !isatty(fileno(in))) mode = 0666 & ~umask(0666); else mode = sbuf.st_mode & 0777; printf("begin %o %s\n", mode, argv[1]); encode(in, stdout); printf("end\n"); exit(0); } /* * copy from in to out, encoding as you go along. */ encode(in, out) register FILE *in; register FILE *out; { char buf[80]; register int i, n; for (;;) { /* 1 (up to) 45 character line */ n = fread(buf, 1, 45, in); putc(ENC(n), out); for (i=0; i> 2; c2 = (*p << 4) & 060 | (p[1] >> 4) & 017; c3 = (p[1] << 2) & 074 | (p[2] >> 6) & 03; c4 = p[2] & 077; putc(ENC(c1), f); putc(ENC(c2), f); putc(ENC(c3), f); putc(ENC(c4), f); }