diff options
Diffstat (limited to 'Utilities/cmcurl/lib/altsvc.c')
-rw-r--r-- | Utilities/cmcurl/lib/altsvc.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/Utilities/cmcurl/lib/altsvc.c b/Utilities/cmcurl/lib/altsvc.c index c2ec489..4ab77fd 100644 --- a/Utilities/cmcurl/lib/altsvc.c +++ b/Utilities/cmcurl/lib/altsvc.c @@ -9,7 +9,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -25,7 +25,7 @@ */ #include "curl_setup.h" -#if !defined(CURL_DISABLE_HTTP) && defined(USE_ALTSVC) +#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC) #include <curl/curl.h> #include "urldata.h" #include "altsvc.h" @@ -302,11 +302,12 @@ CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl) * Curl_altsvc_cleanup() frees an altsvc cache instance and all associated * resources. */ -void Curl_altsvc_cleanup(struct altsvcinfo *altsvc) +void Curl_altsvc_cleanup(struct altsvcinfo **altsvcp) { - struct curl_llist_element *e; - struct curl_llist_element *n; - if(altsvc) { + struct Curl_llist_element *e; + struct Curl_llist_element *n; + if(*altsvcp) { + struct altsvcinfo *altsvc = *altsvcp; for(e = altsvc->list.head; e; e = n) { struct altsvc *as = e->ptr; n = e->next; @@ -314,6 +315,7 @@ void Curl_altsvc_cleanup(struct altsvcinfo *altsvc) } free(altsvc->filename); free(altsvc); + *altsvcp = NULL; /* clear the pointer */ } } @@ -323,8 +325,8 @@ void Curl_altsvc_cleanup(struct altsvcinfo *altsvc) CURLcode Curl_altsvc_save(struct Curl_easy *data, struct altsvcinfo *altsvc, const char *file) { - struct curl_llist_element *e; - struct curl_llist_element *n; + struct Curl_llist_element *e; + struct Curl_llist_element *n; CURLcode result = CURLE_OK; FILE *out; char *tempstore; @@ -353,7 +355,7 @@ CURLcode Curl_altsvc_save(struct Curl_easy *data, if(!out) result = CURLE_WRITE_ERROR; else { - fputs("# Your alt-svc cache. https://curl.haxx.se/docs/alt-svc.html\n" + fputs("# Your alt-svc cache. https://curl.se/docs/alt-svc.html\n" "# This file was generated by libcurl! Edit at your own risk.\n", out); for(e = altsvc->list.head; e; e = n) { @@ -399,8 +401,8 @@ static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen) static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid, const char *srchost, unsigned short srcport) { - struct curl_llist_element *e; - struct curl_llist_element *n; + struct Curl_llist_element *e; + struct Curl_llist_element *n; for(e = asi->list.head; e; e = n) { struct altsvc *as = e->ptr; n = e->next; @@ -449,12 +451,14 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data, { const char *p = value; size_t len; - enum alpnid dstalpnid = srcalpnid; /* the same by default */ char namebuf[MAX_ALTSVC_HOSTLEN] = ""; char alpnbuf[MAX_ALTSVC_ALPNLEN] = ""; struct altsvc *as; unsigned short dstport = srcport; /* the same by default */ CURLcode result = getalnum(&p, alpnbuf, sizeof(alpnbuf)); +#ifdef CURL_DISABLE_VERBOSE_STRINGS + (void)data; +#endif if(result) { infof(data, "Excessive alt-svc header, ignoring...\n"); return CURLE_OK; @@ -473,7 +477,7 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data, do { if(*p == '=') { /* [protocol]="[host][:port]" */ - dstalpnid = alpn2alpnid(alpnbuf); + enum alpnid dstalpnid = alpn2alpnid(alpnbuf); /* the same by default */ p++; if(*p == '\"') { const char *dsthost = ""; @@ -612,8 +616,8 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi, struct altsvc **dstentry, const int versions) /* one or more bits */ { - struct curl_llist_element *e; - struct curl_llist_element *n; + struct Curl_llist_element *e; + struct Curl_llist_element *n; time_t now = time(NULL); DEBUGASSERT(asi); DEBUGASSERT(srchost); @@ -640,4 +644,4 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi, return FALSE; } -#endif /* CURL_DISABLE_HTTP || USE_ALTSVC */ +#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */ |