From: mathew <mathew@mantis.co.uk>
Newsgroups: comp.bbs.waffle
Subject: Re: Waffle icon needed
Date: Mon, 11 Jan 93 15:38:54 GMT
Organization: Mantis Consultants, Cambridge. UK.
X-Newsreader: rusnews v0.98

bob@1776.COM (Robert Coe) writes:
> This reminds me of something I've been wondering about: how does one get the
> program that reassembles uuencoded files?  Obviously someone can't just mail
> you a uuencoded version of the program!  (Well, they could, but what could
> you do with it?)

Here's something I saved a while back...  Richard Marks' package is now up to
uuexe515.zip.

From: halcyon!ralphs@seattleu.edu
Newsgroups: alt.bbs.waffle
Date: 14 Sep 91 15:22:41 GMT

bobk@dogear.spk.wa.us (Bob Kirkpatrick) writes:

> It exists for most platforms there are. I'd send it to you, but I'd
> have to encode it, and you obviously don't have it to decode it. ;-)

Well!  (I've removed part of this for brevity's sake)...  Also, I'd
recommend getting Richard Mark's uuexe413 package which makes it
unnecessary to remove extraneous text (such as found in messages).

		1) Instructions
		2) BASIC source to create UUDECODE.COM
		3) DEBUG script to create UUDECODE.COM
		4) C source for UUDECODE
		5) Documentation for UUDECODE

You will need:

		1) GW-BASIC or DEBUG (from MS-DOS)
		2) File editor

What to do:

You will need to split this file into 5 parts. Each part is separated by a
line stating "---CUT HERE---" and a short description. Using a text editor,
separate the parts for the BASIC and DEBUG sources.
If you have a GW-BASIC interpreter, run the UUDECODE.BAS program, which will
create UUDECODE.COM. If you have the MS-DOS DEBUG program, create
UUDECODE.COM by saving the DEBUG script below as UUDECODE.DBG and feeding it
to DEBUG by giving the command

		DEBUG < UUDECODE.DBG

This will create UUDECODE.COM. You can alternately compile UUDECODE.C.

