From 95bd2b3e7f00b9ecbd4d5ea7d8bc3b59fcb038c0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 31 Oct 2016 21:49:38 +0100 Subject: 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 --- src/Makefile.inc | 2 -- src/tool_getparam.c | 8 ++++---- src/tool_helpers.c | 4 ++-- src/tool_libinfo.c | 4 ++-- src/tool_metalink.c | 12 ++++++------ src/tool_operate.c | 6 +++--- src/tool_paramhlp.c | 20 ++++++++++---------- 7 files changed, 27 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/Makefile.inc b/src/Makefile.inc index 368c18b7e..2196ffa33 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -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 diff --git a/src/tool_getparam.c b/src/tool_getparam.c index a546888c5..95dd4555f 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -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 diff --git a/src/tool_helpers.c b/src/tool_helpers.c index b89497b33..b5a619b91 100644 --- a/src/tool_helpers.c +++ b/src/tool_helpers.c @@ -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"); diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c index 190b93aa1..d2bf7fb93 100644 --- a/src/tool_libinfo.c +++ b/src/tool_libinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, , 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; } diff --git a/src/tool_metalink.c b/src/tool_metalink.c index 77f3ba513..985e7c323 100644 --- a/src/tool_metalink.c +++ b/src/tool_metalink.c @@ -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) == ';'); } diff --git a/src/tool_operate.c b/src/tool_operate.c index 3307dfc3c..deae87753 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -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 */ diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index c443d779d..7de490525 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -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", -- cgit v1.2.3