Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/http/src/response.c

    r9a09212 rb7fd2a0  
    3434 */
    3535
     36#include <errno.h>
    3637#include <stdio.h>
    3738#include <stdlib.h>
     
    4041
    4142#include <http/http.h>
    42 #include <http/errno.h>
    4343
    4444static bool is_digit(char c)
     
    4747}
    4848
    49 static int receive_number(receive_buffer_t *rb, char **str)
     49static errno_t receive_number(receive_buffer_t *rb, char **str)
    5050{
    5151        receive_buffer_mark_t start;
     
    5353       
    5454        recv_mark(rb, &start);
    55         int rc = recv_while(rb, is_digit);
    56         if (rc < 0) {
     55        errno_t rc = recv_while(rb, is_digit);
     56        if (rc != EOK) {
    5757                recv_unmark(rb, &start);
    5858                return rc;
     
    6666}
    6767
    68 static int receive_uint8_t(receive_buffer_t *rb, uint8_t *out_value)
     68static errno_t receive_uint8_t(receive_buffer_t *rb, uint8_t *out_value)
    6969{
    7070        char *str = NULL;
    71         int rc = receive_number(rb, &str);
     71        errno_t rc = receive_number(rb, &str);
    7272       
    7373        if (rc != EOK)
     
    8080}
    8181
    82 static int receive_uint16_t(receive_buffer_t *rb, uint16_t *out_value)
     82static errno_t receive_uint16_t(receive_buffer_t *rb, uint16_t *out_value)
    8383{
    8484        char *str = NULL;
    85         int rc = receive_number(rb, &str);
     85        errno_t rc = receive_number(rb, &str);
    8686       
    8787        if (rc != EOK)
     
    9494}
    9595
    96 static int expect(receive_buffer_t *rb, const char *expect)
     96static errno_t expect(receive_buffer_t *rb, const char *expect)
    9797{
    9898        size_t ndisc;
    99         int rc = recv_discard_str(rb, expect, &ndisc);
     99        errno_t rc = recv_discard_str(rb, expect, &ndisc);
    100100        if (rc != EOK)
    101101                return rc;
     
    110110}
    111111
    112 int http_receive_status(receive_buffer_t *rb, http_version_t *out_version,
     112errno_t http_receive_status(receive_buffer_t *rb, http_version_t *out_version,
    113113    uint16_t *out_status, char **out_message)
    114114{
     
    117117        char *message = NULL;
    118118       
    119         int rc = expect(rb, "HTTP/");
     119        errno_t rc = expect(rb, "HTTP/");
    120120        if (rc != EOK)
    121121                return rc;
     
    149149       
    150150        rc = recv_while(rb, is_not_newline);
    151         if (rc < 0) {
     151        if (rc != EOK) {
    152152                recv_unmark(rb, &msg_start);
    153153                return rc;
     
    187187}
    188188
    189 int http_receive_response(receive_buffer_t *rb, http_response_t **out_response,
     189errno_t http_receive_response(receive_buffer_t *rb, http_response_t **out_response,
    190190    size_t max_headers_size, unsigned max_headers_count)
    191191{
     
    196196        http_headers_init(&resp->headers);
    197197       
    198         int rc = http_receive_status(rb, &resp->version, &resp->status,
     198        errno_t rc = http_receive_status(rb, &resp->version, &resp->status,
    199199            &resp->message);
    200200        if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.