xref: /titanic_50/usr/src/lib/libresolv2/include/isc/eventlib.h (revision 9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829)
17c478bd9Sstevel@tonic-gate /*
2*9525b14bSRao Shoaib  * Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
3*9525b14bSRao Shoaib  * Copyright (C) 1995-1999, 2001, 2003  Internet Software Consortium.
47c478bd9Sstevel@tonic-gate  *
5*9525b14bSRao Shoaib  * Permission to use, copy, modify, and/or distribute this software for any
67c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
77c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies.
87c478bd9Sstevel@tonic-gate  *
9*9525b14bSRao Shoaib  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10*9525b14bSRao Shoaib  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11*9525b14bSRao Shoaib  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12*9525b14bSRao Shoaib  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13*9525b14bSRao Shoaib  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14*9525b14bSRao Shoaib  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15*9525b14bSRao Shoaib  * PERFORMANCE OF THIS SOFTWARE.
167c478bd9Sstevel@tonic-gate  */
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate /* eventlib.h - exported interfaces for eventlib
197c478bd9Sstevel@tonic-gate  * vix 09sep95 [initial]
207c478bd9Sstevel@tonic-gate  *
21*9525b14bSRao Shoaib  * $Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp $
227c478bd9Sstevel@tonic-gate  */
237c478bd9Sstevel@tonic-gate 
247c478bd9Sstevel@tonic-gate #ifndef _EVENTLIB_H
257c478bd9Sstevel@tonic-gate #define _EVENTLIB_H
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/uio.h>
297c478bd9Sstevel@tonic-gate #include <sys/time.h>
307c478bd9Sstevel@tonic-gate #include <stdio.h>
317c478bd9Sstevel@tonic-gate 
32*9525b14bSRao Shoaib #include <isc/platform.h>
33*9525b14bSRao Shoaib 
347c478bd9Sstevel@tonic-gate #ifndef __P
357c478bd9Sstevel@tonic-gate # define __EVENTLIB_P_DEFINED
367c478bd9Sstevel@tonic-gate # ifdef __STDC__
377c478bd9Sstevel@tonic-gate #  define __P(x) x
387c478bd9Sstevel@tonic-gate # else
397c478bd9Sstevel@tonic-gate #  define __P(x) ()
407c478bd9Sstevel@tonic-gate # endif
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /* In the absence of branded types... */
447c478bd9Sstevel@tonic-gate typedef struct { void *opaque; } evConnID;
457c478bd9Sstevel@tonic-gate typedef struct { void *opaque; } evFileID;
467c478bd9Sstevel@tonic-gate typedef struct { void *opaque; } evStreamID;
477c478bd9Sstevel@tonic-gate typedef struct { void *opaque; } evTimerID;
487c478bd9Sstevel@tonic-gate typedef struct { void *opaque; } evWaitID;
497c478bd9Sstevel@tonic-gate typedef struct { void *opaque; } evContext;
507c478bd9Sstevel@tonic-gate typedef struct { void *opaque; } evEvent;
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #define	evInitID(id) ((id)->opaque = NULL)
537c478bd9Sstevel@tonic-gate #define	evTestID(id) ((id).opaque != NULL)
547c478bd9Sstevel@tonic-gate 
55*9525b14bSRao Shoaib typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
56*9525b14bSRao Shoaib 			       const void *, int));
57*9525b14bSRao Shoaib typedef void (*evFileFunc)__P((evContext, void *, int, int));
58*9525b14bSRao Shoaib typedef	void (*evStreamFunc)__P((evContext, void *, int, int));
59*9525b14bSRao Shoaib typedef void (*evTimerFunc)__P((evContext, void *,
60*9525b14bSRao Shoaib 				struct timespec, struct timespec));
61*9525b14bSRao Shoaib typedef	void (*evWaitFunc)__P((evContext, void *, const void *));
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate typedef	struct { unsigned char mask[256/8]; } evByteMask;
647c478bd9Sstevel@tonic-gate #define	EV_BYTEMASK_BYTE(b) ((b) / 8)
657c478bd9Sstevel@tonic-gate #define	EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
667c478bd9Sstevel@tonic-gate #define	EV_BYTEMASK_SET(bm, b) \
677c478bd9Sstevel@tonic-gate 	((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
687c478bd9Sstevel@tonic-gate #define	EV_BYTEMASK_CLR(bm, b) \
697c478bd9Sstevel@tonic-gate 	((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
707c478bd9Sstevel@tonic-gate #define	EV_BYTEMASK_TST(bm, b) \
717c478bd9Sstevel@tonic-gate 	((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #define	EV_POLL		1
747c478bd9Sstevel@tonic-gate #define	EV_WAIT		2
757c478bd9Sstevel@tonic-gate #define	EV_NULL		4
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate #define	EV_READ		1
787c478bd9Sstevel@tonic-gate #define	EV_WRITE	2
797c478bd9Sstevel@tonic-gate #define	EV_EXCEPT	4
807c478bd9Sstevel@tonic-gate 
81*9525b14bSRao Shoaib #define EV_WASNONBLOCKING 8	/* Internal library use. */
82*9525b14bSRao Shoaib 
837c478bd9Sstevel@tonic-gate /* eventlib.c */
847c478bd9Sstevel@tonic-gate #define evCreate	__evCreate
857c478bd9Sstevel@tonic-gate #define evSetDebug	__evSetDebug
867c478bd9Sstevel@tonic-gate #define evDestroy	__evDestroy
877c478bd9Sstevel@tonic-gate #define evGetNext	__evGetNext
887c478bd9Sstevel@tonic-gate #define evDispatch	__evDispatch
897c478bd9Sstevel@tonic-gate #define evDrop		__evDrop
907c478bd9Sstevel@tonic-gate #define evMainLoop	__evMainLoop
917c478bd9Sstevel@tonic-gate #define evHighestFD	__evHighestFD
92*9525b14bSRao Shoaib #define evGetOption	__evGetOption
93*9525b14bSRao Shoaib #define evSetOption	__evSetOption
947c478bd9Sstevel@tonic-gate 
95*9525b14bSRao Shoaib int  evCreate __P((evContext *));
96*9525b14bSRao Shoaib void evSetDebug __P((evContext, int, FILE *));
97*9525b14bSRao Shoaib int  evDestroy __P((evContext));
98*9525b14bSRao Shoaib int  evGetNext __P((evContext, evEvent *, int));
99*9525b14bSRao Shoaib int  evDispatch __P((evContext, evEvent));
100*9525b14bSRao Shoaib void evDrop __P((evContext, evEvent));
101*9525b14bSRao Shoaib int  evMainLoop __P((evContext));
102*9525b14bSRao Shoaib int  evHighestFD __P((evContext));
103*9525b14bSRao Shoaib int  evGetOption __P((evContext *, const char *, int *));
104*9525b14bSRao Shoaib int  evSetOption __P((evContext *, const char *, int));
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /* ev_connects.c */
1077c478bd9Sstevel@tonic-gate #define evListen	__evListen
1087c478bd9Sstevel@tonic-gate #define evConnect	__evConnect
1097c478bd9Sstevel@tonic-gate #define evCancelConn	__evCancelConn
1107c478bd9Sstevel@tonic-gate #define evHold		__evHold
1117c478bd9Sstevel@tonic-gate #define evUnhold	__evUnhold
1127c478bd9Sstevel@tonic-gate #define evTryAccept	__evTryAccept
1137c478bd9Sstevel@tonic-gate 
114*9525b14bSRao Shoaib int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
115*9525b14bSRao Shoaib int evConnect __P((evContext, int, const void *, int,
116*9525b14bSRao Shoaib 		   evConnFunc, void *, evConnID *));
117*9525b14bSRao Shoaib int evCancelConn __P((evContext, evConnID));
1187c478bd9Sstevel@tonic-gate int evHold __P((evContext, evConnID));
1197c478bd9Sstevel@tonic-gate int evUnhold __P((evContext, evConnID));
1207c478bd9Sstevel@tonic-gate int evTryAccept __P((evContext, evConnID, int *));
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /* ev_files.c */
1237c478bd9Sstevel@tonic-gate #define evSelectFD	__evSelectFD
1247c478bd9Sstevel@tonic-gate #define evDeselectFD	__evDeselectFD
1257c478bd9Sstevel@tonic-gate 
126*9525b14bSRao Shoaib int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
127*9525b14bSRao Shoaib int evDeselectFD __P((evContext, evFileID));
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /* ev_streams.c */
1307c478bd9Sstevel@tonic-gate #define evConsIovec	__evConsIovec
1317c478bd9Sstevel@tonic-gate #define evWrite		__evWrite
1327c478bd9Sstevel@tonic-gate #define evRead		__evRead
1337c478bd9Sstevel@tonic-gate #define evTimeRW	__evTimeRW
1347c478bd9Sstevel@tonic-gate #define evUntimeRW	__evUntimeRW
1357c478bd9Sstevel@tonic-gate #define	evCancelRW	__evCancelRW
1367c478bd9Sstevel@tonic-gate 
137*9525b14bSRao Shoaib struct iovec evConsIovec __P((void *, size_t));
138*9525b14bSRao Shoaib int evWrite __P((evContext, int, const struct iovec *, int,
139*9525b14bSRao Shoaib 		 evStreamFunc func, void *, evStreamID *));
140*9525b14bSRao Shoaib int evRead __P((evContext, int, const struct iovec *, int,
141*9525b14bSRao Shoaib 		evStreamFunc func, void *, evStreamID *));
142*9525b14bSRao Shoaib int evTimeRW __P((evContext, evStreamID, evTimerID timer));
143*9525b14bSRao Shoaib int evUntimeRW __P((evContext, evStreamID));
144*9525b14bSRao Shoaib int evCancelRW __P((evContext, evStreamID));
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /* ev_timers.c */
1477c478bd9Sstevel@tonic-gate #define evConsTime	__evConsTime
1487c478bd9Sstevel@tonic-gate #define evAddTime	__evAddTime
1497c478bd9Sstevel@tonic-gate #define evSubTime	__evSubTime
1507c478bd9Sstevel@tonic-gate #define evCmpTime	__evCmpTime
1517c478bd9Sstevel@tonic-gate #define	evTimeSpec	__evTimeSpec
1527c478bd9Sstevel@tonic-gate #define	evTimeVal	__evTimeVal
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #define evNowTime		__evNowTime
155*9525b14bSRao Shoaib #define evUTCTime		__evUTCTime
1567c478bd9Sstevel@tonic-gate #define evLastEventTime		__evLastEventTime
1577c478bd9Sstevel@tonic-gate #define evSetTimer		__evSetTimer
1587c478bd9Sstevel@tonic-gate #define evClearTimer		__evClearTimer
159*9525b14bSRao Shoaib #define evConfigTimer		__evConfigTimer
1607c478bd9Sstevel@tonic-gate #define evResetTimer		__evResetTimer
1617c478bd9Sstevel@tonic-gate #define evSetIdleTimer		__evSetIdleTimer
1627c478bd9Sstevel@tonic-gate #define evClearIdleTimer	__evClearIdleTimer
1637c478bd9Sstevel@tonic-gate #define evResetIdleTimer	__evResetIdleTimer
1647c478bd9Sstevel@tonic-gate #define evTouchIdleTimer	__evTouchIdleTimer
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate struct timespec evConsTime __P((time_t sec, long nsec));
167*9525b14bSRao Shoaib struct timespec evAddTime __P((struct timespec, struct timespec));
168*9525b14bSRao Shoaib struct timespec evSubTime __P((struct timespec, struct timespec));
1697c478bd9Sstevel@tonic-gate struct timespec evNowTime __P((void));
170*9525b14bSRao Shoaib struct timespec evUTCTime __P((void));
1717c478bd9Sstevel@tonic-gate struct timespec evLastEventTime __P((evContext));
1727c478bd9Sstevel@tonic-gate struct timespec evTimeSpec __P((struct timeval));
1737c478bd9Sstevel@tonic-gate struct timeval evTimeVal __P((struct timespec));
174*9525b14bSRao Shoaib int evCmpTime __P((struct timespec, struct timespec));
175*9525b14bSRao Shoaib int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
176*9525b14bSRao Shoaib 		    struct timespec, evTimerID *));
177*9525b14bSRao Shoaib int evClearTimer __P((evContext, evTimerID));
178*9525b14bSRao Shoaib int evConfigTimer __P((evContext, evTimerID, const char *param,
179*9525b14bSRao Shoaib 		      int value));
1807c478bd9Sstevel@tonic-gate int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
1817c478bd9Sstevel@tonic-gate 		      struct timespec, struct timespec));
1827c478bd9Sstevel@tonic-gate int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
1837c478bd9Sstevel@tonic-gate 			evTimerID *));
1847c478bd9Sstevel@tonic-gate int evClearIdleTimer __P((evContext, evTimerID));
1857c478bd9Sstevel@tonic-gate int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *,
1867c478bd9Sstevel@tonic-gate 			  struct timespec));
1877c478bd9Sstevel@tonic-gate int evTouchIdleTimer __P((evContext, evTimerID));
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate /* ev_waits.c */
1907c478bd9Sstevel@tonic-gate #define evWaitFor	__evWaitFor
1917c478bd9Sstevel@tonic-gate #define evDo		__evDo
1927c478bd9Sstevel@tonic-gate #define evUnwait	__evUnwait
1937c478bd9Sstevel@tonic-gate #define evDefer		__evDefer
1947c478bd9Sstevel@tonic-gate 
195*9525b14bSRao Shoaib int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
196*9525b14bSRao Shoaib int evDo __P((evContext, const void *));
197*9525b14bSRao Shoaib int evUnwait __P((evContext, evWaitID));
1987c478bd9Sstevel@tonic-gate int evDefer __P((evContext, evWaitFunc, void *));
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate #ifdef __EVENTLIB_P_DEFINED
2017c478bd9Sstevel@tonic-gate # undef __P
2027c478bd9Sstevel@tonic-gate #endif
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate #endif /*_EVENTLIB_H*/
205*9525b14bSRao Shoaib 
206*9525b14bSRao Shoaib /*! \file */
207