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