login-proxy.h revision d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76
424N/A#ifndef LOGIN_PROXY_H
424N/A#define LOGIN_PROXY_H
424N/A
424N/Astruct login_proxy;
851N/A
851N/A/* Called when new input comes from proxy. */
424N/Atypedef void proxy_callback_t(struct istream *input, struct ostream *output,
424N/A void *context);
424N/A
424N/A/* Create a proxy to given host. Returns NULL if failed. Given callback is
424N/A called when new input is available from proxy. */
424N/Astruct login_proxy *
424N/Alogin_proxy_new(struct client *client, const char *host, unsigned int port,
424N/A proxy_callback_t *callback, void *context);
424N/A#ifdef CONTEXT_TYPE_SAFETY
424N/A# define login_proxy_new(client, host, port, callback, context) \
424N/A ({(void)(1 ? 0 : callback((struct istream *)NULL, \
424N/A (struct ostream *)NULL, context)); \
424N/A login_proxy_new(client, host, port, \
424N/A (proxy_callback_t *)callback, context); })
424N/A#else
424N/A# define login_proxy_new(client, host, port, callback, context) \
424N/A login_proxy_new(client, host, port, \
424N/A (proxy_callback_t *)callback, context)
424N/A#endif
424N/A/* Free the proxy. This should be called if authentication fails. */
424N/Avoid login_proxy_free(struct login_proxy **proxy);
424N/A
424N/A/* Return TRUE if host/port/destuser combination points to same as current
424N/A connection. */
424N/Abool login_proxy_is_ourself(const struct client *client, const char *host,
424N/A unsigned int port, const char *destuser);
851N/A
424N/A/* Detach proxy from client. This is done after the authentication is
424N/A successful and all that is left is the dummy proxying. */
424N/Avoid login_proxy_detach(struct login_proxy *proxy, struct istream *client_input,
493N/A struct ostream *client_output);
424N/A
424N/Aconst char *login_proxy_get_host(const struct login_proxy *proxy) ATTR_PURE;
851N/Aunsigned int login_proxy_get_port(const struct login_proxy *proxy) ATTR_PURE;
424N/A
424N/Avoid login_proxy_deinit(void);
424N/A
424N/A#endif
424N/A