Electroneum
ub_event.h
Go to the documentation of this file.
1 /*
2  * util/ub_event.h - indirection layer for pluggable events
3  *
4  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
43 #ifndef UB_EVENT_H
44 #define UB_EVENT_H
45 
46 struct ub_event_base;
47 struct ub_event;
48 struct comm_base;
49 struct event_base;
50 
52 #define UB_EV_TIMEOUT 0x01
53 
54 #define UB_EV_READ 0x02
55 
56 #define UB_EV_WRITE 0x04
57 
58 #define UB_EV_SIGNAL 0x08
59 
60 #define UB_EV_PERSIST 0x10
61 
66 const char* ub_event_get_version(void);
68 void ub_get_event_sys(struct ub_event_base*, const char** n, const char** s,
69  const char** m);
73 struct ub_event_base* ub_default_event_base(int, time_t*, struct timeval*);
75 struct ub_event_base* ub_libevent_event_base(struct event_base*);
79 struct event_base* ub_libevent_get_event_base(struct ub_event_base*);
81 void ub_event_base_free(struct ub_event_base*);
86 
88 struct ub_event* ub_event_new(struct ub_event_base*,
89  int fd, short bits, void (*cb)(int, short, void*), void* arg);
91 struct ub_event* ub_signal_new(struct ub_event_base*, int fd,
92  void (*cb)(int, short, void*), void* arg);
95  void* wsaevent, void (*cb)(int, short, void*), void* arg);
96 
98 void ub_event_add_bits(struct ub_event*, short bits);
100 void ub_event_del_bits(struct ub_event*, short bits);
102 void ub_event_set_fd(struct ub_event*, int fd);
104 void ub_event_free(struct ub_event*);
106 int ub_event_add(struct ub_event*, struct timeval*);
108 int ub_event_del(struct ub_event*);
110 int ub_timer_add(struct ub_event*, struct ub_event_base*,
111  void (*cb)(int, short, void*), void* arg, struct timeval*);
113 int ub_timer_del(struct ub_event*);
115 int ub_signal_add(struct ub_event*, struct timeval*);
117 int ub_signal_del(struct ub_event*);
123 void ub_winsock_tcp_wouldblock(struct ub_event*, int bits);
125 void ub_comm_base_now(struct comm_base* cb);
126 
127 #endif /* UB_EVENT_H */
void ub_comm_base_now(struct comm_base *cb)
void ub_event_base_free(struct ub_event_base *)
const char * ub_event_get_version(void)
int ub_timer_add(struct ub_event *, struct ub_event_base *, void(*cb)(int, short, void *), void *arg, struct timeval *)
int ub_timer_del(struct ub_event *)
int ub_event_del(struct ub_event *)
int ub_event_base_dispatch(struct ub_event_base *)
struct ub_event * ub_signal_new(struct ub_event_base *, int fd, void(*cb)(int, short, void *), void *arg)
void ub_event_del_bits(struct ub_event *, short bits)
int ub_event_base_loopexit(struct ub_event_base *)
struct event_base * ub_libevent_get_event_base(struct ub_event_base *)
struct ub_event * ub_winsock_register_wsaevent(struct ub_event_base *, void *wsaevent, void(*cb)(int, short, void *), void *arg)
int ub_event_add(struct ub_event *, struct timeval *)
struct ub_event_base * ub_libevent_event_base(struct event_base *)
struct ub_event_base * ub_default_event_base(int, time_t *, struct timeval *)
void ub_event_set_fd(struct ub_event *, int fd)
void ub_get_event_sys(struct ub_event_base *, const char **n, const char **s, const char **m)
int ub_signal_add(struct ub_event *, struct timeval *)
struct ub_event * ub_event_new(struct ub_event_base *, int fd, short bits, void(*cb)(int, short, void *), void *arg)
void ub_event_free(struct ub_event *)
void ub_winsock_tcp_wouldblock(struct ub_event *, int bits)
void ub_event_add_bits(struct ub_event *, short bits)
void ub_winsock_unregister_wsaevent(struct ub_event *ev)
int ub_signal_del(struct ub_event *)
unsigned int bits[ATOMS]
Definition: rctTypes.h:136