src/line_proto.h
changeset 8 be88e543c8ff
child 10 9fe218576d13
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/line_proto.h	Sun Feb 22 08:21:22 2009 +0200
@@ -0,0 +1,33 @@
+#ifndef LINE_PROTO_H
+#define LINE_PROTO_H
+
+/*
+ * Support for protocols that send/receive lines
+ */
+#include "sock.h"
+#include "error.h"
+
+/*
+ * The state handle
+ */
+struct line_proto;
+
+/*
+ * Create a new line_proto off the the given sock_stream. The newly allocated line_proto will be returned via *lp_ptr.
+ */
+err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, struct error_info *err);
+
+/*
+ * Receive one line into the given buffer. The line will be terminated with '\r\n', and said terminator will be
+ * NUL'd out, so the buffer is safe for use as a C-string after succesfull return.
+ *
+ * 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);
+
+/*
+ * Get current error_info*
+ */
+const struct error_info* line_proto_error (struct line_proto *lp);
+
+#endif /* LINE_PROTO_H */