[comp.sys.atari.8bit] uudecode revision..

jhs@MITRE-BEDFORD.ARPA.UUCP (02/02/87)

Here is a minor revision of uudecode.  This version IS SUPPOSED to do the
following:

  1.  It should act like the latest former version in that it counts bytes
      and hopefully works OK on 800s as well as 800XLs with or without
      OMNIVIEW.


  2.  If you enter a RETURN for the output file name, it will proceed
      until it has read the "begin" line of the input file.  If it
      finds a normal "begin" line, i.e. one with "begin" and something
      ending with a space followed by a valid filename, it will use
      that name for the output filename.  Otherwise it will either
      ask for a filename again or bomb, depending on its mood.

      Note that this implies you can give it a nonstandard output file name
      or let it use the one on the "begin" line by default.

By popular request, this version is also supposed to ignore header and
trailer comments, e.g. if the file is embedded in a mail message.  It searches
for "begin" before even opening the output file.

Finally, the diagnostics at line 20 have been made a little more helpful.

I made this mod on the VAX and have not tested it on an Atari yet.  But how
could such a simple change have any bugs in it?  (Don't answer that!)
I would appreciate comments from my "Beta Test Site" users on whether the new
features work.

-John S.

Be sure to download with translation to ATASCII character set enable.
(The ASCII Line Feeds have to be translated to EOLs. $9B)

------------c-u-t---h-e-r-e---f-o-r---r-e-v-i-s-e-d---UUDECODE.LST------------
1 GOTO 100:REM jump around time-critical loop to start up program.
2 M=USR(UUDADR)
10 IF M=0 THEN 2090
20 IF M<0 OR M>OBUFDIM THEN ? "Error at line 20 - M=";M;"  BYTES=";BYTES:GOTO 3000
30 PRINT #2;OBUF$;:BYTES=BYTES+M
40 INPUT #1,IBUF$:GOTO 2
100 ? "Uucode Ver. 0.8":? "Report errors to":? "J. Sangster at (617) 235-8753"
101 ? "or jhs@mitre-bedford.arpa":REM Modified to count bytes 1/14/86 - JHS
102 POKE 6,1:REM Temporary fix for improved OMNIVIEW compatibility.
103 REM This version modified to take filename from header in .uue file.
105 DIM OBUF$(80),IBUF$(80),OFILE$(16),IFILE$(16),A$(1)
110 DIM UUDECODE$(400),UUENCODE$(400)
120 UUDADR=ADR(UUDECODE$):UUEADR=ADR(UUENCODE$):IBUF=ADR(IBUF$):OBUF=ADR(OBUF$)
130 OBUFDIM=80:UUDDIM=400
500 REM COMMAND DISPATCHER
520 ? "Encode (E) or Decode (D)";:INPUT A$
530 ? "INPUT FILE";:INPUT IFILE$:IF LEN(IFILE$)=0 THEN 530
540 ? "OUTPUT FILE":INPUT OFILE$:IF A$="E" AND LEN(OBUF$)=0 THEN 540
550 IF A$="E" THEN 1000
560 IF A$="D" THEN 2000
570 SOUND 1,85,12,15:FOR I=1 TO 60:NEXT I:SOUND 1,0,0,0:GOTO 520
1000 GOTO 1100:REM E not done yet
1010 CLOSE #1:OPEN #1,4,0,IFILE$
1020 CLOSE #2:OPEN #2,8,0,OFILE$
1030 L=45:TRAP 1100
1100 ? "UUENCODE NOT IMPLEMENTED YET":END 
2000 ? "LOADING UUDECODE SUBROUTINE..."
2001 RESTORE 4000:POKADR=UUDADR:MAXADR=POKADR+UUDDIM-1:PRGTOP=UUDADR-1
2002 READ X:IF X=255 THEN READ X:IF X=255 THEN 2004
2003 ? "BAD LOAD FILE FOR UUD":END 
2004 READ LO1,HI1,LO2,HI2:BYTES=HI2*256+LO2-(HI1*256+LO1)+1:PRGTOP=PRGTOP+BYTES
2005 IF BYTES<0 OR BYTES>UUDDIM THEN ? "BYTE COUNT ERROR FOR UUD":END 
2006 FOR I=1 TO BYTES:READ X:POKE POKADR,X:POKADR=POKADR+1:IF POKADR>MAXADR THEN ? "UUD STRG OVFLOW!":END 
2007 NEXT I
2008 TRAP 2009:READ LO1,HI1,LO2,HI2:BYTES=256*HI2+LO2-(256*HI1+LO1)+1
2009 PRGTOP=PRGTOP+BYTES:IF LO1<>224 OR HI1<>2 THEN 2006
2010 ? "Beginning uudecode loop..."
2011 IBUF$(1,1)=" ":M=USR(UUDADR,IBUF,OBUF):IF M<>0 THEN ? "Error in initializing UUDECODE! M=";M:? 
2019 CLOSE #1:OPEN #1,4,0,IFILE$
2030 INPUT #1,IBUF$:BYTES=0
2040 TRAP 2095:IF IBUF$(1,5)<>"begin" THEN 2030:REM skip header
2042 ? IBUF$
2044 TRAP 2050:L=LEN(OFILE$):IF L<>0 THEN CLOSE #2:OPEN #2,8,0,OFILE$:GOTO 40
2046 FOR I=L TO 1 STEP -1:IF IBUF$(I,I)=" " THEN OFILE$=IBUF(I+1,L):GOTO 2044
2048 NEXT I
2050 ? "OUTPUT FILENAME":INPUT OFILE$:IF LEN(OFILE$)=0 THEN 2050
2052 GOTO 2044
2090 INPUT #1,IBUF$:IF IBUF$(1,3)="end" THEN PRINT IBUF$:GOTO 3000
2095 NERR=PEEK(195):IF NERR=136 THEN PRINT "Missing 'end' line!":GOTO 3000
2097 ? "Error Code=";NERR
3000 ? "Done!":CLOSE #1:CLOSE #2:? "Output byte count = ";BYTES:END 
4000 DATA 255,255,8,6,3,7
4010 DATA 104,240,67,170,56,233
4020 DATA 2,240,14,104,104,202
4030 DATA 208,251,169,254,133,212
4040 DATA 169,255,133,213,96,104
4050 DATA 141,1,6,104,141,0
4060 DATA 6,104,141,3,6,104
4070 DATA 141,2,6,165,6,240
4080 DATA 100,165,134,133,203,165
4090 DATA 135,133,204,173,2,6
4100 DATA 56,229,140,133,208,173
4110 DATA 3,6,229,141,133,209
4120 DATA 162,128,208,2,240,72
4130 DATA 160,0,177,203,201,129
4140 DATA 208,42,160,2,177,203
4150 DATA 56,229,208,208,33,200
4160 DATA 177,203,229,209,208,26
4170 DATA 165,203,141,6,6,165
4180 DATA 204,141,7,6,160,6
4190 DATA 177,203,141,4,6,200
4200 DATA 177,203,141,5,6,24
4210 DATA 144,22,24,165,203,105
4220 DATA 8,133,203,144,2,230
4230 DATA 204,202,208,192,169,255
4240 DATA 133,212,133,213,96,234
4250 DATA 173,0,6,133,204,173
4260 DATA 1,6,133,205,160,0
4270 DATA 132,213,177,204,56,233
4280 DATA 32,133,212,208,24,165
4290 DATA 6,240,19,173,6,6
4300 DATA 133,208,173,7,6,133
4310 DATA 209,160,4,169,0,145
4320 DATA 208,200,145,208,96,165
4330 DATA 6,240,43,173,4,6
4340 DATA 56,229,212,173,5,6
4350 DATA 229,213,16,9,169,255
4360 DATA 133,212,133,213,32,54
4370 DATA 185,173,6,6,133,208
4380 DATA 173,7,6,133,209,169
4390 DATA 0,160,5,145,208,136
4400 DATA 165,212,145,208,230,204
4410 DATA 208,2,230,205,173,2
4420 DATA 6,133,206,173,3,6
4430 DATA 4,7,102,7,133,207
4440 DATA 166,212,160,1,177,204
4450 DATA 56,233,32,133,203,6
4460 DATA 203,6,203,136,177,204
4470 DATA 56,233,32,6,203,42
4480 DATA 6,203,42,145,206,202
4490 DATA 240,64,169,0,133,208
4500 DATA 160,2,177,204,56,233
4510 DATA 32,74,102,208,74,102
4520 DATA 208,5,203,136,145,206
4530 DATA 202,240,39,160,3,177
4540 DATA 204,56,233,32,5,208
4550 DATA 136,145,206,202,240,24
4560 DATA 24,165,204,105,4,133
4570 DATA 204,144,2,230,205,24
4580 DATA 165,206,105,3,133,206
4590 DATA 144,166,230,207,176,162
4600 DATA 96,224,2,225,2,0

jhs@MITRE-BEDFORD.ARPA.UUCP (02/02/87)

Well, folks...

The "minor revision" to uudecode posted last night has at least two bugs that
I have found.  Please change Line 2046 as shown.  I will post another complete
listing after I have fully debugged it.

2046 L=LEN(IBUF$):FOR I=L TO 1 STEP -1:IF IBUF$(I,I)=" " THEN OFILE$=IBUF$(I+1,L):GOTO 2044
     ^^^^^^^^^^^^^                                                       ^
-John S.