src/line_proto.h
changeset 8 be88e543c8ff
child 10 9fe218576d13
equal deleted inserted replaced
7:844f014409ff 8:be88e543c8ff
       
     1 #ifndef LINE_PROTO_H
       
     2 #define LINE_PROTO_H
       
     3 
       
     4 /*
       
     5  * Support for protocols that send/receive lines
       
     6  */
       
     7 #include "sock.h"
       
     8 #include "error.h"
       
     9 
       
    10 /*
       
    11  * The state handle
       
    12  */
       
    13 struct line_proto;
       
    14 
       
    15 /*
       
    16  * Create a new line_proto off the the given sock_stream. The newly allocated line_proto will be returned via *lp_ptr.
       
    17  */
       
    18 err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, struct error_info *err);
       
    19 
       
    20 /*
       
    21  * Receive one line into the given buffer. The line will be terminated with '\r\n', and said terminator will be
       
    22  * NUL'd out, so the buffer is safe for use as a C-string after succesfull return.
       
    23  *
       
    24  * Note: currently this uses the buffer to store intermediate state, so always pass the same buffer (for now).
       
    25  */
       
    26 err_t line_proto_read (struct line_proto *lp, char *buf, size_t len);
       
    27 
       
    28 /*
       
    29  * Get current error_info*
       
    30  */
       
    31 const struct error_info* line_proto_error (struct line_proto *lp);
       
    32 
       
    33 #endif /* LINE_PROTO_H */