annotate src/login-common/login-proxy.h @ 4906:0c3c948412c5 HEAD

Type safe callbacks weren't as easy as I thought. Only callback(void *context) can be handled generically. Others can be handled specially, but only if all the parameters are pointers, otherwise eg. int parameter can be replaced with long without compiler giving any warnings.
author Timo Sirainen <tss@iki.fi>
date Fri, 15 Dec 2006 20:10:51 +0200
parents 204d7edc7cdc
children 5c0a5cf4626d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2768
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 #ifndef __LOGIN_PROXY_H
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2 #define __LOGIN_PROXY_H
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
2773
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
4 struct login_proxy;
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
5
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
6 /* Called when new input comes from proxy. */
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
7 typedef void proxy_callback_t(struct istream *input, struct ostream *output,
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
8 void *context);
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
9
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
10 /* Create a proxy to given host. Returns NULL if failed. Given callback is
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
11 called when new input is available from proxy. */
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
12 struct login_proxy *
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
13 login_proxy_new(struct client *client, const char *host, unsigned int port,
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
14 proxy_callback_t *callback, void *context);
4906
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
15 #ifdef CONTEXT_TYPE_SAFETY
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
16 # define login_proxy_new(client, host, port, callback, context) \
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
17 ({(void)(1 ? 0 : callback((struct istream *)NULL, \
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
18 (struct ostream *)NULL, context)); \
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
19 login_proxy_new(client, host, port, \
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
20 (proxy_callback_t *)callback, context); })
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
21 #else
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
22 # define login_proxy_new(client, host, port, callback, context) \
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
23 login_proxy_new(client, host, port, \
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
24 (proxy_callback_t *)callback, context)
0c3c948412c5 Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents: 4903
diff changeset
25 #endif
2773
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
26 /* Free the proxy. This should be called if authentication fails. */
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
27 void login_proxy_free(struct login_proxy *proxy);
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
28
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
29 /* Detach proxy from client. This is done after the authentication is
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
30 successful and all that is left is the dummy proxying. */
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
31 void login_proxy_detach(struct login_proxy *proxy, struct istream *client_input,
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
32 struct ostream *client_output);
2768
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33
4538
9d9e72374164 Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents: 2773
diff changeset
34 /* Return number of active detached login proxies */
9d9e72374164 Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents: 2773
diff changeset
35 unsigned int login_proxy_get_count(void);
9d9e72374164 Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents: 2773
diff changeset
36
2768
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 void login_proxy_deinit(void);
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 #endif