1 | /* |
2 | * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu> |
3 | * Copyright (c) 2007-2012 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 | #ifndef EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ |
28 | #define EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ |
29 | |
30 | /** @file event2/bufferevent_struct.h |
31 | |
32 | Data structures for bufferevents. Using these structures may hurt forward |
33 | compatibility with later versions of Libevent: be careful! |
34 | |
35 | @deprecated Use of bufferevent_struct.h is completely deprecated; these |
36 | structures are only exposed for backward compatibility with programs |
37 | written before Libevent 2.0 that used them. |
38 | */ |
39 | |
40 | #ifdef __cplusplus |
41 | extern "C" { |
42 | #endif |
43 | |
44 | #include <event2/event-config.h> |
45 | #ifdef EVENT__HAVE_SYS_TYPES_H |
46 | #include <sys/types.h> |
47 | #endif |
48 | #ifdef EVENT__HAVE_SYS_TIME_H |
49 | #include <sys/time.h> |
50 | #endif |
51 | |
52 | /* For int types. */ |
53 | #include <event2/util.h> |
54 | /* For struct event */ |
55 | #include <event2/event_struct.h> |
56 | |
57 | struct event_watermark { |
58 | size_t low; |
59 | size_t high; |
60 | }; |
61 | |
62 | /** |
63 | Shared implementation of a bufferevent. |
64 | |
65 | This type is exposed only because it was exposed in previous versions, |
66 | and some people's code may rely on manipulating it. Otherwise, you |
67 | should really not rely on the layout, size, or contents of this structure: |
68 | it is fairly volatile, and WILL change in future versions of the code. |
69 | **/ |
70 | struct bufferevent { |
71 | /** Event base for which this bufferevent was created. */ |
72 | struct event_base *ev_base; |
73 | /** Pointer to a table of function pointers to set up how this |
74 | bufferevent behaves. */ |
75 | const struct bufferevent_ops *be_ops; |
76 | |
77 | /** A read event that triggers when a timeout has happened or a socket |
78 | is ready to read data. Only used by some subtypes of |
79 | bufferevent. */ |
80 | struct event ev_read; |
81 | /** A write event that triggers when a timeout has happened or a socket |
82 | is ready to write data. Only used by some subtypes of |
83 | bufferevent. */ |
84 | struct event ev_write; |
85 | |
86 | /** An input buffer. Only the bufferevent is allowed to add data to |
87 | this buffer, though the user is allowed to drain it. */ |
88 | struct evbuffer *input; |
89 | |
90 | /** An input buffer. Only the bufferevent is allowed to drain data |
91 | from this buffer, though the user is allowed to add it. */ |
92 | struct evbuffer *output; |
93 | |
94 | struct event_watermark wm_read; |
95 | struct event_watermark wm_write; |
96 | |
97 | bufferevent_data_cb readcb; |
98 | bufferevent_data_cb writecb; |
99 | /* This should be called 'eventcb', but renaming it would break |
100 | * backward compatibility */ |
101 | bufferevent_event_cb errorcb; |
102 | void *cbarg; |
103 | |
104 | struct timeval timeout_read; |
105 | struct timeval timeout_write; |
106 | |
107 | /** Events that are currently enabled: currently EV_READ and EV_WRITE |
108 | are supported. */ |
109 | short enabled; |
110 | }; |
111 | |
112 | #ifdef __cplusplus |
113 | } |
114 | #endif |
115 | |
116 | #endif /* EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ */ |
117 | |