Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / isc / include / isc / event.h
blobf3cca874c78789da5d1594119892d96084674c59
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2002 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: event.h,v 1.24.2.4 2004/04/15 02:16:29 marka Exp $ */
20 #ifndef ISC_EVENT_H
21 #define ISC_EVENT_H 1
23 #include <isc/lang.h>
24 #include <isc/types.h>
26 /*****
27 ***** Events.
28 *****/
30 typedef void (*isc_eventdestructor_t)(isc_event_t *);
32 #define ISC_EVENT_COMMON(ltype) \
33 size_t ev_size; \
34 unsigned int ev_attributes; \
35 void * ev_tag; \
36 isc_eventtype_t ev_type; \
37 isc_taskaction_t ev_action; \
38 void * ev_arg; \
39 void * ev_sender; \
40 isc_eventdestructor_t ev_destroy; \
41 void * ev_destroy_arg; \
42 ISC_LINK(ltype) ev_link
45 * Attributes matching a mask of 0x000000ff are reserved for the task library's
46 * definition. Attributes of 0xffffff00 may be used by the application
47 * or non-ISC libraries.
49 #define ISC_EVENTATTR_NOPURGE 0x00000001
52 * The ISC_EVENTATTR_CANCELED attribute is intended to indicate
53 * that an event is delivered as a result of a canceled operation
54 * rather than successful completion, by mutual agreement
55 * between the sender and receiver. It is not set or used by
56 * the task system.
58 #define ISC_EVENTATTR_CANCELED 0x00000002
60 #define ISC_EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da) \
61 do { \
62 (event)->ev_size = (sz); \
63 (event)->ev_attributes = (at); \
64 (event)->ev_tag = (ta); \
65 (event)->ev_type = (ty); \
66 (event)->ev_action = (ac); \
67 (event)->ev_arg = (ar); \
68 (event)->ev_sender = (sn); \
69 (event)->ev_destroy = (df); \
70 (event)->ev_destroy_arg = (da); \
71 ISC_LINK_INIT((event), ev_link); \
72 } while (0)
75 * This structure is public because "subclassing" it may be useful when
76 * defining new event types.
78 struct isc_event {
79 ISC_EVENT_COMMON(struct isc_event);
82 #define ISC_EVENTTYPE_FIRSTEVENT 0x00000000
83 #define ISC_EVENTTYPE_LASTEVENT 0xffffffff
85 #define ISC_EVENT_PTR(p) ((isc_event_t **)(void *)(p))
87 ISC_LANG_BEGINDECLS
89 isc_event_t *
90 isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
91 isc_taskaction_t action, const void *arg, size_t size);
93 * Allocate and initialize in a structure with initial elements
94 * defined by:
96 * struct {
97 * ISC_EVENT_COMMON(struct isc_event);
98 * ...
99 * };
101 * Requires:
102 * 'size' >= sizeof(struct isc_event)
103 * 'action' to be non NULL
105 * Returns:
106 * a pointer to a initialized structure of the requested size.
107 * NULL if unable to allocate memory.
110 void
111 isc_event_free(isc_event_t **);
113 ISC_LANG_ENDDECLS
115 #endif /* ISC_EVENT_H */