bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid iostream_pump_copy(struct iostream_pump *pump)
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi size_t old_size = o_stream_get_max_buffer_size(pump->output);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi res = o_stream_send_istream(pump->output, pump->input);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi o_stream_set_max_buffer_size(pump->output, old_size);
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen pump->callback(IOSTREAM_PUMP_STATUS_INPUT_ERROR, pump->context);
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen pump->callback(IOSTREAM_PUMP_STATUS_OUTPUT_ERROR, pump->context);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* flush it */
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen pump->callback(IOSTREAM_PUMP_STATUS_OUTPUT_ERROR, pump->context);
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen pump->callback(IOSTREAM_PUMP_STATUS_INPUT_EOF, pump->context);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiint iostream_pump_flush(struct iostream_pump *pump)
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen pump->callback(IOSTREAM_PUMP_STATUS_OUTPUT_ERROR, pump->context);
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen pump->callback(IOSTREAM_PUMP_STATUS_INPUT_EOF, pump->context);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi pump->io = io_add_istream(pump->input, iostream_pump_copy, pump);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiiostream_pump_create(struct istream *input, struct ostream *output)
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* ref streams */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* create pump */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi struct iostream_pump *pump = i_new(struct iostream_pump, 1);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid iostream_pump_start(struct iostream_pump *pump)
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* add flush handler */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi o_stream_set_flush_callback(pump->output, iostream_pump_flush, pump);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* make IO objects */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi pump->io = io_add_istream(pump->input, iostream_pump_copy, pump);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* make sure we do first read right away */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct istream *iostream_pump_get_input(struct iostream_pump *pump)
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct ostream *iostream_pump_get_output(struct iostream_pump *pump)
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid iostream_pump_set_completion_callback(struct iostream_pump *pump,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi iostream_pump_callback_t *callback, void *context)
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid iostream_pump_unref(struct iostream_pump **pump_r)
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid iostream_pump_stop(struct iostream_pump *pump)
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainenbool iostream_pump_is_waiting_output(struct iostream_pump *pump)