Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Take in account that CURLAUTH_* bitmasks are now 'unsigned long' - fo…

…llow-up

MIPSPro compiler detected curl_easy_getinfo() related missing adjustments.
SunPro compiler detected curl tool --libcurl option related missing adjustments.
  • Loading branch information...
commit 94111bbbd4f2c875bc33c9c84f6e365c1a1434d7 1 parent df4205c
yangtse authored April 19, 2012
13  lib/getinfo.c
@@ -5,7 +5,7 @@
5 5
  *                            | (__| |_| |  _ <| |___
6 6
  *                             \___|\___/|_| \_\_____|
7 7
  *
8  
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
  8
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
9 9
  *
10 10
  * This software is licensed as described in the file COPYING, which
11 11
  * you should have received as part of this distribution. The terms
@@ -87,6 +87,11 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
87 87
     struct curl_slist    * to_slist;
88 88
   } ptr;
89 89
 
  90
+  union {
  91
+    unsigned long *to_ulong;
  92
+    long          *to_long;
  93
+  } lptr;
  94
+
90 95
   if(!data)
91 96
     return CURLE_BAD_FUNCTION_ARGUMENT;
92 97
 
@@ -191,10 +196,12 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
191 196
     *param_charp = (char *) data->set.private_data;
192 197
     break;
193 198
   case CURLINFO_HTTPAUTH_AVAIL:
194  
-    *param_longp = data->info.httpauthavail;
  199
+    lptr.to_long = param_longp;
  200
+    *lptr.to_ulong = data->info.httpauthavail;
195 201
     break;
196 202
   case CURLINFO_PROXYAUTH_AVAIL:
197  
-    *param_longp = data->info.proxyauthavail;
  203
+    lptr.to_long = param_longp;
  204
+    *lptr.to_ulong = data->info.proxyauthavail;
198 205
     break;
199 206
   case CURLINFO_OS_ERRNO:
200 207
     *param_longp = data->state.os_errno;
22  src/tool_operate.c
@@ -841,20 +841,20 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
841 841
 
842 842
           /* new in libcurl 7.10.6 */
843 843
           if(config->proxyanyauth)
844  
-            my_setopt_flags(curl, CURLOPT_PROXYAUTH,
845  
-                            (long) CURLAUTH_ANY);
  844
+            my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
  845
+                              (long) CURLAUTH_ANY);
846 846
           else if(config->proxynegotiate)
847  
-            my_setopt_flags(curl, CURLOPT_PROXYAUTH,
848  
-                            (long) CURLAUTH_GSSNEGOTIATE);
  847
+            my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
  848
+                              (long) CURLAUTH_GSSNEGOTIATE);
849 849
           else if(config->proxyntlm)
850  
-            my_setopt_flags(curl, CURLOPT_PROXYAUTH,
851  
-                            (long) CURLAUTH_NTLM);
  850
+            my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
  851
+                              (long) CURLAUTH_NTLM);
852 852
           else if(config->proxydigest)
853  
-            my_setopt_flags(curl, CURLOPT_PROXYAUTH,
854  
-                            (long) CURLAUTH_DIGEST);
  853
+            my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
  854
+                              (long) CURLAUTH_DIGEST);
855 855
           else if(config->proxybasic)
856  
-            my_setopt_flags(curl, CURLOPT_PROXYAUTH,
857  
-                            (long) CURLAUTH_BASIC);
  856
+            my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
  857
+                              (long) CURLAUTH_BASIC);
858 858
 
859 859
           /* new in libcurl 7.19.4 */
860 860
           my_setopt(curl, CURLOPT_NOPROXY, config->noproxy);
@@ -919,7 +919,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
919 919
 
920 920
           /* new in libcurl 7.10.6 (default is Basic) */
921 921
           if(config->authtype)
922  
-            my_setopt_flags(curl, CURLOPT_HTTPAUTH, (long) config->authtype);
  922
+            my_setopt_bitmask(curl, CURLOPT_HTTPAUTH, (long) config->authtype);
923 923
 
924 924
           /* curl 7.19.1 (the 301 version existed in 7.18.2),
925 925
              303 was added in 7.26.0 */
47  src/tool_setopt.c
@@ -51,7 +51,7 @@ const NameValue setopt_nv_CURLPROXY[] = {
51 51
   NVEND,
52 52
 };
53 53
 
54  
-const NameValue setopt_nv_CURLAUTH[] = {
  54
+const NameValueUnsigned setopt_nv_CURLAUTH[] = {
55 55
   NV(CURLAUTH_ANY),             /* combination */
56 56
   NV(CURLAUTH_ANYSAFE),         /* combination */
57 57
   NV(CURLAUTH_BASIC),
@@ -234,7 +234,7 @@ CURLcode tool_setopt_enum(CURL *curl, struct Configurable *config,
234 234
   return ret;
235 235
 }
236 236
 
237  
-/* setopt wrapper for bit mask */
  237
+/* setopt wrapper for flags */
238 238
 CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config,
239 239
                            const char *name, CURLoption tag,
240 240
                            const NameValue *nvlist, long lval)
@@ -276,6 +276,49 @@ CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config,
276 276
   return ret;
277 277
 }
