]> granicus.if.org Git - curl/commitdiff
strcase: make the tool use curl_str[n]equal instead
authorDaniel Stenberg <daniel@haxx.se>
Mon, 31 Oct 2016 20:49:38 +0000 (21:49 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 31 Oct 2016 20:51:19 +0000 (21:51 +0100)
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

lib/curlx.h
src/Makefile.inc
src/tool_getparam.c
src/tool_helpers.c
src/tool_libinfo.c
src/tool_metalink.c
src/tool_operate.c
src/tool_paramhlp.c

index 101491b842d416d7dbf31c7a164953f9a3d97d8f..6168dc119f12d1ab479e9bdbdb90fb26099f5b54 100644 (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
index 368c18b7ef86d1bdd4de1c308f81d28a08385088..2196ffa33e2a3996547a27151775f79d963ed712 100644 (file)
 # 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
 
index a546888c5f012e862a5d188306d71e3d500379af..95dd4555f70d9614b845567a437a5f1becffa659 100644 (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
index b89497b33c1dd28c931a1fa1f479edd5b5ea15ed..b5a619b91e7277dae79a380e1ebb44eafd385783 100644 (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");
index 190b93aa1169fea7e13c285c945021cba045f54c..d2bf7fb93b555135164f3917e1ecd1de11bf8c26 100644 (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;
         }
index 77f3ba513df7a13992bc5ac7d39e1b77e514bd29..985e7c323595bb3028e8c8e18677df3df0b2c2c7 100644 (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) == ';');
 }
index 3307dfc3cd50454b7b89a94d1d714fa191b5d26b..deae87753cf1fabd4bf654b6381b36d7a3d8da42 100644 (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 */
index c443d779d6cc57c4a404886bc76335738ea74b2d..7de490525e0a816b2de1f1cb9d3e54257ed62453 100644 (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",