GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
BASE64(3) FreeBSD Library Functions Manual BASE64(3)

b64_encoder_create, b64_decoder_create
base-64 encoder and decoder

PDEL Library (libpdel, -lpdel)

#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[];

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.

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.

filter(3), libpdel(3)

N. Freed and N. Borenstein, Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies, RFC 2045.

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

Archie Cobbs ⟨archie@freebsd.org⟩
April 22, 2002 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.