Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!cbosgd!ucbvax!LLL-MFE.ARPA!PSIMON%PPC.MFENET From: PSIMON%PPC.MFENET@LLL-MFE.ARPA Newsgroups: net.micro.atari16 Subject: Fear not, would be UUDECODERS. Message-ID: <8609120159.AA11773@ucbvax.Berkeley.EDU> Date: Thu, 11-Sep-86 21:48:00 EDT Article-I.D.: ucbvax.8609120159.AA11773 Posted: Thu Sep 11 21:48:00 1986 Date-Received: Fri, 12-Sep-86 07:32:38 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 168 No more tears out there in NETLAND for all those inaccessible uuencoded programs. I have written a version of UUDECODE in ST BASIC. The program is included below. How to use -- Simply run this like any other BASIC program. It will prompt for the input file name (the uuencoded file), and the output file name. I have successfully decoded three programs (four files) on my ATARI 1040ST using this program, including UNITERM and microEMACS, which were posted on this BBS. I haven't had any failures yet. Caveats: 1. I had to work around several ST BASIC bugs, some of which are mentioned in the comments to the program. This means that if ST BASIC is updated, or if the bugs are somehow specific to my system, you may have to edit this program to get it to work. 2. The output file name must be specified by the user at the appropriate point. This is unlike "standard" UUDECODE, where the output file name is read from the "begin..." line of the input filename. This is due to problems with the BASIC statement LINE INPUT #. These problems only seem to occur after opening a file. 3. The first line of the UUENCODED file should be the "begin..." line. This first line is ignored. Encoded binary is assumed to begin on the second line. (Also not standard UUDECODE, and also due to the LINE INPUT # bugs.) 4. If your UUENCODED file does not contain exactly 45 encoded bytes per line, then this program will not operate correctly as is. There is no problem here if every line in your encoded file begins with M. Only special case: last line of encoded binary can begin with any character between ! and M (refer to an ascii table). (While this is not "standard", I have run across no exceptions as yet.) 5. The program assumes it has completed if it reads in a line -- which reads "end"; or -- which begins with a space; or -- which is blank. (Only the first of these is standard, but as before, I haven't found any problems yet.) Despite the caveats, I have not had any trouble UUDECODING anything yet. (But, I regret that I cannot assume legal responsibility for any losses incurred by the user.) As far as I know, UUDECODE is public domain. Presumeably, then, this program is also. (Could I really find anyone who'd pay for ThiS?) GOOD LUCK! and let me know how things turn out. -- Patrick Simon September 11, 1986 PSIMON%PPC.MFENET@LLL-MFE.ARPA **********ACKNOWLEDGEMENTS*************************************************** I have to thank John Sangster (jhs@mitre-bedford.ARPA) for providing me with the functional specs of UUDECODE. **********STANDARD DISCLAIMERS, ETC.***************************************** If this program fails to operate as specified, return for a full refund. As with any test(y) program, please exercise appropriate caution in the use of this decode program. In particular, I suggest that if the disk you are using contains the only copy of anything important, you aren't using appropriate caution. Princeton University bears no responsibility for any part of this bulletin. (Is it legal for me to say the same for me?) ---------------------- cut here --------------------------------------- 10 ' UUDECODE PROGRAM 11 ' /* 12 ' * Uudecode -- decode a uuencoded file back to binary form 13 ' * 14 ' * Slightly modified from a version posted to net.sources once; 15 ' * suitable for compilation on an IBM PC. 16 ' * 17 ' * modified for Lattice C on the ST - 11.05.86 by MSD 18 ' * 19 ' * rewritten for ST BASIC on the Atari ST - September 9, 1986, 20 ' * by Patrick Simon 21 ' * 22 ' */ 23 ' Initializations. 24 DIM I(4) 25 FULLW 2 : CLEARW 2 ' Use full output window, clear it. 26 MASK = 63 : SP = ASC(" ") 30 ' Get input filename and open file. 40 INPUT "Enter name of uuencoded file > ", IFILEN$ 50 OPEN "I", #1, IFILEN$ 60 ' Get output filename, open, and set up pointers. 70 INPUT "Enter name of output file > ", OFILEN$ 80 OPEN "R", #2, OFILEN$, 45 90 FIELD #2, 45 AS CBUF$ 110 ' Input and ignore first line of input file (original filename). 120 LINE INPUT #1, INLINE$ ' Due to a bug in ST BASIC, LINE INPUT # 130 LINE INPUT #1, INLINE$ ' must be called 2x, just to get first 140 ' line. Even then we lose the 1st character. 150 ' Now set up screen for user. 160 CLEARW 2 170 GOTOXY 1,2 : PRINT "Decoding "; IFILEN$; " to "; OFILEN$ 180 GOTOXY 1,4 : PRINT "# lines read in: " 190 GOTOXY 1,5 : PRINT "# bytes output: " 200 ' Initialize some variables for main body of program. 210 NUML = 0 : BYTEOUT = 0 220 LINELOOP: ' Now loop for as long as there are input lines. 230 LINE INPUT #1, INLINE$ ' LINE INPUT should work OK by now! 231 IF INLINE$ = "end" THEN GOTO 500 ' All done 232 NUML = NUML + 1 240 ' For each line, must "decode" each byte. 241 ' First byte contains # bytes to ***output*** from this line. 242 ' Then, after decoding, each set of 4 input bytes contains 6*4 = 24 243 ' bits of information to output, 8 bits per output byte, thus 244 ' 3 output bytes. 250 ' Set up string position pointer for INLINE$ 260 SPTR = 1 270 ' Get first byte = # bytes to output; exit if line has zero to output 280 GOSUB DECODE : NN = C : N = NN : IF NN = 0 THEN GOTO 500 285 ' Process one line of input 290 MPTR = 1 300 WHILE N > 0 ' Decode set of 4 input bytes. 310 FOR J = 1 TO 4 320 GOSUB DECODE : I(J) = C 330 NEXT J 340 C1 = ((I(1) * 4) MOD 256) + INT(I(2) / 16) 350 C2 = ((I(2) * 16) MOD 256) + INT(I(3) / 4) 360 C3 = ((I(3) * 64) MOD 256) + I(4) 370 IF N>0 THEN MID$(CBUF$,MPTR,1)=CHR$(C1) : MPTR = MPTR + 1 380 IF N>1 THEN MID$(CBUF$,MPTR,1)=CHR$(C2) : MPTR = MPTR + 1 390 IF N>2 THEN MID$(CBUF$,MPTR,1)=CHR$(C3) : MPTR = MPTR + 1 400 N = N - 3 410 WEND ' If more in this line, go back again. 415 ' Finished processing line. 420 PUT #2, NUML ' Send decoded stuff to output file. 430 BYTEOUT = BYTEOUT + NN ' Show status to user. 440 GOTOXY 20,4 : PRINT NUML 445 GOTOXY 20,5 : PRINT BYTEOUT 450 GOTO LINELOOP ' Get next line ... 500 ' Hopefully, we have now decoded the input file. 510 CLOSE #1 : CLOSE #2 520 END 1000 DECODE: ' Subroutine to decode a single character 1010 IF LEN(MID$(INLINE$,SPTR)) = 0 THEN INLINE$ = INLINE$ + " " 1020 CH$ = MID$(INLINE$, SPTR, 1) : SPTR = SPTR + 1 1030 C = (ASC(CH$) - SP) AND MASK 1040 RETURN