bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file
987c15a5980f53225e60f79325c14cb2acddaabbTimo Siraineniostream_proxy_completion(struct iostream_proxy *proxy,
987c15a5980f53225e60f79325c14cb2acddaabbTimo Sirainen status = IOSTREAM_PROXY_STATUS_OTHER_SIDE_OUTPUT_ERROR;
987c15a5980f53225e60f79325c14cb2acddaabbTimo Sirainen proxy->callback(side, status, proxy->context);
39435f00a35a276d329283179b3e7e0351482939Timo Sirainenvoid iostream_proxy_rtl_completion(enum iostream_pump_status status,
987c15a5980f53225e60f79325c14cb2acddaabbTimo Sirainen iostream_proxy_completion(proxy, IOSTREAM_PROXY_SIDE_RIGHT, status);
39435f00a35a276d329283179b3e7e0351482939Timo Sirainenvoid iostream_proxy_ltr_completion(enum iostream_pump_status status,
987c15a5980f53225e60f79325c14cb2acddaabbTimo Sirainen iostream_proxy_completion(proxy, IOSTREAM_PROXY_SIDE_LEFT, status);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomiiostream_proxy_create(struct istream *left_input, struct ostream *left_output,
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi struct istream *right_input, struct ostream *right_output)
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi /* create proxy */
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi struct iostream_proxy *proxy = i_new(struct iostream_proxy, 1);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi proxy->ltr = iostream_pump_create(left_input, right_output);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi proxy->rtl = iostream_pump_create(right_input, left_output);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi iostream_pump_set_completion_callback(proxy->ltr, iostream_proxy_ltr_completion, proxy);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi iostream_pump_set_completion_callback(proxy->rtl, iostream_proxy_rtl_completion, proxy);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_start(struct iostream_proxy *proxy)
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_set_completion_callback(struct iostream_proxy *proxy,
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomistruct istream *iostream_proxy_get_istream(struct iostream_proxy *proxy, enum iostream_proxy_side side)
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi case IOSTREAM_PROXY_SIDE_LEFT: return iostream_pump_get_input(proxy->ltr);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi case IOSTREAM_PROXY_SIDE_RIGHT: return iostream_pump_get_input(proxy->rtl);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomistruct ostream *iostream_proxy_get_ostream(struct iostream_proxy *proxy, enum iostream_proxy_side side)
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi case IOSTREAM_PROXY_SIDE_LEFT: return iostream_pump_get_output(proxy->ltr);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi case IOSTREAM_PROXY_SIDE_RIGHT: return iostream_pump_get_output(proxy->rtl);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_ref(struct iostream_proxy *proxy)
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_unref(struct iostream_proxy **proxy_r)
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi /* pumps will call stop internally
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi if refcount drops to 0 */
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_stop(struct iostream_proxy *proxy)
6ce52edd3de46bdf565ee71f6112a9e7a6090031Timo Sirainenbool iostream_proxy_is_waiting_output(struct iostream_proxy *proxy,
6ce52edd3de46bdf565ee71f6112a9e7a6090031Timo Sirainen return iostream_pump_is_waiting_output(proxy->ltr);
6ce52edd3de46bdf565ee71f6112a9e7a6090031Timo Sirainen return iostream_pump_is_waiting_output(proxy->rtl);