278 278
 
  279
+/* setopt wrapper for bitmasks */
  280
+CURLcode tool_setopt_bitmask(CURL *curl, struct Configurable *config,
  281
+                             const char *name, CURLoption tag,
  282
+                             const NameValueUnsigned *nvlist,
  283
+                             long lval)
  284
+{
  285
+  CURLcode ret = CURLE_OK;
  286
+  bool skip = FALSE;
  287
+
  288
+  ret = curl_easy_setopt(curl, tag, lval);
  289
+  if(!lval)
  290
+    skip = TRUE;
  291
+
  292
+  if(config->libcurl && !skip && !ret) {
  293
+    /* we only use this for real if --libcurl was used */
  294
+    char preamble[80];
  295
+    unsigned long rest = (unsigned long)lval;
  296
+    const NameValueUnsigned *nv = NULL;
  297
+    snprintf(preamble, sizeof(preamble),
  298
+             "curl_easy_setopt(hnd, %s, ", name);
  299
+    for(nv=nvlist; nv->name; nv++) {
  300
+      if((nv->value & ~ rest) == 0) {
  301
+        /* all value flags contained in rest */
  302
+        rest &= ~ nv->value;    /* remove bits handled here */
  303
+        CODE3("%s(long)%s%s",
  304
+              preamble, nv->name, rest ? " |" : ");");
  305
+        if(!rest)
  306
+          break;                /* handled them all */
  307
+        /* replace with all spaces for continuation line */
  308
+        sprintf(preamble, "%*s", strlen(preamble), "");
  309
+      }
  310
+    }
  311
+    /* If any bits have no definition, output an explicit value.
  312
+     * This could happen if new bits are defined and used
  313
+     * but the NameValue list is not updated. */
  314
+    if(rest)
  315
+      CODE2("%s%luUL);", preamble, rest);
  316
+  }
  317
+
  318
+ nomem:
  319
+  return ret;
  320
+}
  321
+
279 322
 /* setopt wrapper for CURLOPT_HTTPPOST */
280 323
 CURLcode tool_setopt_httppost(CURL *curl, struct Configurable *config,
281 324
                               const char *name, CURLoption tag,
16  src/tool_setopt.h
@@ -41,13 +41,18 @@ typedef struct {
41 41
   long value;
42 42
 } NameValue;
43 43
 
  44
+typedef struct {
  45
+  const char *name;
  46
+  unsigned long value;
  47
+} NameValueUnsigned;
  48
+
44 49
 extern const NameValue setopt_nv_CURLPROXY[];
45  
-extern const NameValue setopt_nv_CURLAUTH[];
46 50
 extern const NameValue setopt_nv_CURL_HTTP_VERSION[];
47 51
 extern const NameValue setopt_nv_CURL_SSLVERSION[];
48 52
 extern const NameValue setopt_nv_CURL_TIMECOND[];
49 53
 extern const NameValue setopt_nv_CURLFTPSSL_CCC[];
50 54
 extern const NameValue setopt_nv_CURLPROTO[];
  55
+extern const NameValueUnsigned setopt_nv_CURLAUTH[];
51 56
 
52 57
 /* Map options to NameValue sets */
53 58
 #define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION
@@ -68,6 +73,9 @@ CURLcode tool_setopt_enum(CURL *curl, struct Configurable *config,
68 73
 CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config,
69 74
                            const char *name, CURLoption tag,
70 75
                            const NameValue *nv, long lval);
  76
+CURLcode tool_setopt_bitmask(CURL *curl, struct Configurable *config,
  77
+                             const char *name, CURLoption tag,
  78
+                             const NameValueUnsigned *nv, long lval);
71 79
 CURLcode tool_setopt_httppost(CURL *curl, struct Configurable *config,
72 80
                               const char *name, CURLoption tag,
73 81
                               struct curl_httppost *httppost);
@@ -89,6 +97,9 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
89 97
 #define my_setopt_flags(x,y,z) \
90 98
   SETOPT_CHECK(tool_setopt_flags(x, config, #y, y, setopt_nv_ ## y, z))
91 99
 
  100
+#define my_setopt_bitmask(x,y,z) \
  101
+  SETOPT_CHECK(tool_setopt_bitmask(x, config, #y, y, setopt_nv_ ## y, z))
  102
+
92 103
 #define my_setopt_httppost(x,y,z) \
93 104
   SETOPT_CHECK(tool_setopt_httppost(x, config, #y, y, z))
94 105
 
@@ -115,6 +126,9 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
115 126
 #define my_setopt_flags(x,y,z) \
116 127
   SETOPT_CHECK(curl_easy_setopt(x, y, z))
117 128
 
  129
+#define my_setopt_bitmask(x,y,z) \
  130
+  SETOPT_CHECK(curl_easy_setopt(x, y, z))
  131
+
118 132
 #define my_setopt_httppost(x,y,z) \
119 133
   SETOPT_CHECK(curl_easy_setopt(x, y, z))
120 134
 

0 notes on commit 94111bb

Please sign in to comment.
Something went wrong with that request. Please try again.