xref: /minix3/usr.bin/uuencode/uuencode.5 (revision 2fde3a4846bf5ff2e91c001c8718329d949fe938)
1*2fde3a48SSky Liu.\"	$NetBSD: uuencode.5,v 1.11 2008/08/25 09:36:24 wiz Exp $
2*2fde3a48SSky Liu.\"
3*2fde3a48SSky Liu.\" Copyright (c) 1989, 1991, 1993
4*2fde3a48SSky Liu.\"	The Regents of the University of California.  All rights reserved.
5*2fde3a48SSky Liu.\"
6*2fde3a48SSky Liu.\" Redistribution and use in source and binary forms, with or without
7*2fde3a48SSky Liu.\" modification, are permitted provided that the following conditions
8*2fde3a48SSky Liu.\" are met:
9*2fde3a48SSky Liu.\" 1. Redistributions of source code must retain the above copyright
10*2fde3a48SSky Liu.\"    notice, this list of conditions and the following disclaimer.
11*2fde3a48SSky Liu.\" 2. Redistributions in binary form must reproduce the above copyright
12*2fde3a48SSky Liu.\"    notice, this list of conditions and the following disclaimer in the
13*2fde3a48SSky Liu.\"    documentation and/or other materials provided with the distribution.
14*2fde3a48SSky Liu.\" 3. Neither the name of the University nor the names of its contributors
15*2fde3a48SSky Liu.\"    may be used to endorse or promote products derived from this software
16*2fde3a48SSky Liu.\"    without specific prior written permission.
17*2fde3a48SSky Liu.\"
18*2fde3a48SSky Liu.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19*2fde3a48SSky Liu.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*2fde3a48SSky Liu.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*2fde3a48SSky Liu.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22*2fde3a48SSky Liu.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23*2fde3a48SSky Liu.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24*2fde3a48SSky Liu.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25*2fde3a48SSky Liu.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26*2fde3a48SSky Liu.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27*2fde3a48SSky Liu.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28*2fde3a48SSky Liu.\" SUCH DAMAGE.
29*2fde3a48SSky Liu.\"
30*2fde3a48SSky Liu.\"	@(#)uuencode.format.5	8.2 (Berkeley) 1/12/94
31*2fde3a48SSky Liu.\"
32*2fde3a48SSky Liu.Dd April 9, 1997
33*2fde3a48SSky Liu.Dt UUENCODE 5
34*2fde3a48SSky Liu.Os
35*2fde3a48SSky Liu.Sh NAME
36*2fde3a48SSky Liu.Nm uuencode
37*2fde3a48SSky Liu.Nd format of an encoded uuencode file
38*2fde3a48SSky Liu.Sh DESCRIPTION
39*2fde3a48SSky LiuFiles output by
40*2fde3a48SSky Liu.Xr uuencode 1
41*2fde3a48SSky Liuconsist of a header line,
42*2fde3a48SSky Liufollowed by a number of body lines,
43*2fde3a48SSky Liuand a trailer line.
44*2fde3a48SSky LiuThe
45*2fde3a48SSky Liu.Xr uudecode 1
46*2fde3a48SSky Liucommand
47*2fde3a48SSky Liuwill ignore any lines preceding the header or
48*2fde3a48SSky Liufollowing the trailer.
49*2fde3a48SSky LiuLines preceding a header must not, of course,
50*2fde3a48SSky Liulook like a header.
51*2fde3a48SSky Liu.Pp
52*2fde3a48SSky LiuThe header line starts with the word
53*2fde3a48SSky Liu.Dq begin ,
54*2fde3a48SSky Liua space,
55*2fde3a48SSky Liua file mode (in octal),
56*2fde3a48SSky Liua space,
57*2fde3a48SSky Liuand finally a string which names the file being encoded.
58*2fde3a48SSky Liu.Pp
59*2fde3a48SSky LiuThe central engine of
60*2fde3a48SSky Liu.Xr uuencode 1
61*2fde3a48SSky Liuis a six-bit encoding function which outputs an
62*2fde3a48SSky Liu.Tn ASCII
63*2fde3a48SSky Liucharacter.
64*2fde3a48SSky LiuThe six bits to be encoded are treated as a small integer and added
65*2fde3a48SSky Liuwith the
66*2fde3a48SSky Liu.Tn ASCII
67*2fde3a48SSky Liuvalue for the space character (octal 40).
68*2fde3a48SSky LiuThe result is a printable
69*2fde3a48SSky Liu.Tn ASCII
70*2fde3a48SSky Liucharacter.
71*2fde3a48SSky LiuIn the case where all six bits to be encoded are zero,
72*2fde3a48SSky Liuthe
73*2fde3a48SSky Liu.Tn ASCII
74*2fde3a48SSky Liubackquote character \` (octal 140) is emitted instead of what
75*2fde3a48SSky Liuwould normally be a space.
76*2fde3a48SSky Liu.Pp
77*2fde3a48SSky LiuThe body of an encoded file consists of one or more lines,
78*2fde3a48SSky Liueach of which may be a maximum of 86 characters long (including the trailing
79*2fde3a48SSky Liunewline).
80*2fde3a48SSky LiuEach line represents an encoded chunk of data from the input file and begins
81*2fde3a48SSky Liuwith a byte count,
82*2fde3a48SSky Liufollowed by encoded bytes,
83*2fde3a48SSky Liufollowed by a newline.
84*2fde3a48SSky Liu.Pp
85*2fde3a48SSky LiuThe byte count is a six-bit integer encoded with the above function,
86*2fde3a48SSky Liurepresenting the number of bytes encoded in the rest of the line.
87*2fde3a48SSky LiuThe method used to encode the data expands its size by
88*2fde3a48SSky Liu133% (described below).
89*2fde3a48SSky LiuTherefore it is important to note that the byte count describes the size of
90*2fde3a48SSky Liuthe chunk of data before it is encoded, not afterwards.
91*2fde3a48SSky LiuThe six bit size of this number effectively limits the number of bytes
92*2fde3a48SSky Liuthat can be encoded in each line to a maximum of 63.
93*2fde3a48SSky LiuWhile
94*2fde3a48SSky Liu.Xr uuencode 1
95*2fde3a48SSky Liuwill not encode more than 45 bytes per line,
96*2fde3a48SSky Liu.Xr uudecode 1
97*2fde3a48SSky Liuwill tolerate the maximum line size.
98*2fde3a48SSky Liu.Pp
99*2fde3a48SSky LiuThe remaining characters in the line represent the data of the input
100*2fde3a48SSky Liufile encoded as follows.
101*2fde3a48SSky LiuInput data are broken into groups of three eight-bit bytes,
102*2fde3a48SSky Liuwhich are then interpreted together as a 24-bit block.
103*2fde3a48SSky LiuThe first bit of the block is the highest order bit of the first character,
104*2fde3a48SSky Liuand the last is the lowest order bit of the third character.
105*2fde3a48SSky LiuThis block is then broken into four six-bit integers which are encoded one by
106*2fde3a48SSky Liuone starting from the first bit of the block.
107*2fde3a48SSky LiuThe result is a four character
108*2fde3a48SSky Liu.Tn ASCII
109*2fde3a48SSky Liustring for every three bytes of input data.
110*2fde3a48SSky Liu.Pp
111*2fde3a48SSky LiuEncoded lines of data continue in this manner until the input file is
112*2fde3a48SSky Liuexhausted.
113*2fde3a48SSky LiuThe end of the body is signaled by an encoded line with a byte count
114*2fde3a48SSky Liuof zero (the
115*2fde3a48SSky Liu.Tn ASCII
116*2fde3a48SSky Liubackquote character \`).
117*2fde3a48SSky Liu.Pp
118*2fde3a48SSky LiuObviously, not every input file will be a multiple of three bytes in size.
119*2fde3a48SSky LiuIn these cases,
120*2fde3a48SSky Liu.Xr uuencode 1
121*2fde3a48SSky Liuwill pad the remaining one or two bytes of data with garbage bytes until
122*2fde3a48SSky Liua three byte group is created.
123*2fde3a48SSky LiuThe byte count in a line containing
124*2fde3a48SSky Liugarbage padding will reflect the actual number of bytes encoded, making
125*2fde3a48SSky Liuit possible to convey how many bytes are garbage.
126*2fde3a48SSky Liu.Pp
127*2fde3a48SSky LiuThe trailer line consists of
128*2fde3a48SSky Liu.Dq end
129*2fde3a48SSky Liuon a line by itself.
130*2fde3a48SSky Liu.Sh SEE ALSO
131*2fde3a48SSky Liu.Xr mail 1 ,
132*2fde3a48SSky Liu.Xr uucp 1 ,
133*2fde3a48SSky Liu.Xr uudecode 1 ,
134*2fde3a48SSky Liu.Xr uuencode 1 ,
135*2fde3a48SSky Liu.Xr ascii 7
136*2fde3a48SSky Liu.Sh HISTORY
137*2fde3a48SSky LiuThe
138*2fde3a48SSky Liu.Nm
139*2fde3a48SSky Liufile format appeared in
140*2fde3a48SSky Liu.Bx 4.0 .
141*2fde3a48SSky Liu.Sh BUGS
142*2fde3a48SSky LiuThe interpretation of the
143*2fde3a48SSky Liu.Nm
144*2fde3a48SSky Liuformat relies on properties of the
145*2fde3a48SSky Liu.Tn ASCII
146*2fde3a48SSky Liucharacter set and may not work correctly on non-ASCII systems.
147