Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site utecfa.UUCP Path: utzoo!utcsri!utai!uthub!utecfa!mugc From: mugc@utecfa.UUCP (ModemUserGroupChairman) Newsgroups: net.micro.atari Subject: uuENcode.c for the ST. Source. Long Message-ID: <1761@utecfa.UUCP> Date: Mon, 25-Nov-85 18:58:32 EST Article-I.D.: utecfa.1761 Posted: Mon Nov 25 18:58:32 1985 Date-Received: Mon, 25-Nov-85 23:45:54 EST Organization: Engineering Computing Facility, University of Toronto Lines: 151 Here is a version of uuencode that will run on the ST when compiled with the DRI-C compiler. This version was hacked out of the uuencode.c that appeared on net.sources a while ago. Uudecode.c, if I remember correctly, worked right away so I did not bother to archive it. You should be able to get it off net.sources. The only portion that had to be modified was the part of the code used to open a file. The original file used efopen() which then called fopen(). I had to modify it to fopenb() to open binary files. The source follows. Link it with osbind. Enjoy. -------------------------------- /* * * Uuencode -- encode a file so that it's printable ascii, short lines * * Slightly modified from a version posted to net.sources a while back, * and suitable for compilation on the IBM PC * */ /* * Modified for the Atari 520ST (October 27, 1985) */ #include #include char *progname = "UUENCODE"; #define USAGE "Usage: UUENCODE file [>outfile]\n" /* ENC is the basic 1 character encoding function to make a char printing */ #define ENC(c) (((c) & 077) + ' ') main(argc, argv) int argc; char *argv[]; { FILE *in, *out, *efopen(), *efopenb(); if (argc < 2) { fprintf(stderr, USAGE); exit(2); } in = efopenb(argv[1], "r"); if (argc == 3) { out = efopen(argv[2], "w"); } else out = stdout; fprintf(out, "begin %o %s\n", 0777, argv[1]); encode(in, out); fprintf(out, "end\n"); } /* * copy from in to out, encoding as you go along. */ encode(in, out) FILE *in, *out; { char buf[80]; int i, n; for (;;) { n = fr(in, buf, 45); 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); } /* fr: like read but stdio */ int fr(fd, buf, cnt) FILE *fd; char *buf; int cnt; { int c, i; for (i = 0; i < cnt; i++) { c = getc(fd); if (c == EOF) return(i); buf[i] = c; } return (cnt); } FILE * efopen(fn, mode) char *fn, *mode; { FILE *unit; if ((unit = fopen(fn, mode)) == NULL) error("Cannot open file %s", fn); else return unit; } extern char *progname; error(s1, s2) char *s1, *s2; { fprintf(stderr, "%s: ", progname); fprintf(stderr, s1, s2); exit(1); } /* * efopenb is a slightly modified efopen() * All it does is use the ST fopenb() call to open * a binary file. * Note that this is uuencode so only the input file * needs to be opened with this function. */ FILE * efopenb(fn, mode) char *fn, *mode; { FILE *unit; if ((unit = fopenb(fn, mode)) == NULL) error("Cannot open file %s", fn); else return unit; }