---CUT HERE--- Save as UUDECODE.BAS and run under GW-BASIC
100 REM - BASIC PROGRAM TO CREATE UUDECODE.COM v2.0 (a fast uudecoder)
105 REM UUDECODE.BAS created by w8sdz@WSMR-SIMTEL20.ARMY.MIL (Keith Petersen)
110 CLS:PRINT "Creating UUDECODE.COM.  See UUDECODE.DOC for instructions."
115 OPEN "UUDECODE.COM" AS #1 LEN = 1
120 FIELD #1, 1 AS A$: CHECKSUM#=0
130 FOR I = 1 TO    73
140  LINESUM#=0: LOCATE 2,3: PRINT "Countdown: "    73 - I ;
150  FOR J = 1 TO  16: READ BYTE$: CHECKSUM#=CHECKSUM#+VAL("&H"+BYTE$)
160   LINESUM#=LINESUM#+VAL("&H"+BYTE$)
170   IF (BYTE < 256) THEN LSET A$=CHR$(VAL("&H"+BYTE$)): PUT #1
180  NEXT J
190  READ LINETOT$: LINECHECK# = VAL("&H"+LINETOT$)
200  IF LINECHECK# = LINESUM# THEN GOTO 220
210  LOCATE 4,2: PRINT "Error in line #"  ;  260 +  10 * I: GOTO 260
220 NEXT I
230 CLOSE: READ FILETOT$ : FILECHECK# = VAL(FILETOT$)
240 IF CHECKSUM# <> FILECHECK# THEN GOTO 260
250 PRINT: PRINT "UUDECODE.COM created successfully": SYSTEM
260 PRINT: PRINT "UUDECODE.COM is not valid!": END
270 DATA EB,5F,90,49,6E,70,75,74,20,66,69,6C,65,20,65,72,  6A1
280 DATA 72,6F,72,2E,4F,75,74,70,75,74,20,66,69,6C,65,20,  5F2
290 DATA 65,72,72,6F,72,2E,73,74,61,72,74,20,6E,6F,74,20,  617
300 DATA 66,6F,75,6E,64,2E,45,6E,64,20,6E,6F,74,20,66,6F,  5C7
310 DATA 75,6E,64,2E,20,65,78,69,73,74,73,2E,20,41,62,6F,  595
320 DATA 72,74,69,6E,67,21, 0, 0, 0, 0,AC, 3,AC, 3,5C, 3,  402
330 DATA  0,E8,FA, 1,E8,54, 1,BF,5C, 3,E8,D1, 0,AD,3D,62,  743
340 DATA 65,75,F4,AD,3D,67,69,75,EE,AD,3D,6E,20,75,E8,BF,  87F
350 DATA 5C, 3,B4,20,AC,3A,C4,76,FB,AC,3A,C4,75,FB,AC,3A,  84E
360 DATA C4,76,FB,3A,C4,74, 4,AA,AC,EB,F8,BA,5C, 3,33,C9,  8F9
370 DATA 88, D,80,3E,60, 1,FF,74,1E,B4,4E,CD,21,3C, 2,74,  5E7
380 DATA 16,3C,12,74,12,8B,CF,2B,CA,E8,2F, 1,BA,44, 1,B9,  609
390 DATA 12, 0,B0, 5,E9,16, 1,B4,3C,CD,21,73, 3,E9,E3, 0,  5E7
400 DATA A3,58, 1,BF,5C, 3,E8,65, 0,AC, A,C0,74,48,BB,20,  674
410 DATA 20,2A,C3, A,C0,74,3F,32,E4,8B,E8,B9, 4, 6,AC,8A,  70C
420 DATA E0,AC,8A,D0,2B,C3,D0,E4,D0,E4,D2,E8, A,C4,AA,4D,  ABB
430 DATA 74,D4,8A,E2,AC,8A,D0,2B,C3,D2,E4,D0,E8,D0,E8, A,  AD8
440 DATA C4,AA,4D,74,C1,8A,E2,AC,2B,C3,8A,CD,D2,E4, A,C4,  9D1
450 DATA AA,4D,75,C7,EB,B0,E8,15, 0,AD,3D,65,6E,75, 5,AC,  7AE
460 DATA 3C,64,74, 3,E8,AE, 0,E8,61, 0,B4,4C,CD,21,8B,36,  6A5
470 DATA 5A, 1,89,3E,5E, 1,BD,50, 0,BF, C, 3,33,C0,AB,B9,  5B3
480 DATA 27, 0,B8,20,20,F3,AB,BF, C, 3,3B,36,5C, 1,72, 6,  4D1
490 DATA E8,38, 0,E8,55, 0,AC,3C,60,75, 4,B0,20,EB, 8,3C,  61D
500 DATA  D,74,1B,3C, A,74,18,AA,4D,75,DF,3B,36,5C, 1,72,  4F9
510 DATA  3,E8,37, 0,AC,3C, A,75,F2,BF,5C, 3,EB,B4,46,89,  707
520 DATA 36,5A, 1,8B,3E,5E, 1,BE, C, 3,C3,BA,5C, 3,8B,CA,  5B7
530 DATA 87, E,5E, 1,2B,CA,76, A,8B,1E,58, 1,B4,40,CD,21,  54D
540 DATA 72, 1,C3,BA,14, 1,B9,12, 0,EB,22,BA,AC, 3,B9,54,  653
550 DATA FA,8B,1E,56, 1,B4,3F,CD,21,72, C, B,C0,74, 8,8B,  62B
560 DATA F2, 3,C6,A3,5C, 1,C3,BA, 3, 1,B9,11, 0,50,E8, A,  648
570 DATA  0,58,E9,55,FF,BA,36, 1,B9, E, 0,52,51,BA,3E, 3,  5EB
580 DATA B9, 2, 0,90,E8, C, 0,59,5A,E8, 7, 0,BA,3E, 3,B9,  595
590 DATA  2, 0,90,BB, 2, 0,B4,40,CD,21,C3,90, D, A,54,68,  557
600 DATA 69,73,20,50,72,6F,67,72,61,6D,20,52,65,71,75,69,  5FA
610 DATA 72,65,73,20,44,4F,53,20,56,65,72,73,69,6F,6E,20,  576
620 DATA 32,2E,30,20,6F,72,20,68,69,67,68,65,72,2E, D, A,  46D
630 DATA 24, D, A,49,6E,70,75,74,20,70,61,74,68,2F,66,69,  516
640 DATA 6C,65,3A,20,20,4E,6F,20,61,63,74,69,6F,6E,B4,30,  58A
650 DATA CD,21,3C, 2,73, C,BA, C, 3,B4, 9,CD,21,B8, 1,4C,  524
660 DATA CD,21,E8,46, 0,73,33,BA,68, 4,B9,1B, 1,90,E8,6A,  69F
670 DATA FF,BA,41, 3,B9,14, 0,BB, 2, 0,B4,40,CD,21,BF,7F,  6A7
680 DATA  0,C6, 5,50,8B,D7,B4, A,CD,21,E8,1E, 0,73, B,BA,  667
690 DATA 55, 3,B9, 9, 0,B0, 1,E9,33,FF,BA, 4, 4,B8, 0,3D,  59D
700 DATA CD,21,72, 4,A3,56, 1,C3,E9,1C,FF,BE,80, 0,BF, 4,  726
710 DATA  4,FC,AC, A,C0,74,2F,B4,20,AC,3A,C4,76,FB,3A,C4,  806
720 DATA 76,26,3C,2F,74, 4,3C,2D,75,18,8B,D0,8B, 4,3C,3F,  4DA
730 DATA 74,1B,24,5F,3D,4F,20,8B,C2,75, 7,F6,16,60, 1,46,  53A
740 DATA 46,AC,AA,AC,EB,D8,F9,C3,C6, 5, 0,F8,C3,BA,68, 4,  973
750 DATA E9,66,FF,90,55,55,44,45,43,4F,44,45,20,76,32,2E,  622
760 DATA 30, 0,4F,72,69,67,69,6E,61,6C,6C,79,20,62,79,20,  565
770 DATA 54,68,65,6F,64,6F,72,65,20,41,2E,20,4B,61,6C,64,  565
780 DATA 69,73, 0,54,68,6F,72,6F,75,67,68,6C,79,20,72,65,  608
790 DATA 68,61,63,6B,65,64,20,62,79,20,44,61,76,69,64,20,  583
800 DATA 50,20,4B,69,72,73,63,68,62,61,75,6D,2C,20,54,6F,  588
810 DATA 61,64,20,48,61,6C,6C, 0,55,55,44,45,43,4F,44,45,  4B4
820 DATA 20,5B,2D,3F,5D,5B,2D,6F,5D,20,5B,64,3A,5D,5B,5C,  4C5
830 DATA 70,61,74,68,5C,5D,62,69,6E,61,72,79,2E,55,55,45,  608
840 DATA 20,3C,52,45,54,55,52,4E,3E, D, A,55,73,69,6E,67,  497
850 DATA 20,74,68,65,20,66,69,6C,65,6E,61,6D,65,2E,74,79,  5DD
860 DATA 70,20,69,6E,20,74,68,65,20,22,62,65,67,69,6E,22,  531
870 DATA 20,6C,69,6E,65,2C, D, A,70,72,6F,64,75,63,65,73,  570
880 DATA 20,75,75,64,65,63,6F,64,65,64,20,66,69,6C,65,6E,  600
890 DATA 61,6D,65,2E,74,79,70,20,6F,6E,20,63,75,72,72,65,  5FC
900 DATA 6E,74,20,64,72,69,76,65,5C,70,61,74,68, D, A,28,  564
910 DATA 70,72,6F,76,69,64,69,6E,67,20,66,69,6C,65,6E,61,  661
920 DATA 6D,65,2E,74,79,70,20,64,6F,65,73,6E,27,74,20,61,  5B2
930 DATA 6C,72,65,61,64,79,20,65,78,69,73,74,29,2E, D, A,  53C
940 DATA 2D,6F,20,73,77,69,74,63,68,20,66,6F,72,63,65,73,  5F0
950 DATA 20,6F,76,65,72,77,72,69,74,65,20,6F,66,20,65,78,  5F9
960 DATA 69,73,74,69,6E,67,20,66,69,6C,65,6E,61,6D,65,2E,  61D
970 DATA 74,79,70, D, A,2D,3F,20,70,72,6F,64,75,63,65,73,  565
980 DATA 20,74,68,69,73,20,68,65,6C,70,20,6D,65,73,73,61,  5DA
990 DATA 67,65,2E, D, A,24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  135
1000 DATA 114365
---CUT HERE--- Save as UUDECODE.DBG and feed to DEBUG
e 0100
EB 5F 90 49 6E 70 75 74 20 66 69 6C 65 20 65 72
e 0110
72 6F 72 2E 4F 75 74 70 75 74 20 66 69 6C 65 20
e 0120
65 72 72 6F 72 2E 73 74 61 72 74 20 6E 6F 74 20
e 0130
66 6F 75 6E 64 2E 45 6E 64 20 6E 6F 74 20 66 6F
e 0140
75 6E 64 2E 20 65 78 69 73 74 73 2E 20 41 62 6F
e 0150
72 74 69 6E 67 21 00 00 00 00 AC 03 AC 03 5C 03
e 0160
00 E8 FA 01 E8 54 01 BF 5C 03 E8 D1 00 AD 3D 62
e 0170
65 75 F4 AD 3D 67 69 75 EE AD 3D 6E 20 75 E8 BF
e 0180
5C 03 B4 20 AC 3A C4 76 FB AC 3A C4 75 FB AC 3A
e 0190
C4 76 FB 3A C4 74 04 AA AC EB F8 BA 5C 03 33 C9
e 01A0
88 0D 80 3E 60 01 FF 74 1E B4 4E CD 21 3C 02 74
e 01B0
16 3C 12 74 12 8B CF 2B CA E8 2F 01 BA 44 01 B9
e 01C0
12 00 B0 05 E9 16 01 B4 3C CD 21 73 03 E9 E3 00
e 01D0
A3 58 01 BF 5C 03 E8 65 00 AC 0A C0 74 48 BB 20
e 01E0
20 2A C3 0A C0 74 3F 32 E4 8B E8 B9 04 06 AC 8A
e 01F0
E0 AC 8A D0 2B C3 D0 E4 D0 E4 D2 E8 0A C4 AA 4D
e 0200
74 D4 8A E2 AC 8A D0 2B C3 D2 E4 D0 E8 D0 E8 0A
e 0210
C4 AA 4D 74 C1 8A E2 AC 2B C3 8A CD D2 E4 0A C4
e 0220
AA 4D 75 C7 EB B0 E8 15 00 AD 3D 65 6E 75 05 AC
e 0230
3C 64 74 03 E8 AE 00 E8 61 00 B4 4C CD 21 8B 36
e 0240
5A 01 89 3E 5E 01 BD 50 00 BF 0C 03 33 C0 AB B9
e 0250
27 00 B8 20 20 F3 AB BF 0C 03 3B 36 5C 01 72 06
e 0260
E8 38 00 E8 55 00 AC 3C 60 75 04 B0 20 EB 08 3C
e 0270
0D 74 1B 3C 0A 74 18 AA 4D 75 DF 3B 36 5C 01 72
e 0280
03 E8 37 00 AC 3C 0A 75 F2 BF 5C 03 EB B4 46 89
e 0290
36 5A 01 8B 3E 5E 01 BE 0C 03 C3 BA 5C 03 8B CA
e 02A0
87 0E 5E 01 2B CA 76 0A 8B 1E 58 01 B4 40 CD 21
e 02B0
72 01 C3 BA 14 01 B9 12 00 EB 22 BA AC 03 B9 54
e 02C0
FA 8B 1E 56 01 B4 3F CD 21 72 0C 0B C0 74 08 8B
e 02D0
F2 03 C6 A3 5C 01 C3 BA 03 01 B9 11 00 50 E8 0A
e 02E0
00 58 E9 55 FF BA 36 01 B9 0E 00 52 51 BA 3E 03
e 02F0
B9 02 00 90 E8 0C 00 59 5A E8 07 00 BA 3E 03 B9
e 0300
02 00 90 BB 02 00 B4 40 CD 21 C3 90 0D 0A 54 68
e 0310
69 73 20 50 72 6F 67 72 61 6D 20 52 65 71 75 69
e 0320
72 65 73 20 44 4F 53 20 56 65 72 73 69 6F 6E 20
e 0330
32 2E 30 20 6F 72 20 68 69 67 68 65 72 2E 0D 0A
e 0340
24 0D 0A 49 6E 70 75 74 20 70 61 74 68 2F 66 69
e 0350
6C 65 3A 20 20 4E 6F 20 61 63 74 69 6F 6E B4 30
e 0360
CD 21 3C 02 73 0C BA 0C 03 B4 09 CD 21 B8 01 4C
e 0370
CD 21 E8 46 00 73 33 BA 68 04 B9 1B 01 90 E8 6A
e 0380
FF BA 41 03 B9 14 00 BB 02 00 B4 40 CD 21 BF 7F
e 0390
00 C6 05 50 8B D7 B4 0A CD 21 E8 1E 00 73 0B BA
e 03A0
55 03 B9 09 00 B0 01 E9 33 FF BA 04 04 B8 00 3D
e 03B0
CD 21 72 04 A3 56 01 C3 E9 1C FF BE 80 00 BF 04
e 03C0
04 FC AC 0A C0 74 2F B4 20 AC 3A C4 76 FB 3A C4
e 03D0
76 26 3C 2F 74 04 3C 2D 75 18 8B D0 8B 04 3C 3F
e 03E0
74 1B 24 5F 3D 4F 20 8B C2 75 07 F6 16 60 01 46
e 03F0
46 AC AA AC EB D8 F9 C3 C6 05 00 F8 C3 BA 68 04
e 0400
E9 66 FF 90 55 55 44 45 43 4F 44 45 20 76 32 2E
e 0410
30 00 4F 72 69 67 69 6E 61 6C 6C 79 20 62 79 20
e 0420
54 68 65 6F 64 6F 72 65 20 41 2E 20 4B 61 6C 64
e 0430
69 73 00 54 68 6F 72 6F 75 67 68 6C 79 20 72 65
e 0440
68 61 63 6B 65 64 20 62 79 20 44 61 76 69 64 20
e 0450
50 20 4B 69 72 73 63 68 62 61 75 6D 2C 20 54 6F
e 0460
61 64 20 48 61 6C 6C 00 55 55 44 45 43 4F 44 45
e 0470
20 5B 2D 3F 5D 5B 2D 6F 5D 20 5B 64 3A 5D 5B 5C
e 0480
70 61 74 68 5C 5D 62 69 6E 61 72 79 2E 55 55 45
e 0490
20 3C 52 45 54 55 52 4E 3E 0D 0A 55 73 69 6E 67
e 04A0
20 74 68 65 20 66 69 6C 65 6E 61 6D 65 2E 74 79
e 04B0
70 20 69 6E 20 74 68 65 20 22 62 65 67 69 6E 22
e 04C0
20 6C 69 6E 65 2C 0D 0A 70 72 6F 64 75 63 65 73
e 04D0
20 75 75 64 65 63 6F 64 65 64 20 66 69 6C 65 6E
e 04E0
61 6D 65 2E 74 79 70 20 6F 6E 20 63 75 72 72 65
e 04F0
6E 74 20 64 72 69 76 65 5C 70 61 74 68 0D 0A 28
e 0500
70 72 6F 76 69 64 69 6E 67 20 66 69 6C 65 6E 61
e 0510
6D 65 2E 74 79 70 20 64 6F 65 73 6E 27 74 20 61
e 0520
6C 72 65 61 64 79 20 65 78 69 73 74 29 2E 0D 0A
e 0530
2D 6F 20 73 77 69 74 63 68 20 66 6F 72 63 65 73
e 0540
20 6F 76 65 72 77 72 69 74 65 20 6F 66 20 65 78
e 0550
69 73 74 69 6E 67 20 66 69 6C 65 6E 61 6D 65 2E
e 0560
74 79 70 0D 0A 2D 3F 20 70 72 6F 64 75 63 65 73
e 0570
20 74 68 69 73 20 68 65 6C 70 20 6D 65 73 73 61
e 0580
67 65 2E 0D 0A 24

