author | Tero Marttila <terom@fixme.fi> |
Thu, 28 May 2009 01:17:36 +0300 | |
branch | new-lib-errors |
changeset 219 | cefec18b8268 |
parent 176 | src/transport_fd.h@6750d50ee8cd |
permissions | -rw-r--r-- |
219
cefec18b8268
some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents:
176
diff
changeset
|
1 |
#ifndef LIBQMSK_TRANSPORT_FD_H |
cefec18b8268
some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents:
176
diff
changeset
|
2 |
#define LIBQMSK_TRANSPORT_FD_H |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
3 |
|
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
/** |
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
* @file |
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
* |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
7 |
* Support for transport implementations that use POSIX file descriptor streams. |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
8 |
* |
165 | 9 |
* This provides the read/write methods, as well as functions to implement the event-based behaviour. |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
*/ |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
11 |
#include "transport_internal.h" |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
12 |
|
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
#include <event2/event.h> |
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
#include <stdbool.h> |
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
|
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
16 |
// forward-declare |
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
17 |
struct transport_fd; |
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
18 |
|
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
/** |
159
d3e253d7281a
implement heirarchial type-checking for transport_check
Tero Marttila <terom@fixme.fi>
parents:
157
diff
changeset
|
20 |
* Our transport_type |
d3e253d7281a
implement heirarchial type-checking for transport_check
Tero Marttila <terom@fixme.fi>
parents:
157
diff
changeset
|
21 |
*/ |
d3e253d7281a
implement heirarchial type-checking for transport_check
Tero Marttila <terom@fixme.fi>
parents:
157
diff
changeset
|
22 |
extern const struct transport_type transport_fd_type; |
d3e253d7281a
implement heirarchial type-checking for transport_check
Tero Marttila <terom@fixme.fi>
parents:
157
diff
changeset
|
23 |
|
d3e253d7281a
implement heirarchial type-checking for transport_check
Tero Marttila <terom@fixme.fi>
parents:
157
diff
changeset
|
24 |
/** |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
25 |
* Low-level callback |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
*/ |
156
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
27 |
typedef void (*transport_fd_callback_func) (struct transport_fd *fd, short what, void *arg); |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
28 |
|
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
29 |
/** |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
30 |
* The fd-based transport implementation |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
31 |
*/ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
32 |
struct transport_fd { |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
33 |
/** Base transport state */ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
34 |
struct transport base; |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
35 |
|
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
36 |
/** Libevent base to use */ |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
37 |
struct event_base *ev_base; |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
|
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
39 |
/** OS file descriptor */ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
40 |
evutil_socket_t fd; |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
|
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
42 |
/** IO events */ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
43 |
struct event *ev_read, *ev_write; |
118
05b8d5150313
implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
44 |
|
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
45 |
/** Low-level callback */ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
46 |
transport_fd_callback_func cb_func; |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
47 |
|
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
48 |
/** Callback context argument */ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
49 |
void *cb_arg; |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
|
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
51 |
}; |
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
|
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
53 |
/** |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
54 |
* Get a transport_t pointer from a transport_fd |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
55 |
*/ |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
56 |
#define TRANSPORT_FD_BASE(tp_ptr) (&(tp_ptr)->base) |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
57 |
|
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
58 |
/** |
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
59 |
* Invalid OS FD |
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
60 |
*/ |
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
61 |
#define TRANSPORT_FD_INVALID ((evutil_socket_t) -1) |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
62 |
|
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
63 |
/** |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
64 |
* Implementation of transport_methods::read |
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
65 |
*/ |
176
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
66 |
err_t transport_fd__read (transport_t *transport, void *buf, size_t *len, error_t *err); |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
67 |
|
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
68 |
/** |
156
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
69 |
* Implementation of transport_methods::write. |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
70 |
* |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
71 |
* If this gets EAGAIN, it will automatically enable the write event, unless masked out. |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
72 |
*/ |
176
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
73 |
err_t transport_fd__write (transport_t *transport, const void *buf, size_t *len, error_t *err); |
156
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
74 |
|
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
75 |
/** |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
76 |
* Implementation of transport_methods::events. |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
77 |
* |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
78 |
* For TRANSPORT_READ, this will simply apply enable/disable as given. |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
79 |
* |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
80 |
* For TRANSPORT_WRITE, the write event will only be enabled if given in the mask, *and* the ev_write event is currently |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
81 |
* active (via transport_fd_methods_write()); otherwise, the write event will not be enabled. |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
82 |
*/ |
176
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
83 |
err_t transport_fd__events (transport_t *transport, short mask, error_t *err); |
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
84 |
|
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
85 |
/** |
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
86 |
* Implementation of transport_methods::deinit. |
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
87 |
* |
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
88 |
* This simply calls transport_fd_deinit(). |
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
89 |
*/ |
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
90 |
void transport_fd__deinit (transport_t *transport); |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
91 |
|
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
92 |
/** |
156
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
93 |
* A transport_fd_callback_func that simply invokes the transport_callback user functions. |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
94 |
* |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
95 |
* Register with a NULL cb_arg. |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
96 |
*/ |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
97 |
void transport_fd_callback_user (struct transport_fd *fd, short what, void *arg); |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
98 |
|
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
99 |
|
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
100 |
|
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
101 |
|
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
102 |
/** |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
103 |
* Initialize the transport_fd to use the given, connected fd, or TRANSPORT_FD_INVALID if we don't yet have an fd. |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
104 |
* |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
105 |
* It is an error to call this if the transport_fd already has an fd set |
165 | 106 |
* |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
107 |
* @param fd the transport_fd state |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
108 |
* @param ev_base the libevent base to use |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
109 |
* @param _fd the OS file descriptor, or TRANSPORT_FD_INVALID |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
110 |
*/ |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
111 |
void transport_fd_init (struct transport_fd *fd, struct event_base *ev_base, int _fd); |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
112 |
|
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
113 |
/** |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
114 |
* Set the fd's nonblocking mode using fcntl. |
118
05b8d5150313
implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
115 |
*/ |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
116 |
err_t transport_fd_nonblock (struct transport_fd *fd, bool nonblock); |
118
05b8d5150313
implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
117 |
|
05b8d5150313
implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
118 |
/** |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
119 |
* Set or replace the fd's event callback. The callback will not be enabled. |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
120 |
* |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
121 |
* The transport must have a valid fd bound to it. |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
122 |
*/ |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
123 |
err_t transport_fd_setup (struct transport_fd *fd, transport_fd_callback_func cb_func, void *cb_arg); |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
124 |
|
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
125 |
/** |
157 | 126 |
* Enable the specified events, any of { TRANSPORT_READ, TRANSPORT_WRITE }. |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
127 |
*/ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
128 |
err_t transport_fd_enable (struct transport_fd *fd, short mask); |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
129 |
|
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
130 |
/** |
165 | 131 |
* Disable the specified events, any of { TRANSPORT_READ, TRANSPORT_WRITE }. |
156
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
132 |
*/ |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
133 |
err_t transport_fd_disable (struct transport_fd *fd, short mask); |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
134 |
|
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
135 |
/** |
157 | 136 |
* Set the enable/disable state of our events to the given mask. |
156
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
137 |
*/ |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
138 |
err_t transport_fd_events (struct transport_fd *fd, short mask); |
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
139 |
|
6534a4ac957b
add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents:
155
diff
changeset
|
140 |
/** |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
141 |
* Remove any old event callback present, so it will not be called anymore. |
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
142 |
* |
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
143 |
* It is perfectly safe to call this without any callbacks installed. |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
144 |
*/ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
145 |
void transport_fd_clear (struct transport_fd *fd); |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
146 |
|
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
147 |
/** |
157 | 148 |
* Setup and enable the default event handlers for transport operation, that is, use transport_fd_callback_user as the |
149 |
* callback and enable TRANSPORT_READ, unless masked out. |
|
150 |
*/ |
|
151 |
err_t transport_fd_defaults (struct transport_fd *fd); |
|
152 |
||
153 |
/** |
|
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
154 |
* Replace the old fd with a new one, maintaining any event callbacks set with transport_fd_callback. If any events were |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
155 |
* enabled before, they are not enabled anymore. |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
156 |
*/ |
219
cefec18b8268
some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents:
176
diff
changeset
|
157 |
err_t transport_fd_set (struct transport_fd *fd, int _fd, error_t *err); |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
158 |
|
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
159 |
/** |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
160 |
* Close an opened fd, releasing all resources within our state. |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
161 |
*/ |
219
cefec18b8268
some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents:
176
diff
changeset
|
162 |
err_t transport_fd_close (struct transport_fd *fd, error_t *err); |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
163 |
|
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
164 |
/** |
176
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
165 |
* Deinitialize the transport_fd. |
165 | 166 |
* |
167 |
* This logs a warning if the close() fails. |
|
168 |
* |
|
169 |
* XXX: this may actually block, I think? SO_LINGER? |
|
155
c59d3eaff0fb
most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents:
154
diff
changeset
|
170 |
*/ |
176
6750d50ee8cd
modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents:
165
diff
changeset
|
171 |
void transport_fd_deinit (struct transport_fd *fd); |
117
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
172 |
|
9cb405164250
move irc_log.c to modules/irc_log.c, and restructure sock_* to split the basic fd-level stuff out of sock_tcp and into sock_fd
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
173 |
#endif |