mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Take in account that CURLAUTH_* bitmasks are now 'unsigned long' - follow-up
MIPSPro compiler detected curl_easy_getinfo() related missing adjustments. SunPro compiler detected curl tool --libcurl option related missing adjustments.
This commit is contained in:
parent
df4205c10a
commit
94111bbbd4
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2012, 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
|
||||
@ -87,6 +87,11 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
|
||||
struct curl_slist * to_slist;
|
||||
} ptr;
|
||||
|
||||
union {
|
||||
unsigned long *to_ulong;
|
||||
long *to_long;
|
||||
} lptr;
|
||||
|
||||
if(!data)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
|
||||
@ -191,10 +196,12 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
|
||||
*param_charp = (char *) data->set.private_data;
|
||||
break;
|
||||
case CURLINFO_HTTPAUTH_AVAIL:
|
||||
*param_longp = data->info.httpauthavail;
|
||||
lptr.to_long = param_longp;
|
||||
*lptr.to_ulong = data->info.httpauthavail;
|
||||
break;
|
||||
case CURLINFO_PROXYAUTH_AVAIL:
|
||||
*param_longp = data->info.proxyauthavail;
|
||||
lptr.to_long = param_longp;
|
||||
*lptr.to_ulong = data->info.proxyauthavail;
|
||||
break;
|
||||
case CURLINFO_OS_ERRNO:
|
||||
*param_longp = data->state.os_errno;
|
||||
|
@ -841,19 +841,19 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
||||
|
||||
/* new in libcurl 7.10.6 */
|
||||
if(config->proxyanyauth)
|
||||
my_setopt_flags(curl, CURLOPT_PROXYAUTH,
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long) CURLAUTH_ANY);
|
||||
else if(config->proxynegotiate)
|
||||
my_setopt_flags(curl, CURLOPT_PROXYAUTH,
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long) CURLAUTH_GSSNEGOTIATE);
|
||||
else if(config->proxyntlm)
|
||||
my_setopt_flags(curl, CURLOPT_PROXYAUTH,
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long) CURLAUTH_NTLM);
|
||||
else if(config->proxydigest)
|
||||
my_setopt_flags(curl, CURLOPT_PROXYAUTH,
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long) CURLAUTH_DIGEST);
|
||||
else if(config->proxybasic)
|
||||
my_setopt_flags(curl, CURLOPT_PROXYAUTH,
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long) CURLAUTH_BASIC);
|
||||
|
||||
/* new in libcurl 7.19.4 */
|
||||
@ -919,7 +919,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
||||
|
||||
/* new in libcurl 7.10.6 (default is Basic) */
|
||||
if(config->authtype)
|
||||
my_setopt_flags(curl, CURLOPT_HTTPAUTH, (long) config->authtype);
|
||||
my_setopt_bitmask(curl, CURLOPT_HTTPAUTH, (long) config->authtype);
|
||||
|
||||
/* curl 7.19.1 (the 301 version existed in 7.18.2),
|
||||
303 was added in 7.26.0 */
|
||||
|
@ -51,7 +51,7 @@ const NameValue setopt_nv_CURLPROXY[] = {
|
||||
NVEND,
|
||||
};
|
||||
|
||||
const NameValue setopt_nv_CURLAUTH[] = {
|
||||
const NameValueUnsigned setopt_nv_CURLAUTH[] = {
|
||||
NV(CURLAUTH_ANY), /* combination */
|
||||
NV(CURLAUTH_ANYSAFE), /* combination */
|
||||
NV(CURLAUTH_BASIC),
|
||||
@ -234,7 +234,7 @@ CURLcode tool_setopt_enum(CURL *curl, struct Configurable *config,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* setopt wrapper for bit mask */
|
||||
/* setopt wrapper for flags */
|
||||
CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config,
|
||||
const char *name, CURLoption tag,
|
||||
const NameValue *nvlist, long lval)
|
||||
@ -276,6 +276,49 @@ CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* setopt wrapper for bitmasks */
|
||||
CURLcode tool_setopt_bitmask(CURL *curl, struct Configurable *config,
|
||||
const char *name, CURLoption tag,
|
||||
const NameValueUnsigned *nvlist,
|
||||
long lval)
|
||||
{
|
||||
CURLcode ret = CURLE_OK;
|
||||
bool skip = FALSE;
|
||||
|
||||
ret = curl_easy_setopt(curl, tag, lval);
|
||||
if(!lval)
|
||||
skip = TRUE;
|
||||
|
||||
if(config->libcurl && !skip && !ret) {
|
||||
/* we only use this for real if --libcurl was used */
|
||||
char preamble[80];
|
||||
unsigned long rest = (unsigned long)lval;
|
||||
const NameValueUnsigned *nv = NULL;
|
||||
snprintf(preamble, sizeof(preamble),
|
||||
"curl_easy_setopt(hnd, %s, ", name);
|
||||
for(nv=nvlist; nv->name; nv++) {
|
||||
if((nv->value & ~ rest) == 0) {
|
||||
/* all value flags contained in rest */
|
||||
rest &= ~ nv->value; /* remove bits handled here */
|
||||
CODE3("%s(long)%s%s",
|
||||
preamble, nv->name, rest ? " |" : ");");
|
||||
if(!rest)
|
||||
break; /* handled them all */
|
||||
/* replace with all spaces for continuation line */
|
||||
sprintf(preamble, "%*s", strlen(preamble), "");
|
||||
}
|
||||
}
|
||||
/* If any bits have no definition, output an explicit value.
|
||||
* This could happen if new bits are defined and used
|
||||
* but the NameValue list is not updated. */
|
||||
if(rest)
|
||||
CODE2("%s%luUL);", preamble, rest);
|
||||
}
|
||||
|
||||
nomem:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* setopt wrapper for CURLOPT_HTTPPOST */
|
||||
CURLcode tool_setopt_httppost(CURL *curl, struct Configurable *config,
|
||||
const char *name, CURLoption tag,
|
||||
|
@ -41,13 +41,18 @@ typedef struct {
|
||||
long value;
|
||||
} NameValue;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
unsigned long value;
|
||||
} NameValueUnsigned;
|
||||
|
||||
extern const NameValue setopt_nv_CURLPROXY[];
|
||||
extern const NameValue setopt_nv_CURLAUTH[];
|
||||
extern const NameValue setopt_nv_CURL_HTTP_VERSION[];
|
||||
extern const NameValue setopt_nv_CURL_SSLVERSION[];
|
||||
extern const NameValue setopt_nv_CURL_TIMECOND[];
|
||||
extern const NameValue setopt_nv_CURLFTPSSL_CCC[];
|
||||
extern const NameValue setopt_nv_CURLPROTO[];
|
||||
extern const NameValueUnsigned setopt_nv_CURLAUTH[];
|
||||
|
||||
/* Map options to NameValue sets */
|
||||
#define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION
|
||||
@ -68,6 +73,9 @@ CURLcode tool_setopt_enum(CURL *curl, struct Configurable *config,
|
||||
CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config,
|
||||
const char *name, CURLoption tag,
|
||||
const NameValue *nv, long lval);
|
||||
CURLcode tool_setopt_bitmask(CURL *curl, struct Configurable *config,
|
||||
const char *name, CURLoption tag,
|
||||
const NameValueUnsigned *nv, long lval);
|
||||
CURLcode tool_setopt_httppost(CURL *curl, struct Configurable *config,
|
||||
const char *name, CURLoption tag,
|
||||
struct curl_httppost *httppost);
|
||||
@ -89,6 +97,9 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
|
||||
#define my_setopt_flags(x,y,z) \
|
||||
SETOPT_CHECK(tool_setopt_flags(x, config, #y, y, setopt_nv_ ## y, z))
|
||||
|
||||
#define my_setopt_bitmask(x,y,z) \
|
||||
SETOPT_CHECK(tool_setopt_bitmask(x, config, #y, y, setopt_nv_ ## y, z))
|
||||
|
||||
#define my_setopt_httppost(x,y,z) \
|
||||
SETOPT_CHECK(tool_setopt_httppost(x, config, #y, y, z))
|
||||
|
||||
@ -115,6 +126,9 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
|
||||
#define my_setopt_flags(x,y,z) \
|
||||
SETOPT_CHECK(curl_easy_setopt(x, y, z))
|
||||
|
||||
#define my_setopt_bitmask(x,y,z) \
|
||||
SETOPT_CHECK(curl_easy_setopt(x, y, z))
|
||||
|
||||
#define my_setopt_httppost(x,y,z) \
|
||||
SETOPT_CHECK(curl_easy_setopt(x, y, z))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user