Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site imagen.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!gatech!seismo!lll-crg!ucdavis!ucbvax!decvax!decwrl!sun!saber!imagen!turner
From: turner@imagen.UUCP (D'arc Angel)
Newsgroups: net.micro.atari
Subject: Re: uuENcode.c for the ST. Source. Long
Message-ID: <112@imagen.UUCP>
Date: Tue, 3-Dec-85 09:34:53 EST
Article-I.D.: imagen.112
Posted: Tue Dec 3 09:34:53 1985
Date-Received: Fri, 6-Dec-85 08:01:59 EST
References: <1761@utecfa.UUCP>
Organization: The Houses of the Holy
Lines: 615
>
> Here is a version of uuencode that will run on the ST when
> compiled with the DRI-C compiler.
~~~~~~~~~~~~~easy lineater, good lineater~~~~~~~~~~~~~~~
for the alcyon C compiler a further hack was necessary, fopen and
fopenb must be declared as FILE *. Here is both uuencode.c and
uudecode.c plus the encoded version of jim's bouncing ball demo.
~~~~~~~~~~~~~~~~~~~~~~~UUENCODE.C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
* 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.
*/
/*
*
* 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) + ' ')
FILE *in, *out, *efopen(), *efopenb(), *fopen(), *fopenb();
main(argc, argv)
int argc; char *argv[];
{
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;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~UUDECODE.C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
* Uudecode -- decode a uuencoded file back to binary form.
*
* Slightly modified from a version posted to net.sources once;
* suitable for compilation on an IBM PC.
*
*/
#include
#include
char *Progname = "UUDECODE";
#define USAGE "Usage: UUDECODE [file]\n"
/* single character decode */
#define DEC(c) (((c) - ' ') & 077)
FILE *in, *out, *efopen(), *efopenb(), *fopen(), *fopenb();
main(argc, argv)
int argc; char *argv[];
{
int mode;
char dest[128];
char buf[80];
/* optional input arg */
if (argc > 1) {
in = efopen(argv[1], "r");
argv++; argc--;
}
else
in = stdin;
if (argc != 1) {
fprintf(stderr, USAGE);
exit(2);
}
/* search for header line */
for (;;) {
if (fgets(buf, sizeof buf, in) == NULL) {
fprintf(stderr, "No begin line\n");
exit(3);
}
if (strncmp(buf, "begin ", 6) == 0)
break;
}
sscanf(buf, "begin %o %s", &mode, dest);
out = efopenb(dest, "w"); /* create output file */
decode(in, out);
fclose(out);
if (fgets(buf, sizeof buf, in) == NULL || strcmp(buf, "end\n")) {
fprintf(stderr, "No end line\n");
exit(5);
}
}
/*
* copy from in to out, decoding as you go along.
*/
decode(in, out)
FILE *in, *out;
{
char buf[80];
char *bp;
int n;
for (;;) {
if (fgets(buf, sizeof buf, in) == NULL) {
fprintf(stderr, "Short file\n");
break;
}
n = DEC(buf[0]);
if (n <= 0)
break;
bp = &buf[1];
while (n > 0) {
outdec(bp, out, n);
bp += 4;
n -= 3;
}
}
}
/*
* output a group of 3 bytes (4 input characters).
* the input chars are pointed to by p, they are to
* be output to file f. n is used to tell us not to
* output all of them at the end of the file.
*/
outdec(p, f, n)
char *p; FILE *f; int n;
{
int c1, c2, c3;
c1 = DEC(*p) << 2 | DEC(p[1]) >> 4;
c2 = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
c3 = DEC(p[2]) << 6 | DEC(p[3]);
if (n >= 1)
putc(c1, f);
if (n >= 2)
putc(c2, f);
if (n >= 3)
putc(c3, 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);
}
/* If your library already has this function, use it and nuke the code below */
#ifdef noindex
/*
* Return the ptr in sp at which the character c appears;
* NULL if not found
*/
char *index(sp, c)
register char *sp, c;
{
do {
if (*sp == c)
return(sp);
} while (*sp++);
return(NULL);
}
#endif
/* Open a file, aborting on failure */
/* Written by Bernie Roehl, June 1985 */
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;
}
~~~~~~~~~~~~~~~~BOINK.UUE use uudecode on it~~~~~~~~~~~~~~~~~~~~~~~~
begin 777 C:BOINK.PRG
M8!H CJ 8K "8(P K& $*G/SP ($Y!(\ "&X7(\_
M/ 2/SP !#\\ -.35R//SP !$Y.5(\SP (;RP? "9P "HB \ (%(D(
M(\ "'N/SP DY.6(\CP (?(CP (;Y"04/Y APDCG0$ _//__/P$_
M/ '3DY_ ,80 &]"/\
M #9 (>(S_ AYC/\ ( "'H,_S__P (>Q">0 (>I!^0#_@D P
M_ $B,/P =C#\ 2(P_ !$4?D "&R(_D !P AM"/\ "^@ '!A 3>
M(_P % AEB/\ @ (9HC_ 5 "&>(_P " AHB/\ $
M (:8C_ "&J(_P " AKC\\ (_/ !3DU83TJ 9@ !6C Y
M AEM!\ !PR.0 (9I0030\ %]A 0B,#D "&6,CD "&:-#P 7V$ Z(@
M.0 (9XB.0 (:+0N0 (::PO !L.' 1+D "&F1'D "'H0?D -D
M-"@ #8H HQ0P ,4, %" HQ0@ B2.? &$ !Q9,WP #L+P R@ ;SP@
M/ #* !$N0 (:9$>0 (>A!^0 V0T* -B@ "C%# Q0P 8,4( "C%"
M ")(Y\ 80 &TDS? ,D.0 (:[5N0 (:K2N0 (:JRO $ !L#"(\ 0
M $2Y AJK*\ %\ &\@DKP 7P 1('2O !? !$N0 (:I(Y\ 80 &?$S?
M ,C^0 (9X "&6(_D "&B AFB/ AGB/! AHDA T'P '$A!4$%A
M 3(,#D "&>,CD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F'P &6T(8132? 98.C8? 9
M-@1A!DS? #].=4/Y (,T( #-# )@ $4POP H#0 XDC
M?/_XT$$B>0 (>[2P,1\ _E2D'Y B0B!P( !%^0 (H(D3B ( * % ,@ ! ! $ #
M !Y.( @ H > ( * @ +SP "$J8 8O
M/ (6 _/ @3DY<3TYU _ ?L$./P
M'^_^ ' <#^
M '0 < !P ^%YX/L?_/_[@#R >G_^__@
M !]\'SP? #\;W ?#____P.]"WSC_
M^3\' #WQ
M// \#P/_SW,_#____P"Y$X#QA_!X#P P # (
M #KG@>!X'___WO.^#[__O@! ____BIP%H _L Y@ !V $X
M/P!^Y&,<'_P __.'CX!_@ !_W.9\'@/___XI?!D@.>P'&
M !V0&X '\!^)C'>#_X ?_G'F,!WP \__C,^#P'___
M\"4TXTC@W!^X [<"< '_ _ CC^!_
MX ?_SCS!@_^ /__QC/!\#____ BO>&"X'./X'___^ /.,#X/___^ R2O'&\#\/_M 6 #(
M #@ 0 ! =S,/#S__/P#<>,/X ?__^''G\!____ 'C'
M]\#__P_ ,VWPX_ ?#_]8 0 S \ , 0 # "SF'!X__CP
M!^/''\ /___#SS_ ____P!QQO'!\?\/P#-E\./P'P__; J .8 '@
M # $ P 9F,!X!_@X!_'CS^ '___QYX_@?___X \<;P(? ?#^ Q
M=O#Q\ \/_[0 E@#R (X !P # < $S'/\ #P/P_#Q[_ 0#_
M__\\
/'X#___^ #CCN!^X $?_S&[<'CP!X__
M50#-@/R PX = 0 ' #F9QX/P' _____'A\!__
M__ QPS _, #/_\QN0AX^ ?__RF Y,#\0./ &P ( !@ !S,<
M\/P/___\>?#X#P?____AP^ ____@ ,<
'P'___\ #AP!_ #__]AG!^"____@=JP.8C_F/AX
M ; C & '\QQP_ ____PXX//X?_AP!_
M#@X!_O_^ $<. /X ?__^.<'X/___^ S5C$S,?$/#P '9 $ ?[__@ !/'@#^ '___CG!^#____@,VL
MPV+ YC\> !LP"/ 8 ?S''#\#____ CQY_ ?\ /\\'//\#_SP
M SQX _@ !___XYP?@____X#-ML.!P',__P R8!'@,! /]QQP_
M____P!X<_@/^ '_/#S\_ /\_P-X< ?P ___\./$'\ /
M___#G#^#____@,35P\W /S_\ @ .S (\#@,!_\../X'___^ /'C\
M!_P _]X>/@$!_S___#Q#_ #___PQP_ ____P#&V\'&P#\__H @ " $
M#9D$> P' __''#\#____ #AX^ ?X ?_\'#P#P_____Q\8_P@ ___\,
'WX/@?]__#'#\#____ ,;;P<; /S_^@ " ( 0 ;,Q3P# \?
M_PXX_@?___X 'P#_ #__@X> ?'____^'CX.#_'^#_AQQ_ ____P#FRN'&
MX#\?_@ @ " $ &V<78 ^?'W\<>/P'___\ /'A\!_P __X>/@'Q_____C
MX^ ___@'X</@'Q__P !
M , ( R9BX>'_X^ 3CA^!____@ P\/ /\ /__#P\ _/____\?'P#___\
MAQR_ [__?P#F;>'CX!\?_X 0 # " -L8N/A_^/@$PXQ ?'__P ,?'P#_
M #__PX? ?S____^'AX!___^ <'@']_____AX^ ?___@ /' # /__
M .-EX./@'Q__8 @ . $ VS"X\'_P^ V'''_\ /__ CX^ ?X ?_^'AX!_
M?____P^/ '___P #AP!XP ?_^#C9N#AX!\?_\ H #@ ) %LP./#_\/@-C
MAQ^' '__^ \/ /\ /__#P\ ______\/#@#^__X 0X\ ?T __^XR;@X> ?
M'__ * X "0 !7,##P__#P#8X\?@ !___\?'X#_@ #__P\/ /______#QX
M_O_^ $>. 'X ?__^,V(/'@#]__L "0 / B !EG%Q\/_Q\ ^..'X$ ?___
M'A[Q_O !__\>'@'^_____A\> /[__@ !'#@#^ '___C,ASQ_ ___Z D #P
M (@ ;9A<>#_X? ?#CC^! '___SX^__[^ ?__'AX!_O____X>' '\__P SQY
M _@ !___QS,_^/_W\@ ) \ "( "V8''A_^'P'QQX_ 0#___\\//P\_\/\
M/SP< _S____\/CP!_/_\ ,\<0/P ___\8S/@#___X/8 #0 / R IF!AX
M?_AX!\< ?''#\# /___WQ\_ /___P >#B'^/__
M?_@\> /X__@ !WCS!_ #___QF,^'____@!0 @ . #$ "LQ&/!_\'@/ASQ_
M P#___]X>/@'___X 'AX]_C__P_X?'@#^/_X =XXP?@ !___XYG?A____X
M4 T P _ #+,;CP?_#X#XXX?@'CX!___^ #X__[\ = - , /P VS&X\'_P^ ^..'X' ?____#P
M\ ____ \'#P$/ ?#_#X\ ?P__ #_'C#^ '___C&9\'O_^_ '8 #0 # #\
M %'@'^ '__QX?_@#^#P'^/''\ /___&,SX
M//_\^ .@ &@ & #X #9C;>!CX!P?'''\#P/____AX^ ?___@ .'!X#_@ !__
MX>'@X!_@_Q_CSQ_ #___QC-^#S__/@#H !H !@ ^ F9FXA8> ?WQSQ_ \#
M____X>/@'___X ##P\ _P __^/CX! ?\/__PXX_@0!___\8S?@\__SX [
M: 8 /@ *F9F&6'X'_\\X?P? ____\/#P#___\ P\/ /\ /__#P\ \/_S_
M_\>./X$ ?___.8WX?/_\^ .P &@ & #X &LF)QY@_Q_^../X'P?____#Q\ _
M___ ,>'P'_ #__Q\? /S____^'CO^!@'___S&=\'S__/ #0 #0 # \ ;
M-C<.,/\/_CGC&!_G_Q__@X> ?___@ "'AX!_@ !__X>'@']_____CQZ/ ?#_
MC_\QF_!X__CP!T T P / &S8W#C#_#_XYPP8___\!_X>/@'___X CX^
M?X ?_^/CX!_?____X\<@ /__X#_,9OP>/_X\ =@ - , #P #4V$PXP_P_^
M.<<'____ #^'CX!___^ \/ /\ /__#P\ ______\./ 'C__\ 'W&;\'C_
M^/ '8 #0 # \ 5LQ./$'\/_SG'!\?_QP _!P\ ____ ?#P#_ #__Q\?
M /______'C@!^?_Y =C&^#X__C@!V T P / #;,;CQA_!_\YQP? _\
M/P\? /___P 'AX!_@ !__\>'@'^_____AQX _C_^ 'XS,@\#_PX ]@ -
M, #P !V3"X\8?P?_.<<'P/_ #\.'O'^#_[P 3X> ?X ?__'CP!_/____P\
M< /P__ #\,V./$'\/@/@ "@ & X 9FPN'&'\'_SG'!\#_P _#C[__@'^
M_@$\/ /\ /__SP\ _S____\>/$'\/_P _&-CYQ ?#_C\ H !@ . "IL)
MAPA_!_\YQP? _\ /QX\_CP!_/_#?#P#_ #__\\> /X____^''C#^#_X ?
MAF9^$0'P___ * 8 #@ [;!<<,/P/_&<<'P/_ #\/P _S__WAX!_@
M!___>'@'^/____CQPP_ _\ /XQL?!T#_O_]P "@ & X .VP7'##\#_QG&
M!\'_P _''S\ P/___]X>(?X@ ?__WCP!_#____PX\/#_\/@/___P\0_P
M____\,../X'_@ !_&9GX> ?___B ( @ ! 5)!,<$/P/_&<8'P?_ #\<
M>/P' _____#P\/#_#_#_\>$/X/___^#'CC^!_X ?S$S\/$/___P
M@ ';0+C!A\!_YG.A\'_P( _&'#X#P?____QX? ___P'^'#'\#____ AQQ_
M _\ /]C)N#B'_[_X0 VT"XP(? ?^9SH?!_\" /SCQ^ \'____
MX<'@./__X ?CQQ_ ____P(\_@/__?X >./X'_@ !_\3,
MP\0__/_" U0!+ /\ QYG.A\'_P( _..'X'P?____#@\!____
M (>.AX&'_W^ '''\#_P __,F,.(/_C_A %8 #@!^ $&9SH?!
M_\" /S#C\!\/____QX? ?___P "/#H !@/]_ #QS_ _\ /_F;"'D'_P_X@
M !J "8 ?@!AV0/_ _B , 4 #P ,I,R<.X/X?_]AA^!_'____QP\
M _S__ #>.$'X ?___CC!A\^ /__\W /,#_P/P@ !0 <
M!%;DSAS!_S_\8XY@?I__?_X\> /X__@ !_'##\ /___QQP_?/^#_W^;@'F
M_X#X0 ( # +B9&X___\ 38 \@#^ /$
M )4V,P[P_X_^8QP?//\_ /QQYP_@_^ 'X8^?@$!____
M</P' ____^>9X'C_^. 'N !@ !@ _@
M 6I()CGA_1_YF.1X'_@ !_^./GX!_@(!_&//X#P?____.=L'Q__#
M#_ S \ /P "S:!<8\/R/^)CD>!_X ?_'GL>!
M/X#X?S'G\!\/____G,V#P__ @#_ # \ #P 5
M2@3&'#\3_B9S'@_^ '_CSR W\ __]CSN ^'____G.W#X[_@0!_ # ,
MP "FD.YPH?!?\F?_X/__QYS
M?#____SF7AXY_@'OX! ?\YXP?A__[_X8]Y@/A____XG;A\=OP. _X
M U0"# /\ 3RSN'![\ 0/_<\\/P/___\ >Y\'@__\_X#+@
M\=CP. _X #( )@ ^ !$LS!P\_ ,#
M_V<<'P/___\ _<[[P?__!\!MP..@X& ?X
M + T #P $#=A\.!P'X__.9C;VQ?:6YC
MIV8E]S879E ($
M AM&YM.'( @@ +Z>%]V8G5F "! (99Y7W9B=68 ($ A
MFGA?=F)A>5]V8F%S "! (:)V> ($ AIG9Y
M @0 "&J87D "! (:YD%]N;W0R5]N;W0R8FF" EQK8F1?8FQO8X( #7&YM.')?96YD@@
M -*;F]T,FQO "" SQN;W0R:&D (( #1&)I9V)A;&P I CJ
M;6%S:U]M86NB !%AB;VEN:U]B;*( #E'-H861O=U]BH@ /Z8F]I
M;FM?;&^" YIQ=6ET7V)L=(( #^&)L=%]T;W=E@@ .V'1?;&EN@@ 1:9C%?;&]O< ""
M !%QF(9F]R;5]I;F2A
M(D)M87-K7VEN9*$ B@F)A;&Q?9')AH@ <0