home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
uuencdec.zip
/
MANUAL
next >
Wrap
Text File
|
1987-08-26
|
7KB
|
182 lines
UUENCODE, UUDECODE
Filters used to send binary documents via NetMail, by converting 3 binary bytes
into 4 printable ASCII bytes.
Unix Author: Mark Horton
MSDOS Author: Keith Gregory (complete rewrite)
This program set was written to follow conventions established in the Unix
community.
This source code/manual is hereby placed into the public domain by the author,
who accepts no responsibility for anything that might happen to you or anyone
else from its use (what do you expect for nothing, a RRRRRRubbber Biscuit?).
Redistibution of this program MUST include full source code and this manual.
If you only receive the executables, then you should probably be wary (as a
hint, the original sizes: UUENCODE = 18064, UUDECODE = 18160).
This code compiles with Lattice C, Version 3.1. It has not been tested for
compilability with any other compiler (but Turbo-C should work OK, as I use
its reference manual for looking up system calls).
*******************************************************************************
*******************************************************************************
Part I - Usage
-------------------------------------------------------------------------------
uuencode [-options] [inputfile]
This program takes an optional input file, encodes it into printable ASCII
characters, adds header information which is acceptable to Un*x versions, and
outputs the encoded file to Standard Output. If an input file is not specified
then input will be taken from Standard Input, and the name "UUENCODE.000" will
be stored in the encoded file.
One option is currently defined:
-Mnnn Specify file mode.
This is used for exchange with Un*x systems only, where the
user wants to specify permission codes for the destination.
Normally, files are stored with a permission code for User
Read/Write, Group Read, and nothing for World. If the user
desires something different, then the desired protection code
should be specified as a three-digit octal number.
-------------------------------------------------------------------------------
uudecode [inputfile]
This program is the counterpart to UUENCODE. It reads the input file, removes
any header or trailer information (which would be added by some mail systems),
and converts the encoded file back into binary.
The input file is optional. If it exists, it will be used. If it does not
exist or is not specified, then input will be taken from Standard Input. The
name of the output file is encoded with the file's data. If the output file
already exists, then UUDECODE will not overwrite the existing file - it will
abort. [Note - this may cause problems when reading files from Standard Input,
where the original text is not retrievable].
*******************************************************************************
Part II - Bugs / Future Features
-------------------------------------------------------------------------------
The Unix version of UUENCODE/UUDECODE allows a user to be specified with
the filename. This is designed for use with mail systems, where the
reciever (UUDECODE) must place encoded files into their proper accounts.
Since MS-DOS doesn't have any idea of what a user is, this won't work.
If a file is specified in this format, the user portion will be removed.
At this time, fill pathnames will not be used by either UUENCODE or
UUDECODE. In a future release they will be. Currently, UUENCODE will
trim any path specification from the name that is stored into the encoded
file - however the user may specify a complete path for file access.
UUDECODE will also trim pathnames for output - all output files will be
placed in the current directory (this may be used to get around the
problem mentioned above). Note that UUDECODE will only trim Unix-style
pathnames (which use / instead of \). Since UUENCODE does not store paths,
trimming DOS-style pathnames was not considered necessary.
Currently, the mode stored bears no relationship to the DOS file, it is
strictly for Unix compatibility. UUENCODE stores a likely mode (User Read/
Write, Group/World Read), and UUDECODE ignores the mode completely. In a
future release, UUENCODE will store the file's current read/write status,
and UUDECODE will set the read/write status based on the Unix-style mode.
*******************************************************************************
Part III - Format
-------------------------------------------------------------------------------
1 - An encoded file is made up of the following parts
__header_lines__
begin _mode_ _name_
_encoded_lines_
end
__trailer_lines__
------------------------------------------------------------------------
Header and trailer lines are optional - they may be tacked onto the file
by mail software.
"begin" line contains the name of the destination file and its mode (in
octal). If the filename starts with a tilde (~), it is composed of a
user/filename combination (in form "~user/filename"), and UUDECODE (on
Unix systems, at least) will place the file in the proper directory.
Encoded lines are explained below.
"end" line signifies the end of the encoded file.
2 - Encoded lines contain a size byte, followed by data bytes. All bytes are
encoded as printable ASCII characters. This means that each byte may
contain no more than 6 bits of information.
6_bit_value + ASC(' ') = 7_bit_value, printable ASCII
3 - Since each encoded byte contains 6 bits of information, the file will grow,
since four 6-bit bytes are needed to contain the information from 3 8-bit
bytes. The conversion is as follows:
A = Input Byte #1
B = Input Byte #2
C = Input Byte #3
D = Output Byte #1
E = Output Byte #2
F = Output Byte #3
G = Output Byte #4
D = High order 6 bits of A in bits 0..5
E = Low order 2 bits of A in bits 4..5
High order 4 bits of B in bits 0..3
F = Low order 4 bits of B in bits 2..5
High order 2 bits of C in buts 0..1
G = Low order 6 bits of C in bits 0..5
4 - Sample Conversion
Input Line -- "This is a test"
Output Line - ".5&AI<R!I<R!A('1E<W0"
"." - Length, 14 (32 + 14 = 46 = ".")
"5&AI" - "Thi"
Bit Numbers: 76543210 76543210 76543210 76543210
Encoded Bits: 00110101 00100110 01000001 01001001
Convrtd Bits: 00010101 00000110 00100001 00101001
Decoded Bits: 01010100 01101000 01101001
Decoded Text: T h i
.
.
.