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@8: * Create a new line_proto off the the given sock_stream. The newly allocated line_proto will be returned via *lp_ptr. terom@8: */ terom@8: err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, struct error_info *err); terom@8: terom@8: /* terom@8: * Receive one line into the given buffer. The line will be terminated with '\r\n', and said terminator will be terom@8: * NUL'd out, so the buffer is safe for use as a C-string after succesfull return. terom@8: * terom@8: * Note: currently this uses the buffer to store intermediate state, so always pass the same buffer (for now). terom@8: */ terom@8: err_t line_proto_read (struct line_proto *lp, char *buf, size_t len); 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 */