6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen#ifndef MESSAGE_BINARY_PART_H
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen#define MESSAGE_BINARY_PART_H
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainenstruct message_binary_part {
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen struct message_binary_part *next;
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen /* Absolute position from beginning of message. This can be used to
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen match the part to struct message_part. */
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen uoff_t physical_pos;
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen /* Decoded binary header/body size. The binary header size may differ
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen from message_part's, because Content-Transfer-Encoding is changed to
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen "binary". */
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen uoff_t binary_hdr_size;
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen uoff_t binary_body_size;
e53ab6c7081246c865917f9aa0eff031a08ad1e7Timo Sirainen /* BODYSTRUCTURE for text/ and message/rfc822 parts includes lines
e53ab6c7081246c865917f9aa0eff031a08ad1e7Timo Sirainen count. Decoding may change these numbers. */
e53ab6c7081246c865917f9aa0eff031a08ad1e7Timo Sirainen unsigned int binary_body_lines_count;
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen};
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen/* Serialize message binary_part. */
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainenvoid message_binary_part_serialize(const struct message_binary_part *parts,
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen buffer_t *dest);
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen/* Generate struct message_binary_part from serialized data. Returns 0 if ok,
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen -1 if any problems are detected. */
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainenint message_binary_part_deserialize(pool_t pool, const void *data, size_t size,
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen struct message_binary_part **parts_r);
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen
6e8f0036cad59d1d6bcd9ef69bfe712d01656ca3Timo Sirainen#endif