src/line_proto.h
changeset 10 9fe218576d13
parent 8 be88e543c8ff
child 11 14e79683c48c
--- a/src/line_proto.h	Sun Feb 22 08:48:21 2009 +0200
+++ b/src/line_proto.h	Sun Feb 22 10:16:28 2009 +0200
@@ -13,9 +13,19 @@
 struct line_proto;
 
 /*
+ * The callback for receiving lines
+ */
+typedef void (*line_proto_read_cb)(struct line_proto *lp, const char *line, void *arg);
+
+/*
  * Create a new line_proto off the the given sock_stream. The newly allocated line_proto will be returned via *lp_ptr.
+ *
+ * The incoming lines are buffered in a buffer of \a buf_size bytes. This imposes a maximum limit on the line length.
+ *
+ * The given callback function/argument will be used to provide event-based recv support.
  */
-err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, struct error_info *err);
+err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, size_t buf_size,
+        line_proto_read_cb cb_func, void *cb_arg, struct error_info *err);
 
 /*
  * Receive one line into the given buffer. The line will be terminated with '\r\n', and said terminator will be
@@ -23,7 +33,7 @@
  *
  * Note: currently this uses the buffer to store intermediate state, so always pass the same buffer (for now).
  */
-err_t line_proto_read (struct line_proto *lp, char *buf, size_t len);
+err_t line_proto_read (struct line_proto *lp, const char **line_ptr);
 
 /*
  * Get current error_info*