1 /*
2  * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
3  * Copyright (c) 2007-2011 Niels Provos and Nick Mathewson
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  *   derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /** @file event2/event_struct.h
29 
30   Structures used by event.h.  Using these structures directly WILL harm
31   forward compatibility: be careful.
32 
33   No field declared in this file should be used directly in user code.  Except
34   for historical reasons, these fields would not be exposed at all.
35  */
36 module deimos.event2.event_struct;
37 
38 import deimos.event2._d_util;
39 
40 extern (C):
41 nothrow:
42 
43 
44 /* For int types. */
45 public import deimos.event2.util;
46 
47 /* For evkeyvalq */
48 public import deimos.event2.keyvalq_struct;
49 
50 import deimos.event2._tailq;
51 
52 enum EVLIST_TIMEOUT = 0x01;
53 enum EVLIST_INSERTED = 0x02;
54 enum EVLIST_SIGNAL = 0x04;
55 enum EVLIST_ACTIVE = 0x08;
56 enum EVLIST_INTERNAL = 0x10;
57 enum EVLIST_INIT = 0x80;
58 
59 /* EVLIST_X_ Private space: 0x1000-0xf000 */
60 enum EVLIST_ALL = (0xf000 | 0x9f);
61 
62 struct event_base;
63 struct event {
64 	TAILQ_ENTRY!event ev_active_next;
65 	TAILQ_ENTRY!event ev_next;
66 	/* for managing timeouts */
67 	union ev_timeout_pos_ {
68 		TAILQ_ENTRY!event ev_next_with_common_timeout;
69 		int min_heap_idx;
70 	}
71 	ev_timeout_pos_ ev_timeout_pos;
72 	evutil_socket_t ev_fd;
73 
74 	event_base* ev_base;
75 
76 	union _ev_ {
77 		/* used for io events */
78 		struct ev_io_ {
79 			TAILQ_ENTRY!event ev_io_next;
80 			timeval ev_timeout;
81 		}
82 		ev_io_ ev_io;
83 
84 		/* used by signal events */
85 		struct ev_signal_ {
86 			TAILQ_ENTRY!event ev_signal_next;
87 			short ev_ncalls;
88 			/* Allows deletes in callback */
89 			short* ev_pncalls;
90 		}
91 		ev_signal_ ev_signal;
92 	}
93 	_ev_ _ev;
94 
95 	short ev_events;
96 	short ev_res;		/* result passed to event callback */
97 	short ev_flags;
98 	ev_uint8_t ev_pri;	/* smaller numbers are higher priority */
99 	ev_uint8_t ev_closure;
100 	timeval ev_timeout;
101 
102 	/* allows us to adopt for different types of events */
103 	ExternC!(void function(evutil_socket_t, short, void* arg)) ev_callback;
104 	void* ev_arg;
105 };
106 
107 mixin TAILQ_HEAD!("event_list", event);