strcase: make the tool use curl_str[n]equal instead

As they are after all part of the public API. Saves space and reduces
complexity. Remove the strcase defines from the curlx_ family.

Suggested-by: Dan Fandrich
Idea: https://curl.haxx.se/mail/lib-2016-10/0136.html
This commit is contained in:
Daniel Stenberg 2016-10-31 21:49:38 +01:00
parent 1071680946
commit 95bd2b3e7f
8 changed files with 27 additions and 31 deletions

View File

@ -73,8 +73,6 @@
*/
#define curlx_getenv curl_getenv
#define curlx_strcasecompare curl_strequal
#define curlx_strncasecompare curl_strnequal
#define curlx_mvsnprintf curl_mvsnprintf
#define curlx_msnprintf curl_msnprintf
#define curlx_maprintf curl_maprintf

View File

@ -11,14 +11,12 @@
# the official API, but we re-use the code here to avoid duplication.
CURLX_CFILES = \
../lib/strtoofft.c \
../lib/strcase.c \
../lib/nonblock.c \
../lib/warnless.c
CURLX_HFILES = \
../lib/curl_setup.h \
../lib/strtoofft.h \
../lib/strcase.h \
../lib/nonblock.h \
../lib/warnless.h

View File

@ -416,10 +416,10 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
}
for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
if(curlx_strncasecompare(aliases[j].lname, word, fnam)) {
if(curl_strnequal(aliases[j].lname, word, fnam)) {
longopt = TRUE;
numhits++;
if(curlx_strcasecompare(aliases[j].lname, word)) {
if(curl_strequal(aliases[j].lname, word)) {
parse = aliases[j].letter;
hit = j;
numhits = 1; /* a single unique hit */
@ -1343,7 +1343,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
break;
case 'f': /* crypto engine */
GetStr(&config->engine, nextarg);
if(config->engine && curlx_strcasecompare(config->engine, "list"))
if(config->engine && curl_strequal(config->engine, "list"))
return PARAM_ENGINES_REQUESTED;
break;
case 'g': /* CA info PEM file */
@ -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(!strcasecompare(config->tls_authtype, "SRP"))
if(!curl_strequal(config->tls_authtype, "SRP"))
return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
}
else

View File

@ -104,11 +104,11 @@ void customrequest_helper(struct OperationConfig *config, HttpReq req,
if(!method)
;
else if(curlx_strcasecompare(method, dflt[req])) {
else if(curl_strequal(method, dflt[req])) {
notef(config->global, "Unnecessary use of -X or --request, %s is already "
"inferred.\n", dflt[req]);
}
else if(curlx_strcasecompare(method, "head")) {
else if(curl_strequal(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");

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2014, 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
@ -89,7 +89,7 @@ CURLcode get_libcurl_info(void)
if(curlinfo->protocols) {
for(proto = curlinfo->protocols; *proto; proto++) {
for(p = possibly_built_in; p->proto_name; p++) {
if(curlx_strcasecompare(*proto, p->proto_name)) {
if(curl_strequal(*proto, p->proto_name)) {
built_in_protos |= p->proto_pattern;
break;
}

View File

@ -747,7 +747,7 @@ static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
++digest_alias) {
metalink_checksum_t **p;
for(p = fileinfo->checksums; *p; ++p) {
if(strcasecompare(digest_alias->alias_name, (*p)->type) &&
if(curl_strequal(digest_alias->alias_name, (*p)->type) &&
check_hex_digest((*p)->hash, digest_alias->digest_def)) {
f->checksum =
new_metalink_checksum_from_hex_digest(digest_alias->digest_def,
@ -777,10 +777,10 @@ static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
metainfo file URL may be appeared in fileinfo->metaurls.
*/
if((*p)->type == NULL ||
strcasecompare((*p)->type, "http") ||
strcasecompare((*p)->type, "https") ||
strcasecompare((*p)->type, "ftp") ||
strcasecompare((*p)->type, "ftps")) {
curl_strequal((*p)->type, "http") ||
curl_strequal((*p)->type, "https") ||
curl_strequal((*p)->type, "ftp") ||
curl_strequal((*p)->type, "ftps")) {
res = new_metalink_resource((*p)->url);
tail->next = res;
tail = res;
@ -906,7 +906,7 @@ static int check_content_type(const char *content_type, const char *media_type)
if(!*ptr) {
return 0;
}
return strncasecompare(ptr, media_type, media_type_len) &&
return curl_strnequal(ptr, media_type, media_type_len) &&
(*(ptr+media_type_len) == '\0' || *(ptr+media_type_len) == ' ' ||
*(ptr+media_type_len) == '\t' || *(ptr+media_type_len) == ';');
}

View File

@ -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_strncasecompare(effective_url, "http", 4)) {
curl_strnequal(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_strcasecompare(argv[1], "-q") &&
!curlx_strcasecompare(argv[1], "--disable"))) {
(!curl_strequal(argv[1], "-q") &&
!curl_strequal(argv[1], "--disable"))) {
parseconfig(NULL, config); /* ignore possible failure */
/* If we had no arguments then make sure a url was specified in .curlrc */

View File

@ -312,7 +312,7 @@ long proto2num(struct OperationConfig *config, long *val, const char *str)
}
for(pp=protos; pp->name; pp++) {
if(curlx_strcasecompare(token, pp->name)) {
if(curl_strequal(token, pp->name)) {
switch (action) {
case deny:
*val &= ~(pp->bit);
@ -355,7 +355,7 @@ int check_protocol(const char *str)
if(!str)
return PARAM_REQUIRES_PARAMETER;
for(pp = curlinfo->protocols; *pp; pp++) {
if(curlx_strcasecompare(*pp, str))
if(curl_strequal(*pp, str))
return PARAM_OK;
}
return PARAM_LIBCURL_UNSUPPORTED_PROTOCOL;
@ -466,11 +466,11 @@ ParameterError add2list(struct curl_slist **list, const char *ptr)
int ftpfilemethod(struct OperationConfig *config, const char *str)
{
if(curlx_strcasecompare("singlecwd", str))
if(curl_strequal("singlecwd", str))
return CURLFTPMETHOD_SINGLECWD;
if(curlx_strcasecompare("nocwd", str))
if(curl_strequal("nocwd", str))
return CURLFTPMETHOD_NOCWD;
if(curlx_strcasecompare("multicwd", str))
if(curl_strequal("multicwd", str))
return CURLFTPMETHOD_MULTICWD;
warnf(config->global, "unrecognized ftp file method '%s', using default\n",
@ -481,9 +481,9 @@ int ftpfilemethod(struct OperationConfig *config, const char *str)
int ftpcccmethod(struct OperationConfig *config, const char *str)
{
if(curlx_strcasecompare("passive", str))
if(curl_strequal("passive", str))
return CURLFTPSSL_CCC_PASSIVE;
if(curlx_strcasecompare("active", str))
if(curl_strequal("active", str))
return CURLFTPSSL_CCC_ACTIVE;
warnf(config->global, "unrecognized ftp CCC method '%s', using default\n",
@ -494,11 +494,11 @@ int ftpcccmethod(struct OperationConfig *config, const char *str)
long delegation(struct OperationConfig *config, char *str)
{
if(curlx_strcasecompare("none", str))
if(curl_strequal("none", str))
return CURLGSSAPI_DELEGATION_NONE;
if(curlx_strcasecompare("policy", str))
if(curl_strequal("policy", str))
return CURLGSSAPI_DELEGATION_POLICY_FLAG;
if(curlx_strcasecompare("always", str))
if(curl_strequal("always", str))
return CURLGSSAPI_DELEGATION_FLAG;
warnf(config->global, "unrecognized delegation method '%s', using none\n",