mirror of
https://github.com/moparisthebest/curl
synced 2024-10-31 15:45:12 -04:00
avoid mixing of enumerated type with another type
This commit is contained in:
parent
b33074d893
commit
79954a1b07
@ -2943,7 +2943,7 @@ ConnectionExists(struct SessionHandle *data,
|
|||||||
struct connectdata *chosen = 0;
|
struct connectdata *chosen = 0;
|
||||||
bool canPipeline = IsPipeliningPossible(data, needle);
|
bool canPipeline = IsPipeliningPossible(data, needle);
|
||||||
bool wantNTLM = (data->state.authhost.want==CURLAUTH_NTLM) ||
|
bool wantNTLM = (data->state.authhost.want==CURLAUTH_NTLM) ||
|
||||||
(data->state.authhost.want==CURLAUTH_NTLM_WB);
|
(data->state.authhost.want==CURLAUTH_NTLM_WB) ? TRUE : FALSE;
|
||||||
|
|
||||||
for(i=0; i< data->state.connc->num; i++) {
|
for(i=0; i< data->state.connc->num; i++) {
|
||||||
bool match = FALSE;
|
bool match = FALSE;
|
||||||
|
@ -398,9 +398,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
GetStr(&config->egd_file, nextarg);
|
GetStr(&config->egd_file, nextarg);
|
||||||
break;
|
break;
|
||||||
case 'c': /* connect-timeout */
|
case 'c': /* connect-timeout */
|
||||||
rc=str2unum(&config->connecttimeout, nextarg);
|
err = str2unum(&config->connecttimeout, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
case 'd': /* ciphers */
|
case 'd': /* ciphers */
|
||||||
GetStr(&config->cipher_list, nextarg);
|
GetStr(&config->cipher_list, nextarg);
|
||||||
@ -545,9 +545,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
case 's': /* --max-redirs */
|
case 's': /* --max-redirs */
|
||||||
/* specified max no of redirects (http(s)), this accepts -1 as a
|
/* specified max no of redirects (http(s)), this accepts -1 as a
|
||||||
special condition */
|
special condition */
|
||||||
rc = str2num(&config->maxredirs, nextarg);
|
err = str2num(&config->maxredirs, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
if(config->maxredirs < -1)
|
if(config->maxredirs < -1)
|
||||||
return PARAM_BAD_NUMERIC;
|
return PARAM_BAD_NUMERIC;
|
||||||
break;
|
break;
|
||||||
@ -592,9 +592,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
return PARAM_LIBCURL_DOESNT_SUPPORT;
|
return PARAM_LIBCURL_DOESNT_SUPPORT;
|
||||||
break;
|
break;
|
||||||
case 'y': /* --max-filesize */
|
case 'y': /* --max-filesize */
|
||||||
rc = str2offset(&config->max_filesize, nextarg);
|
err = str2offset(&config->max_filesize, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
case 'z': /* --disable-eprt */
|
case 'z': /* --disable-eprt */
|
||||||
config->disable_eprt = toggle;
|
config->disable_eprt = toggle;
|
||||||
@ -670,19 +670,19 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
config->proxybasic = toggle;
|
config->proxybasic = toggle;
|
||||||
break;
|
break;
|
||||||
case 'g': /* --retry */
|
case 'g': /* --retry */
|
||||||
rc = str2unum(&config->req_retry, nextarg);
|
err = str2unum(&config->req_retry, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
case 'h': /* --retry-delay */
|
case 'h': /* --retry-delay */
|
||||||
rc = str2unum(&config->retry_delay, nextarg);
|
err = str2unum(&config->retry_delay, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
case 'i': /* --retry-max-time */
|
case 'i': /* --retry-max-time */
|
||||||
rc = str2unum(&config->retry_maxtime, nextarg);
|
err = str2unum(&config->retry_maxtime, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'k': /* --proxy-negotiate */
|
case 'k': /* --proxy-negotiate */
|
||||||
@ -769,9 +769,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
config->nokeepalive = (!toggle)?TRUE:FALSE;
|
config->nokeepalive = (!toggle)?TRUE:FALSE;
|
||||||
break;
|
break;
|
||||||
case '3': /* --keepalive-time */
|
case '3': /* --keepalive-time */
|
||||||
rc = str2unum(&config->alivetime, nextarg);
|
err = str2unum(&config->alivetime, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
case '4': /* --post302 */
|
case '4': /* --post302 */
|
||||||
config->post302 = toggle;
|
config->post302 = toggle;
|
||||||
@ -797,9 +797,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
config->proxyver = CURLPROXY_HTTP_1_0;
|
config->proxyver = CURLPROXY_HTTP_1_0;
|
||||||
break;
|
break;
|
||||||
case '9': /* --tftp-blksize */
|
case '9': /* --tftp-blksize */
|
||||||
rc = str2unum(&config->tftp_blksize, nextarg);
|
err = str2unum(&config->tftp_blksize, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
case 'A': /* --mail-from */
|
case 'A': /* --mail-from */
|
||||||
GetStr(&config->mail_from, nextarg);
|
GetStr(&config->mail_from, nextarg);
|
||||||
@ -924,9 +924,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
case 'C':
|
case 'C':
|
||||||
/* This makes us continue an ftp transfer at given position */
|
/* This makes us continue an ftp transfer at given position */
|
||||||
if(!curlx_strequal(nextarg, "-")) {
|
if(!curlx_strequal(nextarg, "-")) {
|
||||||
rc = str2offset(&config->resume_from, nextarg);
|
err = str2offset(&config->resume_from, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
config->resume_from_current = FALSE;
|
config->resume_from_current = FALSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1317,9 +1317,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
/* specified max time */
|
/* specified max time */
|
||||||
rc = str2unum(&config->timeout, nextarg);
|
err = str2unum(&config->timeout, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
break;
|
break;
|
||||||
case 'M': /* M for manual, huge help */
|
case 'M': /* M for manual, huge help */
|
||||||
if(toggle) { /* --no-manual shows no manual... */
|
if(toggle) { /* --no-manual shows no manual... */
|
||||||
@ -1633,17 +1633,17 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
break;
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
/* low speed time */
|
/* low speed time */
|
||||||
rc = str2unum(&config->low_speed_time, nextarg);
|
err = str2unum(&config->low_speed_time, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
if(!config->low_speed_limit)
|
if(!config->low_speed_limit)
|
||||||
config->low_speed_limit = 1;
|
config->low_speed_limit = 1;
|
||||||
break;
|
break;
|
||||||
case 'Y':
|
case 'Y':
|
||||||
/* low speed limit */
|
/* low speed limit */
|
||||||
rc = str2unum(&config->low_speed_limit, nextarg);
|
err = str2unum(&config->low_speed_limit, nextarg);
|
||||||
if(rc)
|
if(err)
|
||||||
return rc;
|
return err;
|
||||||
if(!config->low_speed_time)
|
if(!config->low_speed_time)
|
||||||
config->low_speed_time = 30;
|
config->low_speed_time = 30;
|
||||||
break;
|
break;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "tool_setup.h"
|
#include "tool_setup.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PARAM_OK,
|
PARAM_OK = 0,
|
||||||
PARAM_OPTION_AMBIGUOUS,
|
PARAM_OPTION_AMBIGUOUS,
|
||||||
PARAM_OPTION_UNKNOWN,
|
PARAM_OPTION_UNKNOWN,
|
||||||
PARAM_REQUIRES_PARAMETER,
|
PARAM_REQUIRES_PARAMETER,
|
||||||
|
@ -146,15 +146,15 @@ void cleanarg(char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the string and write the long in the given address. Return non-zero
|
* Parse the string and write the long in the given address. Return PARAM_OK
|
||||||
* on failure, zero on success.
|
* on success, otherwise a parameter specific error enum.
|
||||||
*
|
*
|
||||||
* Since this function gets called with the 'nextarg' pointer from within the
|
* Since this function gets called with the 'nextarg' pointer from within the
|
||||||
* getparameter a lot, we must check it for NULL before accessing the str
|
* getparameter a lot, we must check it for NULL before accessing the str
|
||||||
* data.
|
* data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int str2num(long *val, const char *str)
|
ParameterError str2num(long *val, const char *str)
|
||||||
{
|
{
|
||||||
if(str) {
|
if(str) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
@ -168,15 +168,15 @@ int str2num(long *val, const char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the string and write the long in the given address. Return non-zero
|
* Parse the string and write the long in the given address. Return PARAM_OK
|
||||||
* on failure, zero on success. ONLY ACCEPTS POSITIVE NUMBERS!
|
* on success, otherwise a parameter error enum. ONLY ACCEPTS POSITIVE NUMBERS!
|
||||||
*
|
*
|
||||||
* Since this function gets called with the 'nextarg' pointer from within the
|
* Since this function gets called with the 'nextarg' pointer from within the
|
||||||
* getparameter a lot, we must check it for NULL before accessing the str
|
* getparameter a lot, we must check it for NULL before accessing the str
|
||||||
* data.
|
* data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int str2unum(long *val, const char *str)
|
ParameterError str2unum(long *val, const char *str)
|
||||||
{
|
{
|
||||||
if(str[0]=='-')
|
if(str[0]=='-')
|
||||||
return PARAM_NEGATIVE_NUMERIC; /* badness */
|
return PARAM_NEGATIVE_NUMERIC; /* badness */
|
||||||
@ -295,9 +295,9 @@ long proto2num(struct Configurable *config, long *val, const char *str)
|
|||||||
*
|
*
|
||||||
* @param val the offset to populate
|
* @param val the offset to populate
|
||||||
* @param str the buffer containing the offset
|
* @param str the buffer containing the offset
|
||||||
* @return zero if successful, non-zero if failure.
|
* @return PARAM_OK if successful, a parameter specific error enum if failure.
|
||||||
*/
|
*/
|
||||||
int str2offset(curl_off_t *val, const char *str)
|
ParameterError str2offset(curl_off_t *val, const char *str)
|
||||||
{
|
{
|
||||||
char *endptr;
|
char *endptr;
|
||||||
if(str[0] == '-')
|
if(str[0] == '-')
|
||||||
@ -314,7 +314,7 @@ int str2offset(curl_off_t *val, const char *str)
|
|||||||
return PARAM_BAD_NUMERIC;
|
return PARAM_BAD_NUMERIC;
|
||||||
#endif
|
#endif
|
||||||
if((endptr != str) && (endptr == str + strlen(str)))
|
if((endptr != str) && (endptr == str + strlen(str)))
|
||||||
return 0; /* Ok */
|
return PARAM_OK;
|
||||||
|
|
||||||
return PARAM_BAD_NUMERIC;
|
return PARAM_BAD_NUMERIC;
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file);
|
|||||||
|
|
||||||
void cleanarg(char *str);
|
void cleanarg(char *str);
|
||||||
|
|
||||||
int str2num(long *val, const char *str);
|
ParameterError str2num(long *val, const char *str);
|
||||||
int str2unum(long *val, const char *str); /* for unsigned input numbers */
|
ParameterError str2unum(long *val, const char *str);
|
||||||
|
|
||||||
long proto2num(struct Configurable *config, long *val, const char *str);
|
long proto2num(struct Configurable *config, long *val, const char *str);
|
||||||
|
|
||||||
int str2offset(curl_off_t *val, const char *str);
|
ParameterError str2offset(curl_off_t *val, const char *str);
|
||||||
|
|
||||||
ParameterError checkpasswd(const char *kind, char **userpwd);
|
ParameterError checkpasswd(const char *kind, char **userpwd);
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
#include "strequal.h"
|
#include "strequal.h"
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
|
|
||||||
static int send_request(CURL *curl, const char *url, int seq,
|
static CURLcode send_request(CURL *curl, const char *url, int seq,
|
||||||
long auth_scheme, const char *userpwd)
|
long auth_scheme, const char *userpwd)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
char* full_url = malloc(strlen(url) + 4 + 1);
|
char* full_url = malloc(strlen(url) + 4 + 1);
|
||||||
@ -56,14 +56,14 @@ test_cleanup:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int send_wrong_password(CURL *curl, const char *url, int seq,
|
static CURLcode send_wrong_password(CURL *curl, const char *url, int seq,
|
||||||
long auth_scheme)
|
long auth_scheme)
|
||||||
{
|
{
|
||||||
return send_request(curl, url, seq, auth_scheme, "testuser:wrongpass");
|
return send_request(curl, url, seq, auth_scheme, "testuser:wrongpass");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int send_right_password(CURL *curl, const char *url, int seq,
|
static CURLcode send_right_password(CURL *curl, const char *url, int seq,
|
||||||
long auth_scheme)
|
long auth_scheme)
|
||||||
{
|
{
|
||||||
return send_request(curl, url, seq, auth_scheme, "testuser:testpass");
|
return send_request(curl, url, seq, auth_scheme, "testuser:testpass");
|
||||||
}
|
}
|
||||||
@ -85,7 +85,6 @@ int test(char *url)
|
|||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
CURL *curl = NULL;
|
CURL *curl = NULL;
|
||||||
bool curl_is_init = FALSE;
|
|
||||||
|
|
||||||
long main_auth_scheme = parse_auth_name(libtest_arg2);
|
long main_auth_scheme = parse_auth_name(libtest_arg2);
|
||||||
long fallback_auth_scheme = parse_auth_name(libtest_arg3);
|
long fallback_auth_scheme = parse_auth_name(libtest_arg3);
|
||||||
@ -93,29 +92,27 @@ int test(char *url)
|
|||||||
if (main_auth_scheme == CURLAUTH_NONE ||
|
if (main_auth_scheme == CURLAUTH_NONE ||
|
||||||
fallback_auth_scheme == CURLAUTH_NONE) {
|
fallback_auth_scheme == CURLAUTH_NONE) {
|
||||||
fprintf(stderr, "auth schemes not found on commandline\n");
|
fprintf(stderr, "auth schemes not found on commandline\n");
|
||||||
res = TEST_ERR_MAJOR_BAD;
|
return TEST_ERR_MAJOR_BAD;
|
||||||
goto test_cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||||
fprintf(stderr, "curl_global_init() failed\n");
|
fprintf(stderr, "curl_global_init() failed\n");
|
||||||
res = TEST_ERR_MAJOR_BAD;
|
return TEST_ERR_MAJOR_BAD;
|
||||||
goto test_cleanup;
|
|
||||||
}
|
}
|
||||||
curl_is_init = TRUE;
|
|
||||||
|
|
||||||
/* Send wrong password, then right password */
|
/* Send wrong password, then right password */
|
||||||
|
|
||||||
if ((curl = curl_easy_init()) == NULL) {
|
if ((curl = curl_easy_init()) == NULL) {
|
||||||
fprintf(stderr, "curl_easy_init() failed\n");
|
fprintf(stderr, "curl_easy_init() failed\n");
|
||||||
res = TEST_ERR_MAJOR_BAD;
|
curl_global_cleanup();
|
||||||
goto test_cleanup;
|
return TEST_ERR_MAJOR_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = send_wrong_password(curl, url, 100, main_auth_scheme);
|
res = send_wrong_password(curl, url, 100, main_auth_scheme);
|
||||||
if (res != CURLE_OK)
|
if (res != CURLE_OK)
|
||||||
goto test_cleanup;
|
goto test_cleanup;
|
||||||
curl_easy_reset(curl);
|
curl_easy_reset(curl);
|
||||||
|
|
||||||
res = send_right_password(curl, url, 200, fallback_auth_scheme);
|
res = send_right_password(curl, url, 200, fallback_auth_scheme);
|
||||||
if (res != CURLE_OK)
|
if (res != CURLE_OK)
|
||||||
goto test_cleanup;
|
goto test_cleanup;
|
||||||
@ -127,8 +124,8 @@ int test(char *url)
|
|||||||
|
|
||||||
if ((curl = curl_easy_init()) == NULL) {
|
if ((curl = curl_easy_init()) == NULL) {
|
||||||
fprintf(stderr, "curl_easy_init() failed\n");
|
fprintf(stderr, "curl_easy_init() failed\n");
|
||||||
res = TEST_ERR_MAJOR_BAD;
|
curl_global_cleanup();
|
||||||
goto test_cleanup;
|
return TEST_ERR_MAJOR_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = send_wrong_password(curl, url, 300, main_auth_scheme);
|
res = send_wrong_password(curl, url, 300, main_auth_scheme);
|
||||||
@ -140,6 +137,7 @@ int test(char *url)
|
|||||||
if (res != CURLE_OK)
|
if (res != CURLE_OK)
|
||||||
goto test_cleanup;
|
goto test_cleanup;
|
||||||
curl_easy_reset(curl);
|
curl_easy_reset(curl);
|
||||||
|
|
||||||
res = send_right_password(curl, url, 500, fallback_auth_scheme);
|
res = send_right_password(curl, url, 500, fallback_auth_scheme);
|
||||||
if (res != CURLE_OK)
|
if (res != CURLE_OK)
|
||||||
goto test_cleanup;
|
goto test_cleanup;
|
||||||
@ -147,10 +145,8 @@ int test(char *url)
|
|||||||
|
|
||||||
test_cleanup:
|
test_cleanup:
|
||||||
|
|
||||||
if (curl)
|
curl_easy_cleanup(curl);
|
||||||
curl_easy_cleanup(curl);
|
curl_global_cleanup();
|
||||||
if (curl_is_init)
|
|
||||||
curl_global_cleanup();
|
|
||||||
|
|
||||||
return (int)res;
|
return (int)res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user