b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainen#ifndef MESSAGE_HEADER_ENCODE_H
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainen#define MESSAGE_HEADER_ENCODE_H
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainen
5b6e0b6569d5e79ddb868525063cfd04009437b4Timo Sirainen/* Encode UTF-8 input into output wherever necessary using either Q or B
a7dcd5b93e608feeffe980e268eac6c5b9f5b21cTimo Sirainen encoding depending on which takes less space (approximately). Folding
a7dcd5b93e608feeffe980e268eac6c5b9f5b21cTimo Sirainen whitespace is preserved. Bare [CR]LF will be preserved by adding a TAB
a7dcd5b93e608feeffe980e268eac6c5b9f5b21cTimo Sirainen after it to make it a valid folding whitespace. */
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainenvoid message_header_encode(const char *input, string_t *output);
a5f1628ad97ad649bfef86c84c3afc1d9cb0f326Timo Sirainenvoid message_header_encode_data(const unsigned char *input, unsigned int len,
a5f1628ad97ad649bfef86c84c3afc1d9cb0f326Timo Sirainen string_t *output);
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainen
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainen/* Encode the whole UTF-8 input using "Q" or "B" encoding into output.
5b6e0b6569d5e79ddb868525063cfd04009437b4Timo Sirainen The output is split into multiple lines if necessary (max 76 chars/line).
a7dcd5b93e608feeffe980e268eac6c5b9f5b21cTimo Sirainen The first line's length is given as parameter. All the control characters
a7dcd5b93e608feeffe980e268eac6c5b9f5b21cTimo Sirainen are encoded, including NUL, CR and LF. */
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainenvoid message_header_encode_q(const unsigned char *input, unsigned int len,
5b6e0b6569d5e79ddb868525063cfd04009437b4Timo Sirainen string_t *output, unsigned int first_line_len);
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainenvoid message_header_encode_b(const unsigned char *input, unsigned int len,
5b6e0b6569d5e79ddb868525063cfd04009437b4Timo Sirainen string_t *output, unsigned int first_line_len);
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainen
b22a4a60c59146081d6d32e37aa9e8cd10f4dab2Timo Sirainen#endif