r cx
0486
n uudecode.com
w
q
---CUT HERE--- Save as UUDECODE.C and compile
/*
 * 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.
 *
 * Modifed 13 February 1991 by Greg Roelofs for use on VMS systems.  As
 * with the MS-DOS version, the setting of the file mode has been disabled.
 * Compile and link normally (but note that the shared-image link option
 * produces a binary only 6 blocks long, as opposed to the 137-block one
 * produced by an ordinary link).  To set up the VMS symbol to run the
 * program ("run uudecode filename" won't work), do:
 *		uudecode :== "$disk:[directory]uudecode.exe"
 * and don't forget the leading "$" or it still won't work.  The binaries
 * produced by this program are in VMS "stream-LF" format; this makes no
 * difference to VMS when running decoded executables, nor to VMS unzip,
 * but other programs such as zoo or arc may or may not require the file
 * to be "BILFed" (or "unBILFed" or whatever).  Also, unlike the other
 * flavors, VMS files don't get overwritten (a higher version is created).
 */

#ifndef lint
static char sccsid[] = "@(#)uudecode.c	5.5 (Berkeley) 7/6/88";
#endif /* not lint */

#ifdef __MSDOS__        /* For Turbo C */
#define MSDOS 1
#endif

/*
 * uudecode [input]
 *
 * create the specified file, decoding as you go.
 * used with uuencode.
 */
