Provides tools to convert data to or from a content encoding format. More...
Macros | |
| #define | B_MAIL_NULL_CONVERSION ((uint32) -1) |
| Do not specify a character set for converting, rely on autodetection instead. | |
| #define | B_MAIL_US_ASCII_CONVERSION ((uint32) -3) |
| Specifies the 7bit ASCII character set (a subset of UTF-8) when converting from or to 7bit. | |
| #define | B_MAIL_UTF8_CONVERSION ((uint32) -2) |
| Specifies the UTF-8 character set when converting from or to UTF-8. | |
Enumerations | |
| enum | mail_encoding { base64 = 'b' , quoted_printable = 'q' , seven_bit = '7' , eight_bit = '8' , uuencode = 'u' , null_encoding = 0 , no_encoding = -1 } |
Functions | |
| ssize_t | decode (mail_encoding encoding, char *out, const char *in, off_t length, int underscore_is_space) |
| Decodes data from a certain encoding. | |
| ssize_t | decode_base64 (char *out, const char *in, off_t length) |
| Decodes a base64 data buffer. | |
| ssize_t | decode_qp (char *out, const char *in, off_t length, int underscore_is_space) |
| Decodes a quoted-printable data buffer. | |
| ssize_t | encode (mail_encoding encoding, char *out, const char *in, off_t length, int headerMode) |
| Encodes data to a content encoding. | |
| ssize_t | encode_base64 (char *out, const char *in, off_t length, int headerMode) |
| Encodes a string to base64. | |
| ssize_t | encode_qp (char *out, const char *in, off_t length, int headerMode) |
| Encodes an input data to quoted-printable. | |
| mail_encoding | encoding_for_cte (const char *content_transfer_encoding) |
| Returns a mail_encoding value for the content_transfer_encoding string. | |
| ssize_t | max_encoded_length (mail_encoding encoding, off_t cur_length) |
| Returns the output size of a certain encoding, given an input data has cur_length of length. | |
| ssize_t | uu_decode (char *out, const char *in, off_t length) |
| Decodes a uuencoded data buffer. | |
Provides tools to convert data to or from a content encoding format.
The "7bit" and "8bit" encodings do not perform a binary-to-text conversion but copy the input data into an output buffer. "base64" and "quoted-printable" are as defined in RFC 2045. "uuencode" content format is as defined in the POSIX specification.
| #define B_MAIL_NULL_CONVERSION ((uint32) -1) |
Do not specify a character set for converting, rely on autodetection instead.
| #define B_MAIL_US_ASCII_CONVERSION ((uint32) -3) |
Specifies the 7bit ASCII character set (a subset of UTF-8) when converting from or to 7bit.
| #define B_MAIL_UTF8_CONVERSION ((uint32) -2) |
Specifies the UTF-8 character set when converting from or to UTF-8.
| enum mail_encoding |
| ssize_t decode | ( | mail_encoding | encoding, |
| char * | out, | ||
| const char * | in, | ||
| off_t | length, | ||
| int | underscore_is_space | ||
| ) |
Decodes data from a certain encoding.
Takes an input data in of length bytes and converts it back from encoding to its unencoded form into out.
This wrapper function can be used to convert an input data in base64, quoted-printable or uuencoding formats to its original form. However, if encoding is not recognized, it will not perform any operation and will return -1. On the other hand, if encoding is equal to seven_bit, eight_bit or no_encoding, it will just make a copy of the data.
underscore_is_space is only useful when converting from quoted-printable encoding, when the data is going to be decoded from a header field.
| [in] | encoding | Input data's encoding. |
| [out] | out | Where the resulting data will be written to. |
| [in] | in | Input data. |
| [in] | length | Input data's length. |
| [in] | underscore_is_space | Should be equal to 1 to indicate when decoding a header field. |
-1 if the encoding is not compatible nor recognized.| ssize_t decode_base64 | ( | char * | out, |
| const char * | in, | ||
| off_t | length | ||
| ) |
Decodes a base64 data buffer.
Takes an input data in encoded in base64 of length bytes and converts it back to its unencoded form into out.
| [out] | out | Where the output data will be written to. |
| [in] | in | Input data. |
| [in] | length | Input data's length. |
| ssize_t decode_qp | ( | char * | out, |
| const char * | in, | ||
| off_t | length, | ||
| int | underscore_is_space | ||
| ) |
Decodes a quoted-printable data buffer.
Takes an input data in encoded in quoted-printable of length bytes and converts it back to its unencoded form into out.
| [out] | out | Where the output data will be written to. |
| [in] | in | Input data. |
| [in] | length | Input data's length. |
| [in] | underscore_is_space | Should be equal to 1 to indicate when decoding a header field. |
| ssize_t encode | ( | mail_encoding | encoding, |
| char * | out, | ||
| const char * | in, | ||
| off_t | length, | ||
| int | headerMode | ||
| ) |
Encodes data to a content encoding.
Converts an arbitrary input data in of length bytes as encoding into out.
This wrapper function can be used to convert to base64 or quoted-printable, or in the case of using 7bit, 8bit or no_encoding, to copy the data from in to out. However, it is unable to convert the data to uuencode.
headerMode is used when the output will be used in a header, and is only used for conversions to quoted-printable or base64, ignored otherwise.
| [in] | encoding | Target encoding. |
| [out] | out | Where the output data will be written to. |
| [in] | in | Input data. |
| [in] | length | Input data's length. |
| [in] | headerMode | Whether the output data will be used in a header or not. |
-1 if the encoding is not compatible nor recognized.| ssize_t encode_base64 | ( | char * | out, |
| const char * | in, | ||
| off_t | length, | ||
| int | headerMode | ||
| ) |
Encodes a string to base64.
Converts an input data in of length bytes as base64 into out.
headerMode is used when the output will be used in a header, where there should not be any line breaks.
| [out] | out | Where the resulting data will be written to. |
| [in] | in | Input data. |
| [in] | length | Input data's length. |
| [in] | headerMode | Whether the output data will be used in a header or not. |
| ssize_t encode_qp | ( | char * | out, |
| const char * | in, | ||
| off_t | length, | ||
| int | headerMode | ||
| ) |
Encodes an input data to quoted-printable.
Converts an input data in of length bytes as quoted-printable into out.
headerMode is used when the output will be used in a header, where there should not be any line breaks.
| [out] | out | Where the output data will be written to. |
| [in] | in | Input data. |
| [in] | length | Input data's length. |
| [in] | headerMode | Whether the output data will be used in a header or not. |
| mail_encoding encoding_for_cte | ( | const char * | content_transfer_encoding | ) |
Returns a mail_encoding value for the content_transfer_encoding string.
| [in] | content_transfer_encoding | A string with the name of the encoding: - "uuencode" for mail_encoding::uuencode - "base64" for mail_encoding::base64 - "quoted-printable" for mail_encoding::quoted_printable - "7bit" for mail_encoding::seven_bit - "8bit" for mail_encoding::eight_bit - Other strings or if content_transfer_encoding is NULL return mail_encoding::no_encoding |
| ssize_t max_encoded_length | ( | mail_encoding | encoding, |
| off_t | cur_length | ||
| ) |
Returns the output size of a certain encoding, given an input data has cur_length of length.
It can perform the calculation for base64, quoted-printable, 7bit and 8bit. If encoding is equal to no_encoding, it will just return the same value as cur_length. However, this function cannot perform the calculation for uuencode.
| [in] | encoding | The target encoding. |
| [in] | cur_length | The input data's length. |
-1 if the encoding is not compatible nor recognized.| ssize_t uu_decode | ( | char * | out, |
| const char * | in, | ||
| off_t | length | ||
| ) |
Decodes a uuencoded data buffer.
Takes an input data in encoded in uuencode of length bytes and converts it back to its unencoded form into out.
| [out] | out | Where the output data will be written to. |
| [in] | in | Input data. |
| [in] | length | Input data's length. |