mirror of
https://github.com/curl/curl.git
synced 2026-07-27 08:47:21 +03:00
lib: drop two interim macros in favor of native libcurl API calls
Drop `strcasecompare` and `strncasecompare` in favor of libcurl API calls `curl_strequal` and `curl_strnequal` respectively. Also drop unnecessary `strcase.h` includes. Include `curl/curl.h` instead where it wasn't included before. Closes #17772
This commit is contained in:
parent
d553f7e9f0
commit
a3787f98ac
54 changed files with 223 additions and 260 deletions
26
lib/cookie.c
26
lib/cookie.c
|
|
@ -135,9 +135,9 @@ static bool cookie_tailmatch(const char *cookie_domain,
|
|||
if(hostname_len < cookie_domain_len)
|
||||
return FALSE;
|
||||
|
||||
if(!strncasecompare(cookie_domain,
|
||||
hostname + hostname_len-cookie_domain_len,
|
||||
cookie_domain_len))
|
||||
if(!curl_strnequal(cookie_domain,
|
||||
hostname + hostname_len-cookie_domain_len,
|
||||
cookie_domain_len))
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
|
|
@ -409,7 +409,7 @@ static void remove_expired(struct CookieInfo *ci)
|
|||
/* Make sure domain contains a dot or is localhost. */
|
||||
static bool bad_domain(const char *domain, size_t len)
|
||||
{
|
||||
if((len == 9) && strncasecompare(domain, "localhost", 9))
|
||||
if((len == 9) && curl_strnequal(domain, "localhost", 9))
|
||||
return FALSE;
|
||||
else {
|
||||
/* there must be a dot present, but that dot must not be a trailing dot */
|
||||
|
|
@ -815,7 +815,7 @@ parse_netscape(struct Cookie *co,
|
|||
* domain can access the variable. Set TRUE when the cookie says
|
||||
* .example.com and to false when the domain is complete www.example.com
|
||||
*/
|
||||
co->tailmatch = !!strncasecompare(ptr, "TRUE", len);
|
||||
co->tailmatch = !!curl_strnequal(ptr, "TRUE", len);
|
||||
break;
|
||||
case 2:
|
||||
/* The file format allows the path field to remain not filled in */
|
||||
|
|
@ -842,7 +842,7 @@ parse_netscape(struct Cookie *co,
|
|||
FALLTHROUGH();
|
||||
case 3:
|
||||
co->secure = FALSE;
|
||||
if(strncasecompare(ptr, "TRUE", len)) {
|
||||
if(curl_strnequal(ptr, "TRUE", len)) {
|
||||
if(secure || ci->running)
|
||||
co->secure = TRUE;
|
||||
else
|
||||
|
|
@ -859,9 +859,9 @@ parse_netscape(struct Cookie *co,
|
|||
return CERR_OUT_OF_MEMORY;
|
||||
else {
|
||||
/* For Netscape file format cookies we check prefix on the name */
|
||||
if(strncasecompare("__Secure-", co->name, 9))
|
||||
if(curl_strnequal("__Secure-", co->name, 9))
|
||||
co->prefix_secure = TRUE;
|
||||
else if(strncasecompare("__Host-", co->name, 7))
|
||||
else if(curl_strnequal("__Host-", co->name, 7))
|
||||
co->prefix_host = TRUE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -954,7 +954,7 @@ replace_existing(struct Curl_easy *data,
|
|||
bool matching_domains = FALSE;
|
||||
|
||||
if(clist->domain && co->domain) {
|
||||
if(strcasecompare(clist->domain, co->domain))
|
||||
if(curl_strequal(clist->domain, co->domain))
|
||||
/* The domains are identical */
|
||||
matching_domains = TRUE;
|
||||
}
|
||||
|
|
@ -981,7 +981,7 @@ replace_existing(struct Curl_easy *data,
|
|||
else
|
||||
cllen = strlen(clist->spath);
|
||||
|
||||
if(strncasecompare(clist->spath, co->spath, cllen)) {
|
||||
if(curl_strnequal(clist->spath, co->spath, cllen)) {
|
||||
infof(data, "cookie '%s' for domain '%s' dropped, would "
|
||||
"overlay an existing cookie", co->name, co->domain);
|
||||
return CERR_BAD_SECURE;
|
||||
|
|
@ -993,7 +993,7 @@ replace_existing(struct Curl_easy *data,
|
|||
/* the names are identical */
|
||||
|
||||
if(clist->domain && co->domain) {
|
||||
if(strcasecompare(clist->domain, co->domain) &&
|
||||
if(curl_strequal(clist->domain, co->domain) &&
|
||||
(clist->tailmatch == co->tailmatch))
|
||||
/* The domains are identical */
|
||||
replace_old = TRUE;
|
||||
|
|
@ -1005,7 +1005,7 @@ replace_existing(struct Curl_easy *data,
|
|||
/* the domains were identical */
|
||||
|
||||
if(clist->spath && co->spath &&
|
||||
!strcasecompare(clist->spath, co->spath))
|
||||
!curl_strequal(clist->spath, co->spath))
|
||||
replace_old = FALSE;
|
||||
else if(!clist->spath != !co->spath)
|
||||
replace_old = FALSE;
|
||||
|
|
@ -1337,7 +1337,7 @@ int Curl_cookie_getlist(struct Curl_easy *data,
|
|||
if(!co->domain ||
|
||||
(co->tailmatch && !is_ip &&
|
||||
cookie_tailmatch(co->domain, strlen(co->domain), host)) ||
|
||||
((!co->tailmatch || is_ip) && strcasecompare(host, co->domain)) ) {
|
||||
((!co->tailmatch || is_ip) && curl_strequal(host, co->domain)) ) {
|
||||
/*
|
||||
* the right part of the host matches the domain stuff in the
|
||||
* cookie data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue