Annotation of embedaddon/libpdel/io/base64.3, revision 1.1.1.1
1.1 misho 1: .\" Copyright (c) 2001-2002 Packet Design, LLC.
2: .\" All rights reserved.
3: .\"
4: .\" Subject to the following obligations and disclaimer of warranty,
5: .\" use and redistribution of this software, in source or object code
6: .\" forms, with or without modifications are expressly permitted by
7: .\" Packet Design; provided, however, that:
8: .\"
9: .\" (i) Any and all reproductions of the source or object code
10: .\" must include the copyright notice above and the following
11: .\" disclaimer of warranties; and
12: .\" (ii) No rights are granted, in any manner or form, to use
13: .\" Packet Design trademarks, including the mark "PACKET DESIGN"
14: .\" on advertising, endorsements, or otherwise except as such
15: .\" appears in the above copyright notice or in the software.
16: .\"
17: .\" THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
18: .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
19: .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
20: .\" THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
21: .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
22: .\" OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
23: .\" OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
24: .\" OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
25: .\" RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
26: .\" LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
27: .\" OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
28: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
29: .\" DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
30: .\" USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
31: .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
33: .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
34: .\" THE POSSIBILITY OF SUCH DAMAGE.
35: .\"
36: .\" Author: Archie Cobbs <archie@freebsd.org>
37: .\"
38: .\" $Id: base64.3,v 1.6 2004/06/02 17:24:37 archie Exp $
39: .\"
40: .Dd April 22, 2002
41: .Dt BASE64 3
42: .Os
43: .Sh NAME
44: .Nm b64_encoder_create ,
45: .Nm b64_decoder_create
46: .Nd base-64 encoder and decoder
47: .Sh LIBRARY
48: PDEL Library (libpdel, \-lpdel)
49: .Sh SYNOPSIS
50: .In pdel/io/filter.h
51: .In pdel/io/base64.h
52: .Ft "struct filter *"
53: .Fn b64_encoder_create "const char *charset"
54: .Ft "struct filter *"
55: .Fn b64_decoder_create "const char *charset" "int strict"
56: .Vt extern const char "b64_rfc2045_charset[]" ;
57: .Sh DESCRIPTION
58: These routines create filter objects (see
59: .Xr filter 3)
60: that encode and decode binary data using base-64 encoding.
61: .Pp
62: Both functions take a
63: .Fa charset
64: argument.
65: If equal to
66: .Dv NULL ,
67: then the default (RFC 2045) character set is used.
68: Otherwise,
69: .Fa charset
70: must point to a string with 65 unique characters.
71: The first 64 are used to encode the data, while the last character is used
72: as a pad character when the data length is not a multiple of three.
73: .Pp
74: .Fn b64_encoder_create
75: returns a new encoding filter.
76: For every three bytes input to the filter, four bytes from the chosen
77: character set will be output.
78: If the input length is not a multiple of three, then one or two pad
79: characters will be added at the end of the output, so that the output
80: length of the filter is always a multiple of four.
81: .Pp
82: .Fn b64_decoder_create
83: returns a new decoding filter.
84: Every four bytes input to the filter are decoded into up to three bytes
85: of output.
86: If
87: .Fa strict
88: is non-zero, then any malformed input causes an internal error to be
89: generated in the filter, with
90: .Va errno
91: set to
92: .Er EINVAL.
93: Malformed input is any input character not from the chosen character set.
94: In any case, the pad character is always ignored.
95: If
96: .Fa strict
97: is zero, then any unrecognized characters are simply ignored, rather than
98: causing an error.
99: .Pp
100: .Fn b64_encoder_create
101: always generates strings that are accepted by
102: .Fn b64_decoder_create
103: in strict mode, when created with the same character set.
104: .Pp
105: The RFC 2045 character set is avilable in
106: .Va b64_rfc2045_charset .
107: .Sh RETURN VALUES
108: If there was a system error,
109: .Fn b64_encoder_create
110: and
111: .Fn b64_encoder_create
112: return
113: .Dv NULL
114: with
115: .Va errno
116: set to the appropriate value.
117: If an invalid
118: .Fa charset
119: is passed,
120: .Va errno
121: will be set to
122: .Er EINVAL.
123: .Sh SEE ALSO
124: .Xr filter 3 ,
125: .Xr libpdel 3
126: .Rs
127: .%A N. Freed
128: .%A N. Borenstein
129: .%T "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
130: .%O RFC 2045
131: .Re
132: .Sh HISTORY
133: The PDEL library was developed at Packet Design, LLC.
134: .Dv "http://www.packetdesign.com/"
135: .Sh AUTHORS
136: .An Archie Cobbs Aq archie@freebsd.org
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>