BASE64(3)

NAME
b64_encoder_create, b64_decoder_create - base-64 encoder and decoder

LIBRARY
PDEL Library (libpdel, -lpdel)

SYNOPSIS
#include <pdel/io/filter.h>
#include <pdel/io/base64.h>
struct filter *
b64_encoder_create(const char *charset);
struct filter *
b64_decoder_create(const char *charset, int strict);
extern const char b64_rfc2045_charset[];

DESCRIPTION
These routines create filter objects (see filter(3)) that encode and decode binary data using base-64 encoding.

Both functions take a charset argument. If equal to NULL, then the default (RFC 2045) character set is used. Otherwise, charset must point to a string with 65 unique characters. The first 64 are used to encode the data, while the last character is used as a pad character when the data length is not a multiple of three.

b64_encoder_create() returns a new encoding filter. For every three bytes input to the filter, four bytes from the chosen character set will be output. If the input length is not a multiple of three, then one or two pad characters will be added at the end of the output, so that the output length of the filter is always a multiple of four.

b64_decoder_create() returns a new decoding filter. Every four bytes input to the filter are decoded into up to three bytes of output. If strict is non-zero, then any malformed input causes an internal error to be generated in the filter, with errno set to EINVAL. Malformed input is any input character not from the chosen character set. In any case, the pad character is always ignored. If strict is zero, then any unrecognized characters are simply ignored, rather than causing an error.

b64_encoder_create() always generates strings that are accepted by b64_decoder_create() in strict mode, when created with the same character set.

The RFC 2045 character set is avilable in b64_rfc2045_charset.

RETURN VALUES
If there was a system error, b64_encoder_create() and b64_encoder_create() return NULL with errno set to the appropriate value. If an invalid charset is passed, errno will be set to EINVAL.

SEE ALSO
filter(3), libpdel(3) N. Freed, N. Borenstein, Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies, RFC 2045.

HISTORY
The PDEL library was developed at Packet Design, LLC. http://www.packetdesign.com/

AUTHORS
Archie Cobbs <archie@packetdesign.com>