iostream-proxy.h revision 26e7bc65f13482709c0f6216650582e7705eeeff
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi/* Copyright (c) 2002-2016 Dovecot authors, see the included COPYING file
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomiiostream-proxy
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi=============
26e7bc65f13482709c0f6216650582e7705eeeffAki TuomiThis construct will proxy data between two pairs of
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomiistream and ostream. Data is proxied from left to right
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomiand right to left using iostream-pump.
26e7bc65f13482709c0f6216650582e7705eeeffAki TuomiThe proxy requires you to provide completion callback. The
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomicompletion callback is called with success parameter to
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomiindicate whether it ended with error.
26e7bc65f13482709c0f6216650582e7705eeeffAki TuomiThe istreams and ostreams are reffed on creation and unreffed
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomitypedef void iostream_proxy_callback_t(enum iostream_proxy_side side,
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomiiostream_proxy_create(struct istream *left_input, struct ostream *left_output,
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi struct istream *right_input, struct ostream *right_output);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomistruct istream *iostream_proxy_get_istream(struct iostream_proxy *proxy, enum iostream_proxy_side);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomistruct ostream *iostream_proxy_get_ostream(struct iostream_proxy *proxy, enum iostream_proxy_side);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_start(struct iostream_proxy *proxy);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_stop(struct iostream_proxy *proxy);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_set_completion_callback(struct iostream_proxy *proxy,
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi iostream_proxy_callback_t *callback, void *context);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi#define iostream_proxy_set_completion_callback(proxy, callback, context) \
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi iostream_proxy_set_completion_callback(proxy, (iostream_proxy_callback_t *)callback, context + \
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomi CALLBACK_TYPECHECK(callback, void (*)(enum iostream_proxy_side side, bool, typeof(context))))
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_ref(struct iostream_proxy *proxy);
26e7bc65f13482709c0f6216650582e7705eeeffAki Tuomivoid iostream_proxy_unref(struct iostream_proxy **proxy_r);