message-send.h revision 3ed5b60132508928e82d685d901ad3e6f95b0df0
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen#ifndef __MESSAGE_SEND_H
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen#define __MESSAGE_SEND_H
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainenstruct message_size;
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen/* Send message to client inserting CRs if needed. Only max_virtual_size
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen bytes if sent (relative to virtual_skip), if you want it unlimited,
baf346e71ebd7b44fcba4b48f4d39845453b778bTimo Sirainen use (uoff_t)-1. Remember that if input begins with LF, CR is inserted
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen before it unless virtual_skip = 1. last_cr is set to 1, 0 or -1 if not
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen known. Returns number of bytes sent, or -1 if error. */
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainenoff_t message_send(struct ostream *output, struct istream *input,
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen const struct message_size *msg_size,
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen uoff_t virtual_skip, uoff_t max_virtual_size, int *last_cr);
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen/* Skip number of virtual bytes from putfer. msg_size is updated if it's not
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen NULL. If cr_skipped is TRUE and first character is \n, it's not treated as
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainen \r\n. last_cr is set to TRUE if last character we skipped was \r, meaning
baf346e71ebd7b44fcba4b48f4d39845453b778bTimo Sirainen that next character should be \n and you shouldn't treat it as \r\n. */
cf636afb3826f0d8e15c248aa1fc04ce72820e08Timo Sirainenvoid message_skip_virtual(struct istream *input, uoff_t virtual_skip,
baf346e71ebd7b44fcba4b48f4d39845453b778bTimo Sirainen struct message_size *msg_size,
baf346e71ebd7b44fcba4b48f4d39845453b778bTimo Sirainen int cr_skipped, int *last_cr);
baf346e71ebd7b44fcba4b48f4d39845453b778bTimo Sirainen
baf346e71ebd7b44fcba4b48f4d39845453b778bTimo Sirainen#endif
baf346e71ebd7b44fcba4b48f4d39845453b778bTimo Sirainen