src/line_proto.h
changeset 11 14e79683c48c
parent 10 9fe218576d13
child 12 4147fae232d9
equal deleted inserted replaced
10:9fe218576d13 11:14e79683c48c
    13 struct line_proto;
    13 struct line_proto;
    14 
    14 
    15 /*
    15 /*
    16  * The callback for receiving lines
    16  * The callback for receiving lines
    17  */
    17  */
    18 typedef void (*line_proto_read_cb)(struct line_proto *lp, const char *line, void *arg);
    18 typedef void (*line_proto_read_cb)(const char *line, void *arg);
    19 
    19 
    20 /*
    20 /*
    21  * Create a new line_proto off the the given sock_stream. The newly allocated line_proto will be returned via *lp_ptr.
    21  * Create a new line_proto off the the given sock_stream. The newly allocated line_proto will be returned via *lp_ptr.
    22  *
    22  *
    23  * The incoming lines are buffered in a buffer of \a buf_size bytes. This imposes a maximum limit on the line length.
    23  * The incoming lines are buffered in a buffer of \a buf_size bytes. This imposes a maximum limit on the line length.
    26  */
    26  */
    27 err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, size_t buf_size,
    27 err_t line_proto_create (struct line_proto **lp_ptr, struct sock_stream *sock, size_t buf_size,
    28         line_proto_read_cb cb_func, void *cb_arg, struct error_info *err);
    28         line_proto_read_cb cb_func, void *cb_arg, struct error_info *err);
    29 
    29 
    30 /*
    30 /*
    31  * Receive one line into the given buffer. The line will be terminated with '\r\n', and said terminator will be
    31  * Runs the socket recv() into our internal buffer. If a full line was received, a pointer to our internal bufffer is
    32  * NUL'd out, so the buffer is safe for use as a C-string after succesfull return.
    32  * returned via *line_ptr, and we return SUCCESS. If we don't yet have a full line, and receiving more would block,
    33  *
    33  * NULL is returned via *line_ptr instead. Otherwise, nonzero error return code.
    34  * Note: currently this uses the buffer to store intermediate state, so always pass the same buffer (for now).
       
    35  */
    34  */
    36 err_t line_proto_read (struct line_proto *lp, const char **line_ptr);
    35 err_t line_proto_read (struct line_proto *lp, const char **line_ptr);
    37 
    36 
    38 /*
    37 /*
    39  * Get current error_info*
    38  * Get current error_info*