xref: /titanic_52/usr/src/cmd/cmd-inet/usr.lib/wpad/eloop.h (revision 39de7e401c4775b362a283e4714b49f6859eecab)
1 /*
2  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
8  * Sun elects to license this software under the BSD license.
9  * See README for more details.
10  */
11 #ifndef __ELOOP_H
12 #define	__ELOOP_H
13 
14 #pragma ident	"%Z%%M%	%I%	%E% SMI"
15 
16 #ifdef	__cplusplus
17 extern "C" {
18 #endif
19 
20 /* Magic number for eloop_cancel_timeout() */
21 #define	ELOOP_ALL_CTX		(void *) -1
22 #define	MAX_POLLFDS		32
23 
24 struct eloop_sock {
25 	int sock;
26 	void *eloop_data;
27 	void *user_data;
28 	void (*handler)(int, void *, void *);
29 };
30 
31 struct eloop_timeout {
32 	struct timeval time;
33 	void *eloop_data;
34 	void *user_data;
35 	void (*handler)(void *, void *);
36 	struct eloop_timeout *next;
37 };
38 
39 struct eloop_signal {
40 	int sig;
41 	void *user_data;
42 	void (*handler)(int, void *, void *);
43 	int signaled;
44 };
45 
46 struct eloop_data {
47 	void *user_data;
48 
49 	int max_sock, reader_count;
50 	struct eloop_sock *readers;
51 
52 	struct eloop_timeout *timeout;
53 
54 	int signal_count;
55 	struct eloop_signal *signals;
56 	int signaled;
57 
58 	int terminate;
59 };
60 
61 void eloop_init(void *);
62 
63 int eloop_register_read_sock(int,
64 	void (*handler)(int, void *, void *), void *, void *);
65 
66 void eloop_unregister_read_sock(int);
67 
68 int eloop_register_timeout(unsigned int, unsigned int,
69 	void (*handler)(void *, void *), void *, void *);
70 
71 void eloop_cancel_timeout(void (*handler)(void *, void *), void *, void *);
72 int eloop_register_signal(int, void (*handler)(int, void *, void *), void *);
73 
74 void eloop_run(void);
75 void eloop_terminate(void);
76 void eloop_destroy(void);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* __ELOOP_H */
83