1 /*
2  * The Spread Toolkit.
3  *
4  * The contents of this file are subject to the Spread Open-Source
5  * License, Version 1.0 (the ``License''); you may not use
6  * this file except in compliance with the License.  You may obtain a
7  * copy of the License at:
8  *
9  * http://www.spread.org/license/
10  *
11  * or in the file ``license.txt'' found in this distribution.
12  *
13  * Software distributed under the License is distributed on an AS IS basis,
14  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15  * for the specific language governing rights and limitations under the
16  * License.
17  *
18  * The Creators of Spread are:
19  *  Yair Amir, Michal Miskin-Amir, Jonathan Stanton, John Schultz.
20  *
21  *  Copyright (C) 1993-2009 Spread Concepts LLC <info@spreadconcepts.com>
22  *
23  *  All Rights Reserved.
24  *
25  * Major Contributor(s):
26  * ---------------
27  *    Ryan Caudy           rcaudy@gmail.com - contributions to process groups.
28  *    Claudiu Danilov      claudiu@acm.org - scalable wide area support.
29  *    Cristina Nita-Rotaru crisn@cs.purdue.edu - group communication security.
30  *    Theo Schlossnagle    jesus@omniti.com - Perl, autoconf, old skiplist.
31  *    Dan Schoenblum       dansch@cnds.jhu.edu - Java interface.
32  *
33  */
34 
35 
36 
37 #ifndef	INC_SP_EVENTS
38 #define	INC_SP_EVENTS
39 
40 /* Raise this number AND RECOMPILE events.c to handle more active FD's.
41  * This number limits the number of connections that
42  * can be handled.
43  */
44 #define		MAX_FD_EVENTS		 2000
45 
46 #define		NUM_PRIORITY	3
47 
48 #define		LOW_PRIORITY	0
49 #define		MEDIUM_PRIORITY	1
50 #define		HIGH_PRIORITY	2
51 
52 #define		NUM_FDTYPES	3
53 
54 #define		READ_FD		0
55 #define		WRITE_FD	1
56 #define		EXCEPT_FD	2
57 
58 
59 typedef struct dummy_time {
60 	long	sec;
61 	long	usec;
62 } sp_time;
63 
64 #ifndef NULL
65 #define NULL    (void *)0
66 #endif
67 
68 /* Event routines */
69 
70 int 	E_init(void);
71 sp_time	E_get_time(void);
72 sp_time	E_sub_time( sp_time t, sp_time delta_t );
73 sp_time	E_add_time( sp_time t, sp_time delta_t );
74 /* if t1 > t2 then returns 1;
75    if t1 < t2 then returns -1;
76    if t1 == t2 then returns 0; */
77 int	E_compare_time( sp_time t1, sp_time t2 );
78 int 	E_queue( void (* func)( int code, void *data ), int code, void *data,
79 		 sp_time delta_time );
80 int     E_in_queue( void (* func)( int code, void *data ), int code,
81                     void *data );
82 /* Note: This does not dispose/free the data pointed at by the void
83    *data pointer */
84 int 	E_dequeue( void (* func)( int code, void *data ), int code,
85 		   void *data );
86 void	E_delay( sp_time t );
87 
88 int	E_attach_fd( int fd, int fd_type,
89 		     void (* func)( int fd, int code, void *data), int code,
90 		     void *data, int priority );
91 int 	E_detach_fd( int fd, int fd_type );
92 int 	E_set_active_threshold( int priority );
93 int     E_activate_fd( int fd, int fd_type );
94 int     E_deactivate_fd( int fd, int fd_type );
95 int	E_num_active( int priority );
96 
97 void 	E_handle_events(void);
98 void 	E_exit_events(void);
99 
100 #endif	/* INC_SP_EVENTS */
101