equal
deleted
inserted
replaced
237 static struct line_proto_callbacks irc_conn_lp_callbacks = { |
237 static struct line_proto_callbacks irc_conn_lp_callbacks = { |
238 .on_line = &irc_conn_on_line, |
238 .on_line = &irc_conn_on_line, |
239 .on_error = &irc_conn_on_error, |
239 .on_error = &irc_conn_on_error, |
240 }; |
240 }; |
241 |
241 |
242 err_t irc_conn_create (struct irc_conn **conn_ptr, struct sock_stream *sock, const struct irc_conn_callbacks *callbacks, |
242 // XXX: ugly hack to get at an event_base |
243 void *cb_arg, struct error_info *err) |
243 #include "sock_internal.h" |
|
244 |
|
245 struct event_base **ev_base_ptr = &_sock_stream_ctx.ev_base; |
|
246 |
|
247 err_t irc_conn_create (struct irc_conn **conn_ptr, transport_t *transport, const struct irc_conn_callbacks *callbacks, |
|
248 void *cb_arg, error_t *err) |
244 { |
249 { |
245 struct irc_conn *conn; |
250 struct irc_conn *conn; |
246 |
251 |
247 // alloc new state struct |
252 // alloc new state struct |
248 if ((conn = calloc(1, sizeof(struct irc_conn))) == NULL) |
253 if ((conn = calloc(1, sizeof(struct irc_conn))) == NULL) |
262 || (ERROR_CODE(err) = irc_cmd_add(&conn->ctcp_handlers, irc_conn_ctcp_handlers, conn)) |
267 || (ERROR_CODE(err) = irc_cmd_add(&conn->ctcp_handlers, irc_conn_ctcp_handlers, conn)) |
263 ) |
268 ) |
264 goto error; |
269 goto error; |
265 |
270 |
266 // create the line_proto, with our on_line handler |
271 // create the line_proto, with our on_line handler |
267 if (line_proto_create(&conn->lp, sock, IRC_LINE_MAX * 1.5, &irc_conn_lp_callbacks, conn, err)) |
272 if (line_proto_create(&conn->lp, transport, IRC_LINE_MAX * 1.5, &irc_conn_lp_callbacks, conn, err)) |
268 goto error; |
273 goto error; |
269 |
274 |
270 // create the outgoing line queue |
275 // create the outgoing line queue |
271 if (irc_queue_create(&conn->out_queue, conn->lp, err)) |
276 if (irc_queue_create(&conn->out_queue, *ev_base_ptr, conn->lp, err)) |
272 goto error; |
277 goto error; |
273 |
278 |
274 // ok |
279 // ok |
275 *conn_ptr = conn; |
280 *conn_ptr = conn; |
276 |
281 |