#include <stdio.h>

#ifdef VMS
#  include <types.h>
#  include <stat.h>
#else
#  ifndef MSDOS            /* i.e., UNIX */
#    include <pwd.h>
#  endif
#  include <sys/types.h>   /* MSDOS or UNIX */
#  include <sys/stat.h>
#endif

/* single-character decode */
#define DEC(c)	(((c) - ' ') & 077)

main(argc, argv)
char **argv;
{
	FILE *in, *out;
	int mode;
	char dest[128];
	char buf[80];

	/* optional input arg */
	if (argc > 1) {
		if ((in = fopen(argv[1], "r")) == NULL) {
			perror(argv[1]);
			exit(1);
		}
		argv++; argc--;
	} else
		in = stdin;

	if (argc != 1) {
		printf("Usage: uudecode [infile]\n");
		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;
	}
	(void)sscanf(buf, "begin %o %s", &mode, dest);

#if !defined(MSDOS) && !defined(VMS)	/* i.e., UNIX */
	/* handle ~user/file format */
	if (dest[0] == '~') {
		char *sl;
		struct passwd *getpwnam();
		struct passwd *user;
		char dnbuf[100], *index(), *strcat(), *strcpy();

		sl = index(dest, '/');
		if (sl == NULL) {
			fprintf(stderr, "Illegal ~user\n");
			exit(3);
		}
		*sl++ = 0;
		user = getpwnam(dest+1);
		if (user == NULL) {
			fprintf(stderr, "No such user as %s\n", dest);
			exit(4);
		}
		strcpy(dnbuf, user->pw_dir);
		strcat(dnbuf, "/");
		strcat(dnbuf, sl);
		strcpy(dest, dnbuf);
	}
#endif	/* !defined(MSDOS) && !defined(VMS) */

	/* create output file */
#ifdef MSDOS
	out = fopen(dest, "wb");	/* Binary file */
#else
	out = fopen(dest, "w");
#endif
	if (out == NULL) {
		perror(dest);
		exit(4);
	}
#if !defined(MSDOS) && !defined(VMS)	/* i.e., UNIX */
	chmod(dest, mode);
#endif

	decode(in, out);

	if (fgets(buf, sizeof buf, in) == NULL || strcmp(buf, "end\n")) {
		fprintf(stderr, "No end line\n");
		exit(5);
	}
	exit(0);
}

