aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-09-30 17:15:05 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-10-31 08:46:35 +0100
commit502acba2af821391b85a2cd4ac7b91ad8e9d4180 (patch)
treee219be1178db413bffd92033e965c1e1075c4702
parent1833a45dde4d27febfce42813699533b1ae993d1 (diff)
strcasecompare: is the new name for strequal()
... to make it less likely that we forget that the function actually does case insentive compares. Also replaced several invokes of the function with a plain strcmp when case sensitivity is not an issue (like comparing with "-").
-rw-r--r--lib/Makefile.inc4
-rw-r--r--lib/cookie.c5
-rw-r--r--lib/curl_sasl.c3
-rw-r--r--lib/curlx.h10
-rw-r--r--lib/dict.c1
-rw-r--r--lib/easy.c1
-rw-r--r--lib/formdata.c12
-rw-r--r--lib/ftp.c6
-rw-r--r--lib/gopher.c1
-rw-r--r--lib/http.c1
-rw-r--r--lib/if2ip.c8
-rw-r--r--lib/imap.c5
-rw-r--r--lib/netrc.c2
-rw-r--r--lib/pop3.c7
-rw-r--r--lib/smtp.c5
-rw-r--r--lib/socks.c1
-rw-r--r--lib/ssh.c2
-rw-r--r--lib/strcase.c (renamed from lib/strequal.c)8
-rw-r--r--lib/strcase.h (renamed from lib/strequal.h)15
-rw-r--r--lib/telnet.c1
-rw-r--r--lib/transfer.c2
-rw-r--r--lib/url.c7
-rw-r--r--lib/vauth/cleartext.c1
-rw-r--r--lib/vtls/openssl.c1
-rw-r--r--lib/x509asn1.c10
-rw-r--r--src/tool_cb_dbg.c6
-rw-r--r--src/tool_getparam.c16
-rw-r--r--src/tool_helpers.c6
-rw-r--r--src/tool_operate.c14
-rw-r--r--src/tool_operhlp.c6
-rw-r--r--src/tool_writeout.c2
-rw-r--r--tests/libtest/libauthretry.c8
-rw-r--r--tests/server/Makefile.inc4
-rw-r--r--tests/server/rtspd.c6
-rw-r--r--tests/server/sws.c6
-rw-r--r--tests/unit/unit1301.c16
36 files changed, 98 insertions, 111 deletions
diff --git a/lib/Makefile.inc b/lib/Makefile.inc
index 0ed998c13..5b1540928 100644
--- a/lib/Makefile.inc
+++ b/lib/Makefile.inc
@@ -40,7 +40,7 @@ LIB_VTLS_HFILES = vtls/openssl.h vtls/vtls.h vtls/gtls.h \
LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c \
ldap.c version.c getenv.c escape.c mprintf.c telnet.c netrc.c \
- getinfo.c transfer.c strequal.c easy.c security.c curl_fnmatch.c \
+ getinfo.c transfer.c strcase.c easy.c security.c curl_fnmatch.c \
fileinfo.c ftplistparser.c wildcard.c krb5.c memdebug.c http_chunks.c \
strtok.c connect.c llist.c hash.c multi.c content_encoding.c share.c \
http_digest.c md4.c md5.c http_negotiate.c inet_pton.c strtoofft.c \
@@ -58,7 +58,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
speedcheck.h urldata.h curl_ldap.h escape.h telnet.h getinfo.h \
- strequal.h curl_sec.h memdebug.h http_chunks.h curl_fnmatch.h \
+ strcase.h curl_sec.h memdebug.h http_chunks.h curl_fnmatch.h \
wildcard.h fileinfo.h ftplistparser.h strtok.h connect.h llist.h \
hash.h content_encoding.h share.h curl_md4.h curl_md5.h http_digest.h \
http_negotiate.h inet_pton.h amigaos.h strtoofft.h strerror.h \
diff --git a/lib/cookie.c b/lib/cookie.c
index 8607ce3e7..317468274 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -90,7 +90,6 @@ Example set of cookies:
#include "urldata.h"
#include "cookie.h"
-#include "strequal.h"
#include "strtok.h"
#include "sendf.h"
#include "slist.h"
@@ -939,7 +938,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
}
c->running = FALSE; /* this is not running, this is init */
- if(file && strequal(file, "-")) {
+ if(file && !strcmp(file, "-")) {
fp = stdin;
fromfile=FALSE;
}
@@ -1310,7 +1309,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
/* at first, remove expired cookies */
remove_expired(c);
- if(strequal("-", dumphere)) {
+ if(!strcmp("-", dumphere)) {
/* use stdout */
out = stdout;
use_stdout=TRUE;
diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c
index 65fa52932..f329c0ded 100644
--- a/lib/curl_sasl.c
+++ b/lib/curl_sasl.c
@@ -42,7 +42,6 @@
#include "curl_sasl.h"
#include "warnless.h"
#include "strtok.h"
-#include "strequal.h"
#include "rawstr.h"
#include "sendf.h"
#include "non-ascii.h" /* included for Curl_convert_... prototypes */
@@ -159,7 +158,7 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
sasl->prefmech = SASL_AUTH_NONE;
}
- if(strnequal(value, "*", len))
+ if(!strncmp(value, "*", len))
sasl->prefmech = SASL_AUTH_DEFAULT;
else {
mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
diff --git a/lib/curlx.h b/lib/curlx.h
index 448a34ff3..521350e5d 100644
--- a/lib/curlx.h
+++ b/lib/curlx.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,8 +34,8 @@
functions while they still are offered publicly. They will be made library-
private one day */
-#include "strequal.h"
-/* "strequal.h" provides the strequal protos */
+#include "strcase.h"
+/* "strcase.h" provides the strcasecompare protos */
#include "strtoofft.h"
/* "strtoofft.h" provides this function: curlx_strtoofft(), returns a
@@ -73,8 +73,8 @@
*/
#define curlx_getenv curl_getenv
-#define curlx_strequal curl_strequal
-#define curlx_strnequal curl_strnequal
+#define curlx_strcasecompare curl_strcasecompare
+#define curlx_strncasecompare curl_strncasecompare
#define curlx_raw_equal Curl_raw_equal
#define curlx_mvsnprintf curl_mvsnprintf
#define curlx_msnprintf curl_msnprintf
diff --git a/lib/dict.c b/lib/dict.c
index 48a4e0a81..9dd76e738 100644
--- a/lib/dict.c
+++ b/lib/dict.c
@@ -54,7 +54,6 @@
#include "sendf.h"
#include "escape.h"
#include "progress.h"
-#include "strequal.h"
#include "dict.h"
#include "rawstr.h"
#include "curl_memory.h"
diff --git a/lib/easy.c b/lib/easy.c
index cb0ac6740..eee1061e8 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -50,7 +50,6 @@
#include <sys/param.h>
#endif
-#include "strequal.h"
#include "urldata.h"
#include <curl/curl.h>
#include "transfer.h"
diff --git a/lib/formdata.c b/lib/formdata.c
index ae75fe175..785f1a678 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -33,7 +33,7 @@
#include "urldata.h" /* for struct Curl_easy */
#include "formdata.h"
#include "vtls/vtls.h"
-#include "strequal.h"
+#include "strcase.h"
#include "sendf.h"
#include "strdup.h"
/* The last 3 #include files should be in this order */
@@ -201,9 +201,9 @@ static const char *ContentTypeForFilename(const char *filename,
if(filename) { /* in case a NULL was passed in */
for(i=0; i<sizeof(ctts)/sizeof(ctts[0]); i++) {
if(strlen(filename) >= strlen(ctts[i].extension)) {
- if(strequal(filename +
- strlen(filename) - strlen(ctts[i].extension),
- ctts[i].extension)) {
+ if(strcasecompare(filename +
+ strlen(filename) - strlen(ctts[i].extension),
+ ctts[i].extension)) {
contenttype = ctts[i].type;
break;
}
@@ -878,7 +878,7 @@ static CURLcode AddFormData(struct FormData **formp,
else {
/* Since this is a file to be uploaded here, add the size of the actual
file */
- if(!strequal("-", newform->line)) {
+ if(strcmp("-", newform->line)) {
struct_stat file;
if(!stat(newform->line, &file) && !S_ISDIR(file.st_mode))
*size += filesize(newform->line, file);
@@ -1305,7 +1305,7 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
/* we should include the contents from the specified file */
FILE *fileread;
- fileread = strequal("-", file->contents)?
+ fileread = !strcmp("-", file->contents)?
stdin:fopen(file->contents, "rb"); /* binary read for win32 */
/*
diff --git a/lib/ftp.c b/lib/ftp.c
index f78978d6b..99ad34bff 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -61,7 +61,7 @@
#include "ftplistparser.h"
#include "curl_sec.h"
#include "strtoofft.h"
-#include "strequal.h"
+#include "strcase.h"
#include "vtls/vtls.h"
#include "connect.h"
#include "strerror.h"
@@ -2999,7 +2999,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
/* Check for special servers here. */
- if(strequal(os, "OS/400")) {
+ if(strcasecompare(os, "OS/400")) {
/* Force OS400 name format 1. */
result = Curl_pp_sendf(&ftpc->pp, "%s", "SITE NAMEFMT 1");
if(result) {
@@ -4320,7 +4320,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
return CURLE_OUT_OF_MEMORY;
/* we have a special case for listing the root dir only */
- if(strequal(path_to_use, "/")) {
+ if(!strcmp(path_to_use, "/")) {
cur_pos++; /* make it point to the zero byte */
ftpc->dirs[0] = strdup("/");
ftpc->dirdepth++;
diff --git a/lib/gopher.c b/lib/gopher.c
index 4939ad540..690d5f1dc 100644
--- a/lib/gopher.c
+++ b/lib/gopher.c
@@ -30,7 +30,6 @@
#include "sendf.h"
#include "progress.h"
-#include "strequal.h"
#include "gopher.h"
#include "rawstr.h"
#include "select.h"
diff --git a/lib/http.c b/lib/http.c
index e6e7d377a..05d138f73 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -53,7 +53,6 @@
#include "progress.h"
#include "curl_base64.h"
#include "cookie.h"
-#include "strequal.h"
#include "vauth/vauth.h"
#include "vtls/vtls.h"
#include "http_digest.h"
diff --git a/lib/if2ip.c b/lib/if2ip.c
index 2f92b2def..e6faa4b80 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -51,7 +51,7 @@
#endif
#include "inet_ntop.h"
-#include "strequal.h"
+#include "strcase.h"
#include "if2ip.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -102,7 +102,7 @@ bool Curl_if_is_interface_name(const char *interf)
if(getifaddrs(&head) >= 0) {
for(iface=head; iface != NULL; iface=iface->ifa_next) {
- if(curl_strequal(iface->ifa_name, interf)) {
+ if(strcasecompare(iface->ifa_name, interf)) {
result = TRUE;
break;
}
@@ -132,7 +132,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
for(iface = head; iface != NULL; iface=iface->ifa_next) {
if(iface->ifa_addr != NULL) {
if(iface->ifa_addr->sa_family == af) {
- if(curl_strequal(iface->ifa_name, interf)) {
+ if(strcasecompare(iface->ifa_name, interf)) {
void *addr;
char *ip;
char scope[12] = "";
@@ -180,7 +180,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
}
}
else if((res == IF2IP_NOT_FOUND) &&
- curl_strequal(iface->ifa_name, interf)) {
+ strcasecompare(iface->ifa_name, interf)) {
res = IF2IP_AF_NOT_SUPPORTED;
}
}
diff --git a/lib/imap.c b/lib/imap.c
index 50a351284..6681a4d73 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -68,9 +68,8 @@
#include "http.h" /* for HTTP proxy tunnel stuff */
#include "socks.h"
#include "imap.h"
-
#include "strtoofft.h"
-#include "strequal.h"
+#include "strcase.h"
#include "vtls/vtls.h"
#include "connect.h"
#include "strerror.h"
@@ -1935,7 +1934,7 @@ static CURLcode imap_parse_url_options(struct connectdata *conn)
while(*ptr && *ptr != ';')
ptr++;
- if(strnequal(key, "AUTH=", 5))
+ if(strncasecompare(key, "AUTH=", 5))
result = Curl_sasl_parse_url_auth_option(&imapc->sasl,
value, ptr - value);
else
diff --git a/lib/netrc.c b/lib/netrc.c
index 46f427a2b..558440a11 100644
--- a/lib/netrc.c
+++ b/lib/netrc.c
@@ -28,8 +28,6 @@
#include <curl/curl.h>
#include "netrc.h"
-
-#include "strequal.h"
#include "strtok.h"
#include "rawstr.h"
diff --git a/lib/pop3.c b/lib/pop3.c
index 154e5c38b..55ad98c0d 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -70,9 +70,8 @@
#include "http.h" /* for HTTP proxy tunnel stuff */
#include "socks.h"
#include "pop3.h"
-
#include "strtoofft.h"
-#include "strequal.h"
+#include "strcase.h"
#include "vtls/vtls.h"
#include "connect.h"
#include "strerror.h"
@@ -1412,11 +1411,11 @@ static CURLcode pop3_parse_url_options(struct connectdata *conn)
while(*ptr && *ptr != ';')
ptr++;
- if(strnequal(key, "AUTH=", 5)) {
+ if(strncasecompare(key, "AUTH=", 5)) {
result = Curl_sasl_parse_url_auth_option(&pop3c->sasl,
value, ptr - value);
- if(result && strnequal(value, "+APOP", ptr - value)) {
+ if(result && strncasecompare(value, "+APOP", ptr - value)) {
pop3c->preftype = POP3_TYPE_APOP;
pop3c->sasl.prefmech = SASL_AUTH_NONE;
result = CURLE_OK;
diff --git a/lib/smtp.c b/lib/smtp.c
index 98504df79..d127750ac 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -69,9 +69,8 @@
#include "http.h" /* for HTTP proxy tunnel stuff */
#include "socks.h"
#include "smtp.h"
-
#include "strtoofft.h"
-#include "strequal.h"
+#include "strcase.h"
#include "vtls/vtls.h"
#include "connect.h"
#include "strerror.h"
@@ -1512,7 +1511,7 @@ static CURLcode smtp_parse_url_options(struct connectdata *conn)
while(*ptr && *ptr != ';')
ptr++;
- if(strnequal(key, "AUTH=", 5))
+ if(strncasecompare(key, "AUTH=", 5))
result = Curl_sasl_parse_url_auth_option(&smtpc->sasl,
value, ptr - value);
else
diff --git a/lib/socks.c b/lib/socks.c
index 291a2fb59..742d41156 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -33,7 +33,6 @@
#include "urldata.h"
#include "sendf.h"
-#include "strequal.h"
#include "select.h"
#include "connect.h"
#include "timeval.h"
diff --git a/lib/ssh.c b/lib/ssh.c
index ad1147511..0410115ab 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -1233,7 +1233,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->acceptfail = TRUE;
}
- if(curl_strequal("pwd", cmd)) {
+ if(strcasecompare("pwd", cmd)) {
/* output debug output if that is requested */
char *tmp = aprintf("257 \"%s\" is current directory.\n",
sftp_scp->path);
diff --git a/lib/strequal.c b/lib/strcase.c
index 01c378442..14cbe4c54 100644
--- a/lib/strequal.c
+++ b/lib/strcase.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,12 +26,12 @@
#include <strings.h>
#endif
-#include "strequal.h"
+#include "strcase.h"
/*
* @unittest: 1301
*/
-int curl_strequal(const char *first, const char *second)
+int curl_strcasecompare(const char *first, const char *second)
{
#if defined(HAVE_STRCASECMP)
return !(strcasecmp)(first, second);
@@ -54,7 +54,7 @@ int curl_strequal(const char *first, const char *second)
/*
* @unittest: 1301
*/
-int curl_strnequal(const char *first, const char *second, size_t max)
+int curl_strncasecompare(const char *first, const char *second, size_t max)
{
#if defined(HAVE_STRNCASECMP)
return !strncasecmp(first, second, max);
diff --git a/lib/strequal.h b/lib/strcase.h
index ff56df51f..aa36d9fab 100644
--- a/lib/strequal.h
+++ b/lib/strcase.h
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_STREQUAL_H
-#define HEADER_CURL_STREQUAL_H
+#ifndef HEADER_CURL_STRCASE_H
+#define HEADER_CURL_STRCASE_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,8 +24,11 @@
#include <curl/curl.h>
-#define strequal(a,b) curl_strequal(a,b)
-#define strnequal(a,b,c) curl_strnequal(a,b,c)
+#define strcasecompare(a,b) curl_strcasecompare(a,b)
+#define strncasecompare(a,b,c) curl_strncasecompare(a,b,c)
-#endif /* HEADER_CURL_STREQUAL_H */
+int curl_strcasecompare(const char *first, const char *second);
+int curl_strncasecompare(const char *first, const char *second, size_t max);
+
+#endif /* HEADER_CURL_STRCASE_H */
diff --git a/lib/telnet.c b/lib/telnet.c
index cc705cfc6..4f3af0340 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -58,7 +58,6 @@
#include "arpa_telnet.h"
#include "select.h"
-#include "strequal.h"
#include "rawstr.h"
#include "warnless.h"
diff --git a/lib/transfer.c b/lib/transfer.c
index a96baa2fc..d689d683e 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -21,9 +21,7 @@
***************************************************************************/
#include "curl_setup.h"
-
#include "strtoofft.h"
-#include "strequal.h"
#include "rawstr.h"
#ifdef HAVE_NETINET_IN_H
diff --git a/lib/url.c b/lib/url.c
index b2490fe15..adaaf3dce 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -79,7 +79,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "sendf.h"
#include "progress.h"
#include "cookie.h"
-#include "strequal.h"
+#include "strcase.h"
#include "strerror.h"
#include "escape.h"
#include "strtok.h"
@@ -2610,7 +2610,7 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
break;
case CURLOPT_TLSAUTH_TYPE:
- if(strnequal((char *)va_arg(param, char *), "SRP", strlen("SRP")))
+ if(strncasecompare((char *)va_arg(param, char *), "SRP", strlen("SRP")))
data->set.ssl.authtype = CURL_TLSAUTH_SRP;
else
data->set.ssl.authtype = CURL_TLSAUTH_NONE;
@@ -5422,7 +5422,8 @@ static CURLcode parse_connect_to_string(struct Curl_easy *data,
if(!hostname_to_match)
return CURLE_OUT_OF_MEMORY;
hostname_to_match_len = strlen(hostname_to_match);
- host_match = curl_strnequal(ptr, hostname_to_match, hostname_to_match_len);
+ host_match = strncasecompare(ptr, hostname_to_match,
+ hostname_to_match_len);
free(hostname_to_match);
ptr += hostname_to_match_len;
diff --git a/lib/vauth/cleartext.c b/lib/vauth/cleartext.c
index 4e906bc07..a9d72bfbe 100644
--- a/lib/vauth/cleartext.c
+++ b/lib/vauth/cleartext.c
@@ -33,7 +33,6 @@
#include "curl_md5.h"
#include "warnless.h"
#include "strtok.h"
-#include "strequal.h"
#include "rawstr.h"
#include "sendf.h"
#include "curl_printf.h"
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index 9befbeb77..b93b53fa2 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -46,7 +46,6 @@
#include "openssl.h"
#include "connect.h"
#include "slist.h"
-#include "strequal.h"
#include "select.h"
#include "vtls.h"
#include "rawstr.h"
diff --git a/lib/x509asn1.c b/lib/x509asn1.c
index e17bcd92d..0559cb6c4 100644
--- a/lib/x509asn1.c
+++ b/lib/x509asn1.c
@@ -178,7 +178,7 @@ static const curl_OID * searchOID(const char * oid)
Return the table entry pointer or NULL if not found. */
for(op = OIDtable; op->numoid; op++)
- if(!strcmp(op->numoid, oid) || curl_strequal(op->textoid, oid))
+ if(!strcmp(op->numoid, oid) || strcasecompare(op->textoid, oid))
return op;
return (const curl_OID *) NULL;
@@ -817,7 +817,7 @@ static void do_pubkey(struct Curl_easy * data, int certnum,
/* Get the public key (single element). */
Curl_getASN1Element(&pk, pubkey->beg + 1, pubkey->end);
- if(curl_strequal(algo, "rsaEncryption")) {
+ if(strcasecompare(algo, "rsaEncryption")) {
p = Curl_getASN1Element(&elem, pk.beg, pk.end);
/* Compute key length. */
for(q = elem.beg; !*q && q < elem.end; q++)
@@ -842,7 +842,7 @@ static void do_pubkey(struct Curl_easy * data, int certnum,
Curl_getASN1Element(&elem, p, pk.end);
do_pubkey_field(data, certnum, "rsa(e)", &elem);
}
- else if(curl_strequal(algo, "dsa")) {
+ else if(strcasecompare(algo, "dsa")) {
p = Curl_getASN1Element(&elem, param->beg, param->end);
do_pubkey_field(data, certnum, "dsa(p)", &elem);
p = Curl_getASN1Element(&elem, p, param->end);
@@ -851,7 +851,7 @@ static void do_pubkey(struct Curl_easy * data, int certnum,
do_pubkey_field(data, certnum, "dsa(g)", &elem);
do_pubkey_field(data, certnum, "dsa(pub_key)", &pk);
}
- else if(curl_strequal(algo, "dhpublicnumber")) {
+ else if(strcasecompare(algo, "dhpublicnumber")) {
p = Curl_getASN1Element(&elem, param->beg, param->end);
do_pubkey_field(data, certnum, "dh(p)", &elem);
Curl_getASN1Element(&elem, param->beg, param->end);
@@ -859,7 +859,7 @@ static void do_pubkey(struct Curl_easy * data, int certnum,
do_pubkey_field(data, certnum, "dh(pub_key)", &pk);
}
#if 0 /* Patent-encumbered. */
- else if(curl_strequal(algo, "ecPublicKey")) {
+ else if(strcasecompare(algo, "ecPublicKey")) {
/* Left TODO. */
}
#endif
diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c
index 97a5c92d3..221eae67f 100644
--- a/src/tool_cb_dbg.c
+++ b/src/tool_cb_dbg.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -73,9 +73,9 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
if(!config->trace_stream) {
/* open for append */
- if(curlx_strequal("-", config->trace_dump))
+ if(!strcmp("-", config->trace_dump))
config->trace_stream = stdout;
- else if(curlx_strequal("%", config->trace_dump))
+ else if(!strcmp("%", config->trace_dump))
/* Ok, this is somewhat hackish but we do it undocumented for now */
config->trace_stream = config->errors; /* aka stderr */
else {
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index e49acf803..34983b94d 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -416,7 +416,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
}
for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
- if(curlx_strnequal(aliases[j].lname, word, fnam)) {
+ if(curlx_strncasecompare(aliases[j].lname, word, fnam)) {
longopt = TRUE;
numhits++;
if(curlx_raw_equal(aliases[j].lname, word)) {
@@ -1109,7 +1109,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
break;
case 'C':
/* This makes us continue an ftp transfer at given position */
- if(!curlx_strequal(nextarg, "-")) {
+ if(strcmp(nextarg, "-")) {
err = str2offset(&config->resume_from, nextarg);
if(err)
return err;
@@ -1153,7 +1153,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
}
if('@' == is_file) {
/* a '@' letter, it means that a file name or - (stdin) follows */
- if(curlx_strequal("-", p)) {
+ if(!strcmp("-", p)) {
file = stdin;
set_binmode(stdin);
}
@@ -1218,7 +1218,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
or - (stdin) follows */
nextarg++; /* pass the @ */
- if(curlx_strequal("-", nextarg)) {
+ if(!strcmp("-", nextarg)) {
file = stdin;
if(subletter == 'b') /* forced data-binary */
set_binmode(stdin);
@@ -1377,7 +1377,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
case 'm': /* TLS authentication type */
if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) {
GetStr(&config->tls_authtype, nextarg);
- if(!strequal(config->tls_authtype, "SRP"))
+ if(!strcasecompare(config->tls_authtype, "SRP"))
return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
}
else
@@ -1770,7 +1770,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
FILE *file;
const char *fname;
nextarg++; /* pass the @ */
- if(curlx_strequal("-", nextarg)) {
+ if(!strcmp("-", nextarg)) {
fname = "<stdin>";
file = stdin;
}
@@ -1880,7 +1880,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
bool passarg;
char *flag = argv[i];
- if(curlx_strequal("--", argv[i]))
+ if(!strcmp("--", argv[i]))
/* This indicates the end of the flags and thus enables the
following (URL) argument to start with -. */
stillflags = FALSE;
@@ -1936,7 +1936,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
result != PARAM_ENGINES_REQUESTED) {
const char *reason = param2text(result);
- if(orig_opt && !curlx_strequal(":", orig_opt))
+ if(orig_opt && strcmp(":", orig_opt))
helpf(config->errors, "option %s: %s\n", orig_opt, reason);
else
helpf(config->errors, "%s\n", reason);
diff --git a/src/tool_helpers.c b/src/tool_helpers.c
index 14bc7668c..bfba3dcc1 100644
--- a/src/tool_helpers.c
+++ b/src/tool_helpers.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -104,11 +104,11 @@ void customrequest_helper(struct OperationConfig *config, HttpReq req,
if(!method)
;
- else if(curl_strequal(method, dflt[req])) {
+ else if(curlx_strcasecompare(method, dflt[req])) {
notef(config->global, "Unnecessary use of -X or --request, %s is already "
"inferred.\n", dflt[req]);
}
- else if(curl_strequal(method, "head")) {
+ else if(curlx_strcasecompare(method, "head")) {
warnf(config->global,
"Setting custom HTTP method to HEAD with -X/--request may not work "
"the way you want. Consider using -I/--head instead.\n");
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 88427ce4c..c8bc80a6a 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -321,7 +321,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
/* Single header file for all URLs */
if(config->headerfile) {
/* open file for output: */
- if(!curlx_strequal(config->headerfile, "-")) {
+ if(strcmp(config->headerfile, "-")) {
FILE *newfile = fopen(config->headerfile, "wb");
if(!newfile) {
warnf(config->global, "Failed to open %s\n", config->headerfile);
@@ -464,7 +464,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
urlnum = 1; /* without globbing, this is a single URL */
/* if multiple files extracted to stdout, insert separators! */
- separator= ((!outfiles || curlx_strequal(outfiles, "-")) && urlnum > 1);
+ separator= ((!outfiles || !strcmp(outfiles, "-")) && urlnum > 1);
/* Here's looping around each globbed URL */
for(li = 0 ; li < urlnum; li++) {
@@ -534,7 +534,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
}
if(((urlnode->flags&GETOUT_USEREMOTE) ||
- (outfile && !curlx_strequal("-", outfile))) &&
+ (outfile && strcmp("-", outfile))) &&
(metalink || !config->use_metalink)) {
/*
@@ -715,7 +715,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
DEBUGASSERT(infd == STDIN_FILENO);
set_binmode(stdin);
- if(curlx_strequal(uploadfile, ".")) {
+ if(!strcmp(uploadfile, ".")) {
if(curlx_nonblock((curl_socket_t)infd, TRUE) < 0)
warnf(config->global,
"fcntl failed on fd=%d: %s\n", infd, strerror(errno));
@@ -1559,7 +1559,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
char *effective_url = NULL;
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
if(effective_url &&
- curlx_strnequal(effective_url, "http", 4)) {
+ curlx_strncasecompare(effective_url, "http", 4)) {
/* This was HTTP(S) */
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
if(response != 200 && response != 206) {
@@ -1842,8 +1842,8 @@ CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
/* Parse .curlrc if necessary */
if((argc == 1) ||
- (!curlx_strequal(argv[1], "-q") &&
- !curlx_strequal(argv[1], "--disable"))) {
+ (!curlx_strcasecompare(argv[1], "-q") &&
+ !curlx_strcasecompare(argv[1], "--disable"))) {
parseconfig(NULL, config); /* ignore possible failure */
/* If we had no arguments then make sure a url was specified in .curlrc */
diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c
index b43dc9548..1c0d302ab 100644
--- a/src/tool_operhlp.c
+++ b/src/tool_operhlp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -63,8 +63,8 @@ bool output_expected(const char *url, const char *uploadfile)
bool stdin_upload(const char *uploadfile)
{
- return (curlx_strequal(uploadfile, "-") ||
- curlx_strequal(uploadfile, ".")) ? TRUE : FALSE;
+ return (!strcmp(uploadfile, "-") ||
+ !strcmp(uploadfile, ".")) ? TRUE : FALSE;
}
/*
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 6e94afe42..8b709cbe3 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -126,7 +126,7 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
keepit = *end;
*end = 0; /* zero terminate */
for(i = 0; replacements[i].name; i++) {
- if(curl_strequal(ptr, replacements[i].name)) {
+ if(curl_strcasecompare(ptr, replacements[i].name)) {
match = TRUE;
switch(replacements[i].id) {
case VAR_EFFECTIVE_URL:
diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c
index 994f9de06..7e3025df8 100644
--- a/tests/libtest/libauthretry.c
+++ b/tests/libtest/libauthretry.c
@@ -25,7 +25,7 @@
*/
#include "test.h"
-#include "strequal.h"
+#include "strcase.h"
#include "memdebug.h"
static CURLcode send_request(CURL *curl, const char *url, int seq,
@@ -72,11 +72,11 @@ static long parse_auth_name(const char *arg)
{
if(!arg)
return CURLAUTH_NONE;
- if(strequal(arg, "basic"))
+ if(strcasecompare(arg, "basic"))
return CURLAUTH_BASIC;
- if(strequal(arg, "digest"))
+ if(strcasecompare(arg, "digest"))
return CURLAUTH_DIGEST;
- if(strequal(arg, "ntlm"))
+ if(strcasecompare(arg, "ntlm"))
return CURLAUTH_NTLM;
return CURLAUTH_NONE;
}
diff --git a/tests/server/Makefile.inc b/tests/server/Makefile.inc
index 6e81dfdbc..3490e7872 100644
--- a/tests/server/Makefile.inc
+++ b/tests/server/Makefile.inc
@@ -3,7 +3,7 @@ noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd fake_ntlm
CURLX_SRCS = \
../../lib/mprintf.c \
../../lib/nonblock.c \
- ../../lib/strequal.c \
+ ../../lib/strcase.c \
../../lib/strtoofft.c \
../../lib/timeval.c \
../../lib/warnless.c
@@ -11,7 +11,7 @@ CURLX_SRCS = \
CURLX_HDRS = \
../../lib/curlx.h \
../../lib/nonblock.h \
- ../../lib/strequal.h \
+ ../../lib/strcase.h \
../../lib/strtoofft.h \
../../lib/timeval.h \
../../lib/warnless.h
diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c
index 91ef6c62b..96310cf89 100644
--- a/tests/server/rtspd.c
+++ b/tests/server/rtspd.c
@@ -590,7 +590,7 @@ static int ProcessRequest(struct httprequest *req)
if(got_exit_signal)
return 1; /* done */
- if((req->cl==0) && curlx_strnequal("Content-Length:", line, 15)) {
+ if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
/* If we don't ignore content-length, we read it and we read the whole
request including the body before we return. If we've been told to
ignore the content-length, we will return as soon as all headers
@@ -616,8 +616,8 @@ static int ProcessRequest(struct httprequest *req)
logmsg("... but will abort after %zu bytes", req->cl);
break;
}
- else if(curlx_strnequal("Transfer-Encoding: chunked", line,
- strlen("Transfer-Encoding: chunked"))) {
+ else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
+ strlen("Transfer-Encoding: chunked"))) {
/* chunked data coming in */
chunked = TRUE;
}
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 27c86e013..801a7b83f 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -697,7 +697,7 @@ static int ProcessRequest(struct httprequest *req)
if(got_exit_signal)
return 1; /* done */
- if((req->cl==0) && curlx_strnequal("Content-Length:", line, 15)) {
+ if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
/* If we don't ignore content-length, we read it and we read the whole
request including the body before we return. If we've been told to
ignore the content-length, we will return as soon as all headers
@@ -723,8 +723,8 @@ static int ProcessRequest(struct httprequest *req)
logmsg("... but will abort after %zu bytes", req->cl);
break;
}
- else if(curlx_strnequal("Transfer-Encoding: chunked", line,
- strlen("Transfer-Encoding: chunked"))) {
+ else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
+ strlen("Transfer-Encoding: chunked"))) {
/* chunked data coming in */
chunked = TRUE;
}
diff --git a/tests/unit/unit1301.c b/tests/unit/unit1301.c
index 928076e29..0d6c0cdef 100644
--- a/tests/unit/unit1301.c
+++ b/tests/unit/unit1301.c
@@ -21,7 +21,7 @@
***************************************************************************/
#include "curlcheck.h"
-#include "strequal.h"
+#include "strcase.h"
static CURLcode unit_setup(void) {return CURLE_OK;}
static void unit_stop(void) {}
@@ -30,25 +30,25 @@ UNITTEST_START
int rc;
-rc = curl_strequal("iii", "III");
+rc = curl_strcasecompare("iii", "III");
fail_unless(rc != 0, "return code should be zero");
-rc = curl_strequal("iiia", "III");
+rc = curl_strcasecompare("iiia", "III");
fail_unless(rc == 0, "return code should be zero");
-rc = curl_strequal("iii", "IIIa");
+rc = curl_strcasecompare("iii", "IIIa");
fail_unless(rc == 0, "return code should be zero");
-rc = curl_strequal("iiiA", "IIIa");
+rc = curl_strcasecompare("iiiA", "IIIa");
fail_unless(rc != 0, "return code should be non-zero");
-rc = curl_strnequal("iii", "III", 3);
+rc = curl_strncasecompare("iii", "III", 3);
fail_unless(rc != 0, "return code should be non-zero");
-rc = curl_strnequal("iiiABC", "IIIcba", 3);
+rc = curl_strncasecompare("iiiABC", "IIIcba", 3);
fail_unless(rc != 0, "return code should be non-zero");
-rc = curl_strnequal("ii", "II", 3);
+rc = curl_strncasecompare("ii", "II", 3);
fail_unless(rc != 0, "return code should be non-zero");
UNITTEST_STOP