--- embedaddon/mpd/src/contrib/libpdel/http/http_head.c 2013/07/22 08:44:30 1.1.1.1 +++ embedaddon/mpd/src/contrib/libpdel/http/http_head.c 2021/03/17 00:39:23 1.1.1.2 @@ -79,9 +79,14 @@ struct http_header { char *value; }; +struct const_http_header { + const char *name; + char *value; +}; + struct http_head { char *words[3]; /* first line stuff */ - int num_hdrs; /* number of headers */ + unsigned num_hdrs; /* number of headers */ struct http_header *hdrs; /* headers, sorted */ }; @@ -136,7 +141,7 @@ void _http_head_free(struct http_head **headp) { struct http_head *const head = *headp; - int i; + unsigned i; if (head == NULL) return; @@ -160,7 +165,7 @@ struct http_head * _http_head_copy(struct http_head *head0) { struct http_head *head; - int i; + unsigned i; /* Get new header struct */ if ((head = _http_head_new()) == NULL) @@ -202,7 +207,7 @@ fail: const char * _http_head_get(struct http_head *head, const char *name) { - struct http_header key; + struct const_http_header key; struct http_header *hdr; int i; @@ -211,7 +216,7 @@ _http_head_get(struct http_head *head, const char *nam return (head->words[i]); /* Normal headers */ - key.name = (char *)name; + key.name = name; if ((hdr = bsearch(&key, head->hdrs, head->num_hdrs, sizeof(*head->hdrs), http_header_cmp)) == NULL) { errno = ENOENT; @@ -254,7 +259,7 @@ int _http_head_get_headers(struct http_head *head, const char **names, size_t max_names) { - int i; + unsigned i; if (max_names > head->num_hdrs) max_names = head->num_hdrs; @@ -286,7 +291,7 @@ int _http_head_vset(struct http_head *head, int append, const char *name, const char *valfmt, va_list args) { - struct http_header key; + struct const_http_header key; struct http_header *hdr; char *value; void *mem; @@ -305,7 +310,7 @@ _http_head_vset(struct http_head *head, int append, } /* If header doesn't already exist, add it (unless special) */ - key.name = (char *)name; + key.name = name; if (strcasecmp(name, HTTP_HEADER_SET_COOKIE) == 0 /* XXX blech */ || (hdr = bsearch(&key, head->hdrs, head->num_hdrs, sizeof(*head->hdrs), http_header_cmp)) == NULL) { @@ -360,7 +365,7 @@ _http_head_vset(struct http_head *head, int append, int _http_head_remove(struct http_head *head, const char *name) { - struct http_header key; + struct const_http_header key; struct http_header *hdr; int i; @@ -375,7 +380,7 @@ _http_head_remove(struct http_head *head, const char * } /* Does header exist? */ - key.name = (char *)name; + key.name = name; if ((hdr = bsearch(&key, head->hdrs, head->num_hdrs, sizeof(*head->hdrs), http_header_cmp)) == NULL) return (0); @@ -416,7 +421,7 @@ http_header_cmp(const void *v1, const void *v2) { const struct http_header *const hdrs[] = { v1, v2 }; int sortval[2]; - int i, j; + unsigned i, j; /* Check assigned ordering list */ for (i = 0; i < 2; i++) { @@ -557,7 +562,7 @@ fail: int _http_head_write(struct http_head *head, FILE *fp) { - int i; + unsigned i; for (i = 0; i < 3; i++) { if (head->words[i] == NULL) {