istream-raw-mbox.h revision 313fe89df4d91cd0cd7f3558dc6d7fd21ad39eee
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#ifndef __ISTREAM_RAW_MBOX_H
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define __ISTREAM_RAW_MBOX_H
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainen/* Create a mbox stream for parsing mbox. Reading stops before From-line,
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainen you'll have to call istream_raw_mbox_next() to get to next message. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct istream *i_stream_create_raw_mbox(pool_t pool, struct istream *input);
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Return offset to beginning of the "\nFrom"-line. */
89b548af722113acb5d63dfffb44423cb60f91e4Timo Sirainenuoff_t istream_raw_mbox_get_start_offset(struct istream *stream);
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen/* Return offset to beginning of the headers. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenuoff_t istream_raw_mbox_get_header_offset(struct istream *stream);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
66ae183b6e895216037bd921367670f4b0665911Timo Sirainen/* Return the number of bytes in the body of this message. If body_size isn't
e86d0d34fe365da4c7ca4312d575bfcbf3a01c0eTimo Sirainen (uoff_t)-1, we'll use it as potentially valid body size to avoid actually
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen reading through the whole message. */
da5d50534cfca45d0aaaf0bdac17b287b4588809Timo Sirainenuoff_t istream_raw_mbox_get_body_size(struct istream *stream, uoff_t body_size);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Return received time of current message, or (time_t)-1 if the timestamp is
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen broken. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainentime_t istream_raw_mbox_get_received_time(struct istream *stream);
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen/* Return sender of current message. */
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainenconst char *istream_raw_mbox_get_sender(struct istream *stream);
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Jump to next message. If body_size isn't (uoff_t)-1, we'll use it as
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen potentially valid body size. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid istream_raw_mbox_next(struct istream *stream, uoff_t body_size);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Seek to message at given offset. offset must point to beginning of
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "\nFrom ", or 0 for beginning of file. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid istream_raw_mbox_seek(struct istream *stream, uoff_t offset);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
024815ea2ffdda9ea79919f18e865663977f73eaTimo Sirainen/* Flush all buffering. Call if you modify the mbox. */
8fa41238067c854435884c459963fde6f8c6436bTimo Sirainenvoid istream_raw_mbox_flush(struct istream *stream);
8fa41238067c854435884c459963fde6f8c6436bTimo Sirainen
91dca97b367c54a139c268b56a0c67f564bd9197Timo Sirainen#endif
91dca97b367c54a139c268b56a0c67f564bd9197Timo Sirainen