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:
Viktor Szakats 2025-06-28 12:17:30 +02:00
parent d553f7e9f0
commit a3787f98ac
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
54 changed files with 223 additions and 260 deletions

View file

@ -26,7 +26,6 @@
#if defined(USE_MBEDTLS) || defined(USE_RUSTLS)
#include "cipher_suite.h"
#include "../curl_printf.h"
#include "../strcase.h"
#include <string.h>
/*
@ -561,7 +560,7 @@ static int cs_str_to_zip(const char *cs_str, size_t cs_len,
size_t len;
/* split the cipher string by '-' or '_' */
if(strncasecompare(cs_str, "TLS", 3))
if(curl_strnequal(cs_str, "TLS", 3))
separator = '_';
do {
@ -576,7 +575,7 @@ static int cs_str_to_zip(const char *cs_str, size_t cs_len,
/* lookup index for the part (skip empty string at 0) */
for(idx = 1, entry = cs_txt + 1; idx < CS_TXT_LEN; idx++) {
size_t elen = strlen(entry);
if(elen == len && strncasecompare(entry, cur, len))
if(elen == len && curl_strnequal(entry, cur, len))
break;
entry += elen + 1;
}

View file

@ -53,7 +53,6 @@
#include "../connect.h" /* for the connect timeout */
#include "../progress.h"
#include "../select.h"
#include "../strcase.h"
#include "../strdup.h"
#include "../curlx/warnless.h"
#include "x509asn1.h"
@ -303,9 +302,9 @@ static gnutls_x509_crt_fmt_t gnutls_do_file_type(const char *type)
{
if(!type || !type[0])
return GNUTLS_X509_FMT_PEM;
if(strcasecompare(type, "PEM"))
if(curl_strequal(type, "PEM"))
return GNUTLS_X509_FMT_PEM;
if(strcasecompare(type, "DER"))
if(curl_strequal(type, "DER"))
return GNUTLS_X509_FMT_DER;
return GNUTLS_X509_FMT_PEM; /* default to PEM */
}
@ -982,7 +981,7 @@ static CURLcode gtls_client_init(struct Curl_cfilter *cf,
if(result)
return result;
}
if(ssl_config->cert_type && strcasecompare(ssl_config->cert_type, "P12")) {
if(ssl_config->cert_type && curl_strequal(ssl_config->cert_type, "P12")) {
rc = gnutls_certificate_set_x509_simple_pkcs12_file(
gtls->shared_creds->creds, config->clientcert, GNUTLS_X509_FMT_DER,
ssl_config->key_passwd ? ssl_config->key_passwd : "");

View file

@ -36,7 +36,6 @@
#endif
#include "../curl_memrchr.h"
#include "hostcheck.h"
#include "../strcase.h"
#include "../hostip.h"
#include "../curl_memory.h"
@ -50,7 +49,7 @@ static bool pmatch(const char *hostname, size_t hostlen,
{
if(hostlen != patternlen)
return FALSE;
return strncasecompare(hostname, pattern, hostlen);
return curl_strnequal(hostname, pattern, hostlen);
}
/*

View file

@ -57,7 +57,6 @@
#endif /* MBEDTLS_VERSION_MAJOR >= 2 */
#include "cipher_suite.h"
#include "../strcase.h"
#include "../urldata.h"
#include "../sendf.h"
#include "../curlx/inet_pton.h"
@ -382,7 +381,7 @@ mbed_cipher_suite_walk_str(const char **str, const char **end)
size_t len = *end - *str;
if(!id) {
if(strncasecompare("TLS_ECJPAKE_WITH_AES_128_CCM_8", *str, len))
if(curl_strnequal("TLS_ECJPAKE_WITH_AES_128_CCM_8", *str, len))
id = MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8;
}
return id;

View file

@ -60,7 +60,6 @@
#include "vtls_scache.h"
#include "../vauth/vauth.h"
#include "keylog.h"
#include "../strcase.h"
#include "hostcheck.h"
#include "../multiif.h"
#include "../curlx/strparse.h"
@ -1058,15 +1057,15 @@ static int ossl_do_file_type(const char *type)
{
if(!type || !type[0])
return SSL_FILETYPE_PEM;
if(strcasecompare(type, "PEM"))
if(curl_strequal(type, "PEM"))
return SSL_FILETYPE_PEM;
if(strcasecompare(type, "DER"))
if(curl_strequal(type, "DER"))
return SSL_FILETYPE_ASN1;
if(strcasecompare(type, "PROV"))
if(curl_strequal(type, "PROV"))
return SSL_FILETYPE_PROVIDER;
if(strcasecompare(type, "ENG"))
if(curl_strequal(type, "ENG"))
return SSL_FILETYPE_ENGINE;
if(strcasecompare(type, "P12"))
if(curl_strequal(type, "P12"))
return SSL_FILETYPE_PKCS12;
return -1;
}
@ -1119,7 +1118,7 @@ static int ssl_ui_writer(UI *ui, UI_STRING *uis)
*/
static bool is_pkcs11_uri(const char *string)
{
return string && strncasecompare(string, "pkcs11:", 7);
return string && curl_strnequal(string, "pkcs11:", 7);
}
#endif
@ -5520,7 +5519,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
size_t count;
const char *ver = OpenSSL_version(OPENSSL_VERSION);
const char expected[] = OSSL_PACKAGE " "; /* ie "LibreSSL " */
if(strncasecompare(ver, expected, sizeof(expected) - 1)) {
if(curl_strnequal(ver, expected, sizeof(expected) - 1)) {
ver += sizeof(expected) - 1;
}
count = msnprintf(buffer, size, "%s/%s", OSSL_PACKAGE, ver);

View file

@ -42,7 +42,6 @@
#include "vtls.h"
#include "vtls_int.h"
#include "vtls_scache.h"
#include "../strcase.h"
#include "../sendf.h"
#include "../connect.h" /* for the connect timeout */
#include "../strerror.h"
@ -598,7 +597,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf,
}
if((fInCert || blob) && (data->set.ssl.cert_type) &&
(!strcasecompare(data->set.ssl.cert_type, "P12"))) {
(!curl_strequal(data->set.ssl.cert_type, "P12"))) {
failf(data, "schannel: certificate format compatibility error "
" for %s",
blob ? "(memory blob)" : data->set.ssl.primary.clientcert);

View file

@ -207,12 +207,12 @@ match_ssl_primary_config(struct Curl_easy *data,
!Curl_timestrcmp(c1->username, c2->username) &&
!Curl_timestrcmp(c1->password, c2->password) &&
#endif
strcasecompare(c1->cipher_list, c2->cipher_list) &&
strcasecompare(c1->cipher_list13, c2->cipher_list13) &&
strcasecompare(c1->curves, c2->curves) &&
strcasecompare(c1->signature_algorithms, c2->signature_algorithms) &&
strcasecompare(c1->CRLfile, c2->CRLfile) &&
strcasecompare(c1->pinned_key, c2->pinned_key))
curl_strequal(c1->cipher_list, c2->cipher_list) &&
curl_strequal(c1->cipher_list13, c2->cipher_list13) &&
curl_strequal(c1->curves, c2->curves) &&
curl_strequal(c1->signature_algorithms, c2->signature_algorithms) &&
curl_strequal(c1->CRLfile, c2->CRLfile) &&
curl_strequal(c1->pinned_key, c2->pinned_key))
return TRUE;
return FALSE;
@ -1073,7 +1073,7 @@ static int multissl_setup(const struct Curl_ssl *backend)
env = curl_getenv("CURL_SSL_BACKEND");
if(env) {
for(i = 0; available_backends[i]; i++) {
if(strcasecompare(env, available_backends[i]->info.name)) {
if(curl_strequal(env, available_backends[i]->info.name)) {
Curl_ssl = available_backends[i];
free(env);
return 0;
@ -1083,8 +1083,8 @@ static int multissl_setup(const struct Curl_ssl *backend)
#ifdef CURL_DEFAULT_SSL_BACKEND
for(i = 0; available_backends[i]; i++) {
if(strcasecompare(CURL_DEFAULT_SSL_BACKEND,
available_backends[i]->info.name)) {
if(curl_strequal(CURL_DEFAULT_SSL_BACKEND,
available_backends[i]->info.name)) {
Curl_ssl = available_backends[i];
free(env);
return 0;
@ -1110,7 +1110,7 @@ CURLsslset Curl_init_sslset_nolock(curl_sslbackend id, const char *name,
if(Curl_ssl != &Curl_ssl_multi)
return id == Curl_ssl->info.id ||
(name && strcasecompare(name, Curl_ssl->info.name)) ?
(name && curl_strequal(name, Curl_ssl->info.name)) ?
CURLSSLSET_OK :
#if defined(CURL_WITH_MULTI_SSL)
CURLSSLSET_TOO_LATE;
@ -1120,7 +1120,7 @@ CURLsslset Curl_init_sslset_nolock(curl_sslbackend id, const char *name,
for(i = 0; available_backends[i]; i++) {
if(available_backends[i]->info.id == id ||
(name && strcasecompare(available_backends[i]->info.name, name))) {
(name && curl_strequal(available_backends[i]->info.name, name))) {
multissl_setup(available_backends[i]);
return CURLSSLSET_OK;
}

View file

@ -646,7 +646,7 @@ cf_ssl_find_peer_by_key(struct Curl_easy *data,
/* check for entries with known peer_key */
for(i = 0; scache && i < scache->peer_count; i++) {
if(scache->peers[i].ssl_peer_key &&
strcasecompare(ssl_peer_key, scache->peers[i].ssl_peer_key) &&
curl_strequal(ssl_peer_key, scache->peers[i].ssl_peer_key) &&
cf_ssl_scache_match_auth(&scache->peers[i], conn_config)) {
/* yes, we have a cached session for this! */
*ppeer = &scache->peers[i];

View file

@ -67,7 +67,6 @@
#include "../connect.h" /* for the connect timeout */
#include "../progress.h"
#include "../select.h"
#include "../strcase.h"
#include "../strdup.h"
#include "x509asn1.h"
#include "../curl_printf.h"
@ -227,9 +226,9 @@ static int wssl_do_file_type(const char *type)
{
if(!type || !type[0])
return WOLFSSL_FILETYPE_PEM;
if(strcasecompare(type, "PEM"))
if(curl_strequal(type, "PEM"))
return WOLFSSL_FILETYPE_PEM;
if(strcasecompare(type, "DER"))
if(curl_strequal(type, "DER"))
return WOLFSSL_FILETYPE_ASN1;
return -1;
}

View file

@ -39,7 +39,6 @@
#include <curl/curl.h>
#include "../urldata.h"
#include "../strcase.h"
#include "../curl_ctype.h"
#include "hostcheck.h"
#include "vtls.h"
@ -262,7 +261,7 @@ static const struct Curl_OID *searchOID(const char *oid)
{
const struct Curl_OID *op;
for(op = OIDtable; op->numoid; op++)
if(!strcmp(op->numoid, oid) || strcasecompare(op->textoid, oid))
if(!strcmp(op->numoid, oid) || curl_strequal(op->textoid, oid))
return op;
return NULL;
@ -989,7 +988,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum,
/* Generate all information records for the public key. */
if(strcasecompare(algo, "ecPublicKey")) {
if(curl_strequal(algo, "ecPublicKey")) {
/*
* ECC public key is all the data, a value of type BIT STRING mapped to
* OCTET STRING and should not be parsed as an ASN.1 value.
@ -1011,7 +1010,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum,
if(!getASN1Element(&pk, pubkey->beg + 1, pubkey->end))
return 1;
if(strcasecompare(algo, "rsaEncryption")) {
if(curl_strequal(algo, "rsaEncryption")) {
const char *q;
size_t len;
@ -1046,7 +1045,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum,
if(do_pubkey_field(data, certnum, "rsa(e)", &elem))
return 1;
}
else if(strcasecompare(algo, "dsa")) {
else if(curl_strequal(algo, "dsa")) {
p = getASN1Element(&elem, param->beg, param->end);
if(p) {
if(do_pubkey_field(data, certnum, "dsa(p)", &elem))
@ -1064,7 +1063,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum,
}
}
}
else if(strcasecompare(algo, "dhpublicnumber")) {
else if(curl_strequal(algo, "dhpublicnumber")) {
p = getASN1Element(&elem, param->beg, param->end);
if(p) {
if(do_pubkey_field(data, certnum, "dh(p)", &elem))