src/line_proto.c
changeset 27 e6639132bead
parent 22 c339c020fd33
child 28 9c1050bc8709
equal deleted inserted replaced
26:aec062af155d 27:e6639132bead
    44  */
    44  */
    45 static void line_proto_on_read (struct sock_stream *sock, void *arg)
    45 static void line_proto_on_read (struct sock_stream *sock, void *arg)
    46 {
    46 {
    47     struct line_proto *lp = arg;
    47     struct line_proto *lp = arg;
    48     char *line;
    48     char *line;
       
    49 
       
    50     (void) sock;
    49 
    51 
    50     // sanity-check
    52     // sanity-check
    51     assert(lp->tail_offset < lp->buf_len);
    53     assert(lp->tail_offset < lp->buf_len);
    52     
    54     
    53     do {
    55     do {
    71  * Signal for write
    73  * Signal for write
    72  */
    74  */
    73 static void line_proto_on_write (struct sock_stream *sock, void *arg)
    75 static void line_proto_on_write (struct sock_stream *sock, void *arg)
    74 {
    76 {
    75     struct line_proto *lp = arg;
    77     struct line_proto *lp = arg;
    76     err_t err;
    78     int ret;
       
    79 
       
    80     (void) sock;
    77 
    81 
    78     // just flush
    82     // just flush
    79     if ((err = line_proto_flush(lp)) < 0)
    83     if ((ret = line_proto_flush(lp)) < 0)
    80         FATAL_ERR(err, "line_proto_flush");
    84         FATAL_ERR(-ret, "line_proto_flush");
    81 }
    85 }
    82 
    86 
    83 /*
    87 /*
    84  * Schedule our sock_stream callback
    88  * Schedule our sock_stream callback
    85  */
    89  */
   149  * The given \a hint is an hint as to the offset at which to start scanning, used for incremental invocations of this
   153  * The given \a hint is an hint as to the offset at which to start scanning, used for incremental invocations of this
   150  * on the same buffer.
   154  * on the same buffer.
   151  *
   155  *
   152  */
   156  */
   153 int _parse_line (char *buf, size_t len, size_t *hint) {
   157 int _parse_line (char *buf, size_t len, size_t *hint) {
   154     int i, next = 0;
   158     size_t i, next = 0;
   155 
   159 
   156     // empty buffer -> nothing
   160     // empty buffer -> nothing
   157     if (len == 0)
   161     if (len == 0)
   158         return 0;
   162         return 0;
   159 
   163