--- a/src/line_proto.c Sat Feb 28 21:39:15 2009 +0200
+++ b/src/line_proto.c Sat Feb 28 22:47:39 2009 +0200
@@ -103,8 +103,11 @@
lp->cb_arg = cb_arg;
// initialize event-based stuff
- sock_stream_event_init(sock, &line_proto_sock_stream_callbacks, lp);
- line_proto_schedule_events(lp, EV_READ);
+ if (
+ sock_stream_event_init(sock, &line_proto_sock_stream_callbacks, lp)
+ || line_proto_schedule_events(lp, EV_READ)
+ )
+ return ERROR_CODE(&lp->err);
// return
*lp_ptr = lp;
@@ -214,6 +217,25 @@
return SUCCESS;
}
+int line_proto_write (struct line_proto *lp, const char *line)
+{
+ int ret;
+ size_t len = strlen(line);
+
+ // XXX: no output buffers for now :)
+ if ((ret = sock_stream_write(lp->sock, line, len)) < 0)
+ RETURN_SET_ERROR_INFO(&lp->err, sock_stream_error(lp->sock));
+
+ // EAGAIN or partial?
+ if (ret < len) {
+ // XXX: ugly hack, need partial line buffering
+ return -1;
+ }
+
+ // ok
+ return SUCCESS;
+}
+
const struct error_info* line_proto_error (struct line_proto *lp)
{
// return pointer