src/line_proto.h
author Tero Marttila <terom@fixme.fi>
Sun, 22 Feb 2009 08:48:21 +0200
changeset 9 4c4c906cc649
parent 8 be88e543c8ff
child 10 9fe218576d13
permissions -rw-r--r--
add sock_stream_callbacks and ev_base
#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 */