2 .TH base64 3 "20 June 1999" mLib
4 base64 \- conversion to and from base64 encoding
10 .B "#include <mLib/base64.h>"
12 .BI "void base64_encode(base64_ctx *" ctx ,
13 .BI " const void *" p ", size_t " sz ,
15 .BI "void base64_decode(base64_ctx *" ctx ,
16 .BI " const void *" p ", size_t " sz ,
18 .BI "void base64_init(base64_ctx *" ctx );
23 functions perform base64 encoding and decoding of arbitrary binary
24 strings. The base64 encoding is defined by RFC2045.
26 Before encoding or decoding a string, a
30 must be initialized, by passing it to
32 The context contains data which must be retained between calls to encode
33 or decode substrings. The
35 function sets up initial values for the data, and sets up defaults for
36 the output formatting settings (see below).
38 Encoding of a string is performed by the
40 function. It is passed a pointer to a context block
42 the input substring to encode passed by address
46 and a pointer to a dynamic string
48 in which to write its output (see
50 for details on dynamic strings). Once all the input data has been
53 it is necessary to flush the final few bytes of output. This is
56 a null pointer as its source argument. It is an error to attempt to
57 continue encoding after flushing output.
61 function is formatted into lines using values from the context
64 member is a pointer to a null-terminated string which is used to
65 separate the output lines. The default indent string contains only a
66 newline character. The
68 member gives the maximum length of line that
70 is allowed to produce. If this is not a multiple of 4, it is rounded
71 up to the next highest multiple of four before use. A value of zero
74 not to perform line splitting: the output will be a single (possibly
75 very long) output line. The default maximum line length is 72
76 characters. You may set these parameters by direct assignment to the
77 context structure once it has been initialized.
79 Decoding is performed similarly by the
81 function. The comments above about flushing output apply equally to
84 Decoding ignores all whitespace characters in the encoded string. It
87 characters in the string and works out the final block length
88 automatically based on the input size.
93 Mark Wooding, <mdw@nsict.org>