/*
 * copy from in to out, decoding as you go along.
 */
decode(in, out)
FILE *in;
FILE *out;
{
	char buf[80];
	char *bp;
	int n;

	for (;;) {
		/* for each input line */
		if (fgets(buf, sizeof buf, in) == NULL) {
			printf("Short file\n");
			exit(10);
		}
		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 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);
}

/*
 * Return the ptr in sp at which the character c appears;
 * NULL if not found
 */

#define	NULL	0

char *
index(sp, c)
register char *sp, c;
{
	do {
		if (*sp == c)
			return(sp);
	} while (*sp++);
	return(NULL);
}

---CUT HERE--- Save as UUDECODE.DOC and read

			UUDECODE.DOC
   by David Kirschbaum <kirsch%maxemail@peo-mis-emh1.army.mil>

UUDECODE uudecodes uuencoded files to original binary form.  It is
compatible with the Unix (and other) uuencode/uudecode utilities.

Usage:

          UUDECODE<RETURN>
    Displays usage message, prompts for input file name.

          UUDECODE [-o ][d:][\path\]filename.uue
    Produces a uudecoded file, with the filename taken from
    within the uuencoded file (which might include a path),
    (provided the filename doesn't exist.  Use the "-o"
    (or "/o") switch to force overwriting of any existing
    output file.)

          UUDECODE /?  (or -?)
    Writes a brief help screen to STDOUT and terminates.

Notes:

UUDECODE checks for existing files with the same name as the newly
created output file.  It will produce an error message and abort if it
finds one!  (Use the "-o" switch to force overwriting existing files.)

UUDECODE will accept an input path\filename up to 80 chars long, and will
prompt if none is specified.

A uudecoded filename is taken from the uuencoded source file and is
written to the current directory (or to the path included in the file
header).

Input files may be any length.

Uuencoded file headers (mailing headers, etc.) need not be removed.
However, any spurious lines between the "begin" and "end" lines MUST
be removed.

Anything beyond the "end" line is ignored.  If no "end" is found, the
output file is saved, but an error message is displayed.

Certain uuencoders append a "checksum" character to the end of each
uuencoded line.  UUDECODE ignores these.

Uuencoded files generated or moved through a Unix system may have LF
(ASCII 10) line endings instead of the DOS-convention CR/LF (ASCII
13/10) endings.  UUDECODE will handle those LF ends of line as well.
you MAY get a "end not found" message, but the uudecoded file will be
intact.

Certain systems and mailers will strip off trailing spaces on lines.
UUDECODE attempts to replace them.


mathew