terom@8: #ifndef LINE_PROTO_H terom@8: #define LINE_PROTO_H terom@8: terom@8: /* terom@8: * Support for protocols that send/receive lines terom@8: */ terom@8: #include "sock.h" terom@8: #include "error.h" terom@8: terom@8: /* terom@8: * The state handle terom@8: */ terom@8: struct line_proto; terom@8: terom@8: /* terom@10: * The callback for receiving lines terom@10: */ terom@11: typedef void (*line_proto_read_cb)(const char *line, void *arg); terom@10: terom@10: /* terom@8: * Create a new line_proto off the the given sock_stream. The newly allocated line_proto will be returned via *lp_ptr. terom@10: * terom@10: * The incoming lines are buffered in a buffer of \a buf_size bytes. This imposes a maximum limit on the line length. terom@10: * terom@10: * The given callback function/argument will be used to provide event-based recv support. terom@8: */ terom@10: err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, size_t buf_size, terom@10: line_proto_read_cb cb_func, void *cb_arg, struct error_info *err); terom@8: terom@8: /* terom@11: * Runs the socket recv() into our internal buffer. If a full line was received, a pointer to our internal bufffer is terom@11: * returned via *line_ptr, and we return SUCCESS. If we don't yet have a full line, and receiving more would block, terom@11: * NULL is returned via *line_ptr instead. Otherwise, nonzero error return code. terom@8: */ terom@10: err_t line_proto_read (struct line_proto *lp, const char **line_ptr); terom@8: terom@8: /* terom@8: * Get current error_info* terom@8: */ terom@8: const struct error_info* line_proto_error (struct line_proto *lp); terom@8: terom@8: #endif /* LINE_PROTO_H */