xref: /onnv-gate/usr/src/lib/libresolv2/include/isc/eventlib.h (revision 11038:74b12212b8a2)
10Sstevel@tonic-gate /*
2*11038SRao.Shoaib@Sun.COM  * Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
3*11038SRao.Shoaib@Sun.COM  * Copyright (C) 1995-1999, 2001, 2003  Internet Software Consortium.
40Sstevel@tonic-gate  *
5*11038SRao.Shoaib@Sun.COM  * Permission to use, copy, modify, and/or distribute this software for any
60Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
70Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies.
80Sstevel@tonic-gate  *
9*11038SRao.Shoaib@Sun.COM  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10*11038SRao.Shoaib@Sun.COM  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11*11038SRao.Shoaib@Sun.COM  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12*11038SRao.Shoaib@Sun.COM  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13*11038SRao.Shoaib@Sun.COM  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14*11038SRao.Shoaib@Sun.COM  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15*11038SRao.Shoaib@Sun.COM  * PERFORMANCE OF THIS SOFTWARE.
160Sstevel@tonic-gate  */
170Sstevel@tonic-gate 
180Sstevel@tonic-gate /* eventlib.h - exported interfaces for eventlib
190Sstevel@tonic-gate  * vix 09sep95 [initial]
200Sstevel@tonic-gate  *
21*11038SRao.Shoaib@Sun.COM  * $Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp $
220Sstevel@tonic-gate  */
230Sstevel@tonic-gate 
240Sstevel@tonic-gate #ifndef _EVENTLIB_H
250Sstevel@tonic-gate #define _EVENTLIB_H
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #include <sys/types.h>
280Sstevel@tonic-gate #include <sys/uio.h>
290Sstevel@tonic-gate #include <sys/time.h>
300Sstevel@tonic-gate #include <stdio.h>
310Sstevel@tonic-gate 
32*11038SRao.Shoaib@Sun.COM #include <isc/platform.h>
33*11038SRao.Shoaib@Sun.COM 
340Sstevel@tonic-gate #ifndef __P
350Sstevel@tonic-gate # define __EVENTLIB_P_DEFINED
360Sstevel@tonic-gate # ifdef __STDC__
370Sstevel@tonic-gate #  define __P(x) x
380Sstevel@tonic-gate # else
390Sstevel@tonic-gate #  define __P(x) ()
400Sstevel@tonic-gate # endif
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /* In the absence of branded types... */
440Sstevel@tonic-gate typedef struct { void *opaque; } evConnID;
450Sstevel@tonic-gate typedef struct { void *opaque; } evFileID;
460Sstevel@tonic-gate typedef struct { void *opaque; } evStreamID;
470Sstevel@tonic-gate typedef struct { void *opaque; } evTimerID;
480Sstevel@tonic-gate typedef struct { void *opaque; } evWaitID;
490Sstevel@tonic-gate typedef struct { void *opaque; } evContext;
500Sstevel@tonic-gate typedef struct { void *opaque; } evEvent;
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #define	evInitID(id) ((id)->opaque = NULL)
530Sstevel@tonic-gate #define	evTestID(id) ((id).opaque != NULL)
540Sstevel@tonic-gate 
55*11038SRao.Shoaib@Sun.COM typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
56*11038SRao.Shoaib@Sun.COM 			       const void *, int));
57*11038SRao.Shoaib@Sun.COM typedef void (*evFileFunc)__P((evContext, void *, int, int));
58*11038SRao.Shoaib@Sun.COM typedef	void (*evStreamFunc)__P((evContext, void *, int, int));
59*11038SRao.Shoaib@Sun.COM typedef void (*evTimerFunc)__P((evContext, void *,
60*11038SRao.Shoaib@Sun.COM 				struct timespec, struct timespec));
61*11038SRao.Shoaib@Sun.COM typedef	void (*evWaitFunc)__P((evContext, void *, const void *));
620Sstevel@tonic-gate 
630Sstevel@tonic-gate typedef	struct { unsigned char mask[256/8]; } evByteMask;
640Sstevel@tonic-gate #define	EV_BYTEMASK_BYTE(b) ((b) / 8)
650Sstevel@tonic-gate #define	EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
660Sstevel@tonic-gate #define	EV_BYTEMASK_SET(bm, b) \
670Sstevel@tonic-gate 	((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
680Sstevel@tonic-gate #define	EV_BYTEMASK_CLR(bm, b) \
690Sstevel@tonic-gate 	((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
700Sstevel@tonic-gate #define	EV_BYTEMASK_TST(bm, b) \
710Sstevel@tonic-gate 	((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #define	EV_POLL		1
740Sstevel@tonic-gate #define	EV_WAIT		2
750Sstevel@tonic-gate #define	EV_NULL		4
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #define	EV_READ		1
780Sstevel@tonic-gate #define	EV_WRITE	2
790Sstevel@tonic-gate #define	EV_EXCEPT	4
800Sstevel@tonic-gate 
81*11038SRao.Shoaib@Sun.COM #define EV_WASNONBLOCKING 8	/* Internal library use. */
82*11038SRao.Shoaib@Sun.COM 
830Sstevel@tonic-gate /* eventlib.c */
840Sstevel@tonic-gate #define evCreate	__evCreate
850Sstevel@tonic-gate #define evSetDebug	__evSetDebug
860Sstevel@tonic-gate #define evDestroy	__evDestroy
870Sstevel@tonic-gate #define evGetNext	__evGetNext
880Sstevel@tonic-gate #define evDispatch	__evDispatch
890Sstevel@tonic-gate #define evDrop		__evDrop
900Sstevel@tonic-gate #define evMainLoop	__evMainLoop
910Sstevel@tonic-gate #define evHighestFD	__evHighestFD
92*11038SRao.Shoaib@Sun.COM #define evGetOption	__evGetOption
93*11038SRao.Shoaib@Sun.COM #define evSetOption	__evSetOption
940Sstevel@tonic-gate 
95*11038SRao.Shoaib@Sun.COM int  evCreate __P((evContext *));
96*11038SRao.Shoaib@Sun.COM void evSetDebug __P((evContext, int, FILE *));
97*11038SRao.Shoaib@Sun.COM int  evDestroy __P((evContext));
98*11038SRao.Shoaib@Sun.COM int  evGetNext __P((evContext, evEvent *, int));
99*11038SRao.Shoaib@Sun.COM int  evDispatch __P((evContext, evEvent));
100*11038SRao.Shoaib@Sun.COM void evDrop __P((evContext, evEvent));
101*11038SRao.Shoaib@Sun.COM int  evMainLoop __P((evContext));
102*11038SRao.Shoaib@Sun.COM int  evHighestFD __P((evContext));
103*11038SRao.Shoaib@Sun.COM int  evGetOption __P((evContext *, const char *, int *));
104*11038SRao.Shoaib@Sun.COM int  evSetOption __P((evContext *, const char *, int));
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate /* ev_connects.c */
1070Sstevel@tonic-gate #define evListen	__evListen
1080Sstevel@tonic-gate #define evConnect	__evConnect
1090Sstevel@tonic-gate #define evCancelConn	__evCancelConn
1100Sstevel@tonic-gate #define evHold		__evHold
1110Sstevel@tonic-gate #define evUnhold	__evUnhold
1120Sstevel@tonic-gate #define evTryAccept	__evTryAccept
1130Sstevel@tonic-gate 
114*11038SRao.Shoaib@Sun.COM int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
115*11038SRao.Shoaib@Sun.COM int evConnect __P((evContext, int, const void *, int,
116*11038SRao.Shoaib@Sun.COM 		   evConnFunc, void *, evConnID *));
117*11038SRao.Shoaib@Sun.COM int evCancelConn __P((evContext, evConnID));
1180Sstevel@tonic-gate int evHold __P((evContext, evConnID));
1190Sstevel@tonic-gate int evUnhold __P((evContext, evConnID));
1200Sstevel@tonic-gate int evTryAccept __P((evContext, evConnID, int *));
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate /* ev_files.c */
1230Sstevel@tonic-gate #define evSelectFD	__evSelectFD
1240Sstevel@tonic-gate #define evDeselectFD	__evDeselectFD
1250Sstevel@tonic-gate 
126*11038SRao.Shoaib@Sun.COM int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
127*11038SRao.Shoaib@Sun.COM int evDeselectFD __P((evContext, evFileID));
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate /* ev_streams.c */
1300Sstevel@tonic-gate #define evConsIovec	__evConsIovec
1310Sstevel@tonic-gate #define evWrite		__evWrite
1320Sstevel@tonic-gate #define evRead		__evRead
1330Sstevel@tonic-gate #define evTimeRW	__evTimeRW
1340Sstevel@tonic-gate #define evUntimeRW	__evUntimeRW
1350Sstevel@tonic-gate #define	evCancelRW	__evCancelRW
1360Sstevel@tonic-gate 
137*11038SRao.Shoaib@Sun.COM struct iovec evConsIovec __P((void *, size_t));
138*11038SRao.Shoaib@Sun.COM int evWrite __P((evContext, int, const struct iovec *, int,
139*11038SRao.Shoaib@Sun.COM 		 evStreamFunc func, void *, evStreamID *));
140*11038SRao.Shoaib@Sun.COM int evRead __P((evContext, int, const struct iovec *, int,
141*11038SRao.Shoaib@Sun.COM 		evStreamFunc func, void *, evStreamID *));
142*11038SRao.Shoaib@Sun.COM int evTimeRW __P((evContext, evStreamID, evTimerID timer));
143*11038SRao.Shoaib@Sun.COM int evUntimeRW __P((evContext, evStreamID));
144*11038SRao.Shoaib@Sun.COM int evCancelRW __P((evContext, evStreamID));
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /* ev_timers.c */
1470Sstevel@tonic-gate #define evConsTime	__evConsTime
1480Sstevel@tonic-gate #define evAddTime	__evAddTime
1490Sstevel@tonic-gate #define evSubTime	__evSubTime
1500Sstevel@tonic-gate #define evCmpTime	__evCmpTime
1510Sstevel@tonic-gate #define	evTimeSpec	__evTimeSpec
1520Sstevel@tonic-gate #define	evTimeVal	__evTimeVal
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate #define evNowTime		__evNowTime
155*11038SRao.Shoaib@Sun.COM #define evUTCTime		__evUTCTime
1560Sstevel@tonic-gate #define evLastEventTime		__evLastEventTime
1570Sstevel@tonic-gate #define evSetTimer		__evSetTimer
1580Sstevel@tonic-gate #define evClearTimer		__evClearTimer
159*11038SRao.Shoaib@Sun.COM #define evConfigTimer		__evConfigTimer
1600Sstevel@tonic-gate #define evResetTimer		__evResetTimer
1610Sstevel@tonic-gate #define evSetIdleTimer		__evSetIdleTimer
1620Sstevel@tonic-gate #define evClearIdleTimer	__evClearIdleTimer
1630Sstevel@tonic-gate #define evResetIdleTimer	__evResetIdleTimer
1640Sstevel@tonic-gate #define evTouchIdleTimer	__evTouchIdleTimer
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate struct timespec evConsTime __P((time_t sec, long nsec));
167*11038SRao.Shoaib@Sun.COM struct timespec evAddTime __P((struct timespec, struct timespec));
168*11038SRao.Shoaib@Sun.COM struct timespec evSubTime __P((struct timespec, struct timespec));
1690Sstevel@tonic-gate struct timespec evNowTime __P((void));
170*11038SRao.Shoaib@Sun.COM struct timespec evUTCTime __P((void));
1710Sstevel@tonic-gate struct timespec evLastEventTime __P((evContext));
1720Sstevel@tonic-gate struct timespec evTimeSpec __P((struct timeval));
1730Sstevel@tonic-gate struct timeval evTimeVal __P((struct timespec));
174*11038SRao.Shoaib@Sun.COM int evCmpTime __P((struct timespec, struct timespec));
175*11038SRao.Shoaib@Sun.COM int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
176*11038SRao.Shoaib@Sun.COM 		    struct timespec, evTimerID *));
177*11038SRao.Shoaib@Sun.COM int evClearTimer __P((evContext, evTimerID));
178*11038SRao.Shoaib@Sun.COM int evConfigTimer __P((evContext, evTimerID, const char *param,
179*11038SRao.Shoaib@Sun.COM 		      int value));
1800Sstevel@tonic-gate int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
1810Sstevel@tonic-gate 		      struct timespec, struct timespec));
1820Sstevel@tonic-gate int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
1830Sstevel@tonic-gate 			evTimerID *));
1840Sstevel@tonic-gate int evClearIdleTimer __P((evContext, evTimerID));
1850Sstevel@tonic-gate int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *,
1860Sstevel@tonic-gate 			  struct timespec));
1870Sstevel@tonic-gate int evTouchIdleTimer __P((evContext, evTimerID));
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /* ev_waits.c */
1900Sstevel@tonic-gate #define evWaitFor	__evWaitFor
1910Sstevel@tonic-gate #define evDo		__evDo
1920Sstevel@tonic-gate #define evUnwait	__evUnwait
1930Sstevel@tonic-gate #define evDefer		__evDefer
1940Sstevel@tonic-gate 
195*11038SRao.Shoaib@Sun.COM int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
196*11038SRao.Shoaib@Sun.COM int evDo __P((evContext, const void *));
197*11038SRao.Shoaib@Sun.COM int evUnwait __P((evContext, evWaitID));
1980Sstevel@tonic-gate int evDefer __P((evContext, evWaitFunc, void *));
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate #ifdef __EVENTLIB_P_DEFINED
2010Sstevel@tonic-gate # undef __P
2020Sstevel@tonic-gate #endif
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate #endif /*_EVENTLIB_H*/
205*11038SRao.Shoaib@Sun.COM 
206*11038SRao.Shoaib@Sun.COM /*! \file */
207