1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

fix bool variables checking and assignment

This commit is contained in:
Yang Tse 2011-09-05 20:46:09 +02:00
parent eb44ac0138
commit a50210710a
23 changed files with 128 additions and 129 deletions

View File

@ -126,7 +126,7 @@ static bool tailmatch(const char *little, const char *bigone)
if(littlelen > biglen)
return FALSE;
return (bool)Curl_raw_equal(little, bigone+biglen-littlelen);
return Curl_raw_equal(little, bigone+biglen-littlelen) ? TRUE : FALSE;
}
/*
@ -241,7 +241,7 @@ Curl_cookie_add(struct SessionHandle *data,
endofn++;
/* name ends with a '=' ? */
sep = *endofn == '='?TRUE:FALSE;
sep = (*endofn == '=')?TRUE:FALSE;
/* Strip off trailing whitespace from the 'what' */
while(len && ISBLANK(what[len-1])) {
@ -527,7 +527,7 @@ Curl_cookie_add(struct SessionHandle *data,
As far as I can see, it is set to true when the cookie says
.domain.com and to false when the domain is complete www.domain.com
*/
co->tailmatch=(bool)Curl_raw_equal(ptr, "TRUE");
co->tailmatch = Curl_raw_equal(ptr, "TRUE")?TRUE:FALSE;
break;
case 2:
/* It turns out, that sometimes the file format allows the path
@ -547,7 +547,7 @@ Curl_cookie_add(struct SessionHandle *data,
fields++; /* add a field and fall down to secure */
/* FALLTHROUGH */
case 3:
co->secure = (bool)Curl_raw_equal(ptr, "TRUE");
co->secure = Curl_raw_equal(ptr, "TRUE")?TRUE:FALSE;
break;
case 4:
co->expires = curlx_strtoofft(ptr, NULL, 10);

View File

@ -413,7 +413,7 @@ int Curl_cyassl_init(void)
bool Curl_cyassl_data_pending(const struct connectdata* conn, int connindex)
{
if(conn->ssl[connindex].handle) /* SSL is in use */
return (bool)(0 != SSL_pending(conn->ssl[connindex].handle));
return (0 != SSL_pending(conn->ssl[connindex].handle)) ? TRUE : FALSE;
else
return FALSE;
}

View File

@ -1273,7 +1273,7 @@ static size_t readfromfile(struct Form *form, char *buffer,
size_t size)
{
size_t nread;
bool callback = (bool)(form->data->type == FORM_CALLBACK);
bool callback = (form->data->type == FORM_CALLBACK)?TRUE:FALSE;
if(callback) {
if(form->fread_func == ZERO_NULL)

View File

@ -298,8 +298,8 @@ static void freedirs(struct ftp_conn *ftpc)
*/
static bool isBadFtpString(const char *string)
{
return (bool)((NULL != strchr(string, '\r')) ||
(NULL != strchr(string, '\n')));
return ((NULL != strchr(string, '\r')) ||
(NULL != strchr(string, '\n'))) ? TRUE : FALSE;
}
/***********************************************************************
@ -2530,7 +2530,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if(ftpcode/100 == 2)
/* We have enabled SSL for the data connection! */
conn->ssl[SECONDARYSOCKET].use =
(bool)(data->set.ftp_ssl != CURLUSESSL_CONTROL);
(data->set.ftp_ssl != CURLUSESSL_CONTROL) ? TRUE : FALSE;
/* FTP servers typically responds with 500 if they decide to reject
our 'P' request */
else if(data->set.ftp_ssl > CURLUSESSL_CONTROL)
@ -2841,7 +2841,7 @@ static CURLcode ftp_multi_statemach(struct connectdata *conn,
/* Check for the state outside of the Curl_socket_ready() return code checks
since at times we are in fact already in this state when this function
gets called. */
*done = (bool)(ftpc->state == FTP_STOP);
*done = (ftpc->state == FTP_STOP) ? TRUE : FALSE;
return result;
}
@ -2895,9 +2895,9 @@ static CURLcode ftp_init(struct connectdata *conn)
*/
ftp->user = conn->user;
ftp->passwd = conn->passwd;
if(TRUE == isBadFtpString(ftp->user))
if(isBadFtpString(ftp->user))
return CURLE_URL_MALFORMAT;
if(TRUE == isBadFtpString(ftp->passwd))
if(isBadFtpString(ftp->passwd))
return CURLE_URL_MALFORMAT;
conn->proto.ftpc.known_filesize = -1; /* unknown size for now */

View File

@ -588,7 +588,7 @@ output_auth_headers(struct connectdata *conn,
proxy?"Proxy":"Server", auth,
proxy?(conn->proxyuser?conn->proxyuser:""):
(conn->user?conn->user:""));
authstatus->multi = (bool)(!authstatus->done);
authstatus->multi = (!authstatus->done) ? TRUE : FALSE;
}
else
authstatus->multi = FALSE;
@ -745,7 +745,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
data->state.authproblem = TRUE;
}
else {
neg = Curl_input_negotiate(conn, (bool)(httpcode == 407), start);
neg = Curl_input_negotiate(conn, (httpcode == 407)?TRUE:FALSE, start);
if(neg == 0) {
DEBUGASSERT(!data->req.newurl);
data->req.newurl = strdup(data->change.url);
@ -771,7 +771,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
authp->picked == CURLAUTH_NTLM_WB) {
/* NTLM authentication is picked and activated */
CURLcode ntlm =
Curl_input_ntlm(conn, (bool)(httpcode == 407), start);
Curl_input_ntlm(conn, (httpcode == 407)?TRUE:FALSE, start);
if(CURLE_OK == ntlm) {
data->state.authproblem = FALSE;
#ifdef NTLM_WB_ENABLED
@ -817,7 +817,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
/* We call this function on input Digest headers even if Digest
* authentication isn't activated yet, as we need to store the
* incoming data from this header in case we are gonna use Digest. */
dig = Curl_input_digest(conn, (bool)(httpcode == 407), start);
dig = Curl_input_digest(conn, (httpcode == 407)?TRUE:FALSE, start);
if(CURLDIGEST_FINE != dig) {
infof(data, "Authentication problem. Ignoring this.\n");
@ -946,7 +946,7 @@ static size_t readmoredata(char *buffer,
return 0;
/* make sure that a HTTP request is never sent away chunked! */
conn->data->req.forbidchunk = (bool)(http->sending == HTTPSEND_REQUEST);
conn->data->req.forbidchunk = (http->sending == HTTPSEND_REQUEST)?TRUE:FALSE;
if(http->postsize <= (curl_off_t)fullsize) {
memcpy(buffer, http->postdata, (size_t)http->postsize);
@ -1479,11 +1479,11 @@ CURLcode Curl_http_done(struct connectdata *conn,
static bool use_http_1_1(const struct SessionHandle *data,
const struct connectdata *conn)
{
return (bool)((data->set.httpversion == CURL_HTTP_VERSION_1_1) ||
return ((data->set.httpversion == CURL_HTTP_VERSION_1_1) ||
((data->set.httpversion != CURL_HTTP_VERSION_1_0) &&
((conn->httpversion == 11) ||
((conn->httpversion != 10) &&
(data->state.httpversion != 10)))));
(data->state.httpversion != 10))))) ? TRUE : FALSE;
}
/* check and possibly add an Expect: header */
@ -2154,8 +2154,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
conn->allocptr.cookiehost?
conn->allocptr.cookiehost:host,
data->state.path,
(bool)(conn->handler->protocol&CURLPROTO_HTTPS?
TRUE:FALSE));
(conn->handler->protocol&CURLPROTO_HTTPS)?
TRUE:FALSE);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
if(co) {
@ -2582,7 +2582,7 @@ checkhttpprefix(struct SessionHandle *data,
head = head->next;
}
if((rc != TRUE) && (checkprefix("HTTP/", s)))
if(!rc && (checkprefix("HTTP/", s)))
rc = TRUE;
#ifdef CURL_DOES_CONVERSIONS

View File

@ -79,9 +79,9 @@
We avoid the use of isxdigit to accommodate non-ASCII hosts. */
static bool Curl_isxdigit(char digit)
{
return (bool)( (digit >= 0x30 && digit <= 0x39) /* 0-9 */
|| (digit >= 0x41 && digit <= 0x46) /* A-F */
|| (digit >= 0x61 && digit <= 0x66) ); /* a-f */
return ( (digit >= 0x30 && digit <= 0x39) /* 0-9 */
|| (digit >= 0x41 && digit <= 0x46) /* A-F */
|| (digit >= 0x61 && digit <= 0x66) /* a-f */ ) ? TRUE : FALSE;
}
void Curl_httpchunk_init(struct connectdata *conn)

View File

@ -630,7 +630,7 @@ static CURLcode imap_multi_statemach(struct connectdata *conn,
else
result = Curl_pp_multi_statemach(&imapc->pp);
*done = (bool)(imapc->state == IMAP_STOP);
*done = (imapc->state == IMAP_STOP) ? TRUE : FALSE;
return result;
}

View File

@ -628,9 +628,10 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
easy = data->multi_pos;
if(easy) {
bool premature = (bool)(easy->state < CURLM_STATE_COMPLETED);
bool easy_owns_conn = (bool)(easy->easy_conn &&
(easy->easy_conn->data == easy->easy_handle));
bool premature = (easy->state < CURLM_STATE_COMPLETED) ? TRUE : FALSE;
bool easy_owns_conn = (easy->easy_conn &&
(easy->easy_conn->data == easy->easy_handle)) ?
TRUE : FALSE;
/* If the 'state' is not INIT or COMPLETED, we might need to do something
nice to put the easy_handle in a good known state when this returns. */
@ -1282,7 +1283,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
disconnect_conn = TRUE;
}
else
retry = (bool)(newurl?TRUE:FALSE);
retry = (newurl)?TRUE:FALSE;
Curl_posttransfer(data);
drc = Curl_done(&easy->easy_conn, easy->result, FALSE);
@ -1481,14 +1482,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
Curl_posttransfer(data);
Curl_done(&easy->easy_conn, easy->result, FALSE);
}
else if(TRUE == done) {
else if(done) {
char *newurl = NULL;
bool retry = FALSE;
followtype follow=FOLLOW_NONE;
easy->result = Curl_retry_request(easy->easy_conn, &newurl);
if(!easy->result)
retry = (bool)(newurl?TRUE:FALSE);
retry = (newurl)?TRUE:FALSE;
/* call this even if the readwrite function returned error */
Curl_posttransfer(data);
@ -2213,7 +2214,7 @@ CURLMcode curl_multi_setopt(CURLM *multi_handle,
multi->socket_userp = va_arg(param, void *);
break;
case CURLMOPT_PIPELINING:
multi->pipelining_enabled = (bool)(0 != va_arg(param, long));
multi->pipelining_enabled = (0 != va_arg(param, long)) ? TRUE : FALSE;
break;
case CURLMOPT_TIMERFUNCTION:
multi->timer_cb = va_arg(param, curl_multi_timer_callback);
@ -2478,7 +2479,7 @@ static bool isHandleAtHead(struct SessionHandle *handle,
{
struct curl_llist_element *curr = pipeline->head;
if(curr)
return (bool)(curr->ptr == handle);
return (curr->ptr == handle) ? TRUE : FALSE;
return FALSE;
}

View File

@ -62,7 +62,7 @@ int curlx_nonblock(curl_socket_t sockfd, /* operate on this */
/* most recent unix versions */
int flags;
flags = fcntl(sockfd, F_GETFL, 0);
if(FALSE != nonblock)
if(nonblock)
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
else
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
@ -70,26 +70,25 @@ int curlx_nonblock(curl_socket_t sockfd, /* operate on this */
#elif defined(HAVE_IOCTL_FIONBIO)
/* older unix versions */
int flags;
flags = nonblock;
int flags = nonblock ? 1 : 0;
return ioctl(sockfd, FIONBIO, &flags);
#elif defined(HAVE_IOCTLSOCKET_FIONBIO)
/* Windows */
unsigned long flags;
flags = nonblock;
unsigned long flags = nonblock ? 1UL : 0UL;
return ioctlsocket(sockfd, FIONBIO, &flags);
#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)
/* Amiga */
return IoctlSocket(sockfd, FIONBIO, (long)nonblock);
long flags = nonblock ? 1L : 0L;
return IoctlSocket(sockfd, FIONBIO, flags);
#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK)
/* BeOS */
long b = nonblock ? 1 : 0;
long b = nonblock ? 1L : 0L;
return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
#else

View File

@ -570,7 +570,7 @@ static CURLcode pop3_multi_statemach(struct connectdata *conn, bool *done)
struct pop3_conn *pop3c = &conn->proto.pop3c;
CURLcode result = Curl_pp_multi_statemach(&pop3c->pp);
*done = (bool)(pop3c->state == POP3_STOP);
*done = (pop3c->state == POP3_STOP) ? TRUE : FALSE;
return result;
}

View File

@ -73,7 +73,7 @@ static size_t convert_lineends(struct SessionHandle *data,
return(size);
}
if(data->state.prev_block_had_trailing_cr == TRUE) {
if(data->state.prev_block_had_trailing_cr) {
/* The previous block of incoming data
had a trailing CR, which was turned into a LF. */
if(*startPtr == '\n') {
@ -536,8 +536,8 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
ssize_t nread = 0;
size_t bytesfromsocket = 0;
char *buffertofill = NULL;
bool pipelining = (bool)(conn->data->multi &&
Curl_multi_canPipeline(conn->data->multi));
bool pipelining = (conn->data->multi &&
Curl_multi_canPipeline(conn->data->multi)) ? TRUE : FALSE;
/* Set 'num' to 0 or 1, depending on which socket that has been sent here.
If it is the second socket, we set num to 1. Otherwise to 0. This lets

View File

@ -1032,7 +1032,7 @@ static CURLcode smtp_multi_statemach(struct connectdata *conn,
else
result = Curl_pp_multi_statemach(&smtpc->pp);
*done = (bool)(smtpc->state == SMTP_STOP);
*done = (smtpc->state == SMTP_STOP) ? TRUE : FALSE;
return result;
}

View File

@ -368,7 +368,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
curl_socket_t sock = conn->sock[sockindex];
struct SessionHandle *data = conn->data;
long timeout;
bool socks5_resolve_local = (bool)(conn->proxytype == CURLPROXY_SOCKS5);
bool socks5_resolve_local = (conn->proxytype == CURLPROXY_SOCKS5)?TRUE:FALSE;
const size_t hostname_len = strlen(hostname);
ssize_t packetsize = 0;

View File

@ -2500,7 +2500,7 @@ static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done)
implementation */
result = ssh_statemach_act(conn, &block);
*done = (bool)(sshc->state == SSH_STOP);
*done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
ssh_block2waitfor(conn, block);
return result;

View File

@ -69,10 +69,10 @@ static bool safe_strequal(char* str1, char* str2)
{
if(str1 && str2)
/* both pointers point to something then compare them */
return (bool)(0 != Curl_raw_equal(str1, str2));
return (0 != Curl_raw_equal(str1, str2)) ? TRUE : FALSE;
else
/* if both pointers are NULL then treat them as equal */
return (bool)(!str1 && !str2);
return (!str1 && !str2) ? TRUE : FALSE;
}
bool
@ -210,7 +210,7 @@ Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
/* mark this is being ssl requested from here on. */
conn->ssl[sockindex].use = TRUE;
res = curlssl_connect_nonblocking(conn, sockindex, done);
if(!res && *done == TRUE)
if(!res && *done)
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
return res;
#else

View File

@ -166,14 +166,14 @@ static int passwd_callback(char *buf, int num, int verify
#define seed_enough(x) rand_enough()
static bool rand_enough(void)
{
return (bool)(0 != RAND_status());
return (0 != RAND_status()) ? TRUE : FALSE;
}
#else
#define seed_enough(x) rand_enough(x)
static bool rand_enough(int nread)
{
/* this is a very silly decision to make */
return (bool)(nread > 500);
return (nread > 500) ? TRUE : FALSE;
}
#endif
@ -2564,7 +2564,7 @@ bool Curl_ossl_data_pending(const struct connectdata *conn,
{
if(conn->ssl[connindex].handle)
/* SSL is in use */
return (bool)(0 != SSL_pending(conn->ssl[connindex].handle));
return (0 != SSL_pending(conn->ssl[connindex].handle)) ? TRUE : FALSE;
else
return FALSE;
}

View File

@ -1386,7 +1386,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
}
/* We called WSACreateEvent, so call WSACloseEvent */
if(close_event_func(event_handle) == FALSE) {
if(!close_event_func(event_handle)) {
infof(data,"WSACloseEvent failed (%d)", SOCKERRNO);
}

View File

@ -206,7 +206,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
{
time_t maxtime, timeout;
long timeout_ms;
bool start = (bool)(state->state == TFTP_STATE_START);
bool start = (state->state == TFTP_STATE_START) ? TRUE : FALSE;
time(&state->start_time);
@ -1334,7 +1334,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
result = tftp_state_machine(state, event);
if(result != CURLE_OK)
return(result);
*done = (bool)(state->state == TFTP_STATE_FIN);
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
if(*done)
/* Tell curl we're done */
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
@ -1356,7 +1356,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
result = tftp_state_machine(state, state->event);
if(result != CURLE_OK)
return(result);
*done = (bool)(state->state == TFTP_STATE_FIN);
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
if(*done)
/* Tell curl we're done */
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);

View File

@ -430,7 +430,7 @@ static CURLcode readwrite_data(struct SessionHandle *data,
*didwhat |= KEEP_RECV;
/* indicates data of zero size, i.e. empty file */
is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0));
is_empty_data = ((nread == 0) && (k->bodywrites == 0)) ? TRUE : FALSE;
/* NUL terminate, allowing string ops to be used */
if(0 < nread || is_empty_data) {
@ -1143,8 +1143,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
/* Now update the "done" boolean we return */
*done = (bool)(0 == (k->keepon&(KEEP_RECV|KEEP_SEND|
KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)));
*done = (0 == (k->keepon&(KEEP_RECV|KEEP_SEND|
KEEP_RECV_PAUSE|KEEP_SEND_PAUSE))) ? TRUE : FALSE;
return CURLE_OK;
}
@ -1607,7 +1607,7 @@ static bool is_absolute_url(const char *url)
char prot[16]; /* URL protocol string storage */
char letter; /* used for a silly sscanf */
return (bool)(2 == sscanf(url, "%15[^?&/:]://%c", prot, &letter));
return (2 == sscanf(url, "%15[^?&/:]://%c", prot, &letter)) ? TRUE : FALSE;
}
/*

107
lib/url.c
View File

@ -821,7 +821,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
{
/* remember we want this enabled */
long use_cache = va_arg(param, long);
data->set.global_dns_cache = (bool)(0 != use_cache);
data->set.global_dns_cache = (0 != use_cache)?TRUE:FALSE;
}
break;
case CURLOPT_SSL_CIPHER_LIST:
@ -857,33 +857,33 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* When this transfer is done, it must not be left to be reused by a
* subsequent transfer but shall be closed immediately.
*/
data->set.reuse_forbid = (bool)(0 != va_arg(param, long));
data->set.reuse_forbid = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FRESH_CONNECT:
/*
* This transfer shall not use a previously cached connection but
* should be made with a fresh new connect!
*/
data->set.reuse_fresh = (bool)(0 != va_arg(param, long));
data->set.reuse_fresh = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_VERBOSE:
/*
* Verbose means infof() calls that give a lot of information about
* the connection and transfer procedures as well as internal choices.
*/
data->set.verbose = (bool)(0 != va_arg(param, long));
data->set.verbose = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_HEADER:
/*
* Set to include the header in the general data output stream.
*/
data->set.include_header = (bool)(0 != va_arg(param, long));
data->set.include_header = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_NOPROGRESS:
/*
* Shut off the internal supported progress meter
*/
data->set.hide_progress = (bool)(0 != va_arg(param, long));
data->set.hide_progress = (0 != va_arg(param, long))?TRUE:FALSE;
if(data->set.hide_progress)
data->progress.flags |= PGRS_HIDE;
else
@ -893,14 +893,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/*
* Do not include the body part in the output data stream.
*/
data->set.opt_no_body = (bool)(0 != va_arg(param, long));
data->set.opt_no_body = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FAILONERROR:
/*
* Don't output the >=300 error code HTML-page, but instead only
* return error.
*/
data->set.http_fail_on_error = (bool)(0 != va_arg(param, long));
data->set.http_fail_on_error = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_UPLOAD:
case CURLOPT_PUT:
@ -908,7 +908,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* We want to sent data to the remote host. If this is HTTP, that equals
* using the PUT request.
*/
data->set.upload = (bool)(0 != va_arg(param, long));
data->set.upload = (0 != va_arg(param, long))?TRUE:FALSE;
if(data->set.upload) {
/* If this is HTTP, PUT is what's needed to "upload" */
data->set.httpreq = HTTPREQ_PUT;
@ -924,7 +924,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* Try to get the file time of the remote document. The time will
* later (possibly) become available using curl_easy_getinfo().
*/
data->set.get_filetime = (bool)(0 != va_arg(param, long));
data->set.get_filetime = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_CREATE_MISSING_DIRS:
/*
@ -965,13 +965,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* An option that changes the command to one that asks for a list
* only, no file info details.
*/
data->set.ftp_list_only = (bool)(0 != va_arg(param, long));
data->set.ftp_list_only = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_APPEND:
/*
* We want to upload and append to an existing file.
*/
data->set.ftp_append = (bool)(0 != va_arg(param, long));
data->set.ftp_append = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_FILEMETHOD:
/*
@ -999,7 +999,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
*
* Transfer using ASCII (instead of BINARY).
*/
data->set.prefer_ascii = (bool)(0 != va_arg(param, long));
data->set.prefer_ascii = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_TIMECONDITION:
/*
@ -1028,7 +1028,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/*
* Switch on automatic referer that gets set if curl follows locations.
*/
data->set.http_auto_referer = (bool)(0 != va_arg(param, long));
data->set.http_auto_referer = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_ACCEPT_ENCODING:
@ -1048,14 +1048,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
break;
case CURLOPT_TRANSFER_ENCODING:
data->set.http_transfer_encoding = (bool)(0 != va_arg(param, long));
data->set.http_transfer_encoding = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FOLLOWLOCATION:
/*
* Follow Location: header hints on a HTTP-server.
*/
data->set.http_follow_location = (bool)(0 != va_arg(param, long));
data->set.http_follow_location = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_UNRESTRICTED_AUTH:
@ -1064,7 +1064,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* hostname changed.
*/
data->set.http_disable_hostname_check_before_authentication =
(bool)(0 != va_arg(param, long));
(0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_MAXREDIRS:
@ -1086,8 +1086,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* other - POST is kept as POST after 301 and 302
*/
long postRedir = va_arg(param, long);
data->set.post301 = (bool)((postRedir & CURL_REDIR_POST_301)?TRUE:FALSE);
data->set.post302 = (bool)((postRedir & CURL_REDIR_POST_302)?TRUE:FALSE);
data->set.post301 = (postRedir & CURL_REDIR_POST_301)?TRUE:FALSE;
data->set.post302 = (postRedir & CURL_REDIR_POST_302)?TRUE:FALSE;
}
break;
@ -1296,7 +1296,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* We run mostly with the original cookie spec, as hardly anyone implements
* anything else.
*/
data->set.cookiesession = (bool)(0 != va_arg(param, long));
data->set.cookiesession = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_COOKIELIST:
@ -1371,8 +1371,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/* the DIGEST_IE bit is only used to set a special marker, for all the
rest we need to handle it as normal DIGEST */
data->state.authhost.iestyle = (bool)((auth & CURLAUTH_DIGEST_IE)?
TRUE:FALSE);
data->state.authhost.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE;
if(auth & CURLAUTH_DIGEST_IE) {
auth |= CURLAUTH_DIGEST; /* set standard digest bit */
@ -1417,7 +1416,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/*
* Tunnel operations through the proxy instead of normal proxy use
*/
data->set.tunnel_thru_httpproxy = (bool)(0 != va_arg(param, long));
data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_PROXYPORT:
@ -1436,8 +1435,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/* the DIGEST_IE bit is only used to set a special marker, for all the
rest we need to handle it as normal DIGEST */
data->state.authproxy.iestyle = (bool)((auth & CURLAUTH_DIGEST_IE)?
TRUE:FALSE);
data->state.authproxy.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE;
if(auth & CURLAUTH_DIGEST_IE) {
auth |= CURLAUTH_DIGEST; /* set standard digest bit */
@ -1514,7 +1512,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/*
* set flag for nec socks5 support
*/
data->set.socks5_gssapi_nec = (bool)(0 != va_arg(param, long));
data->set.socks5_gssapi_nec = (0 != va_arg(param, long))?TRUE:FALSE;
break;
#endif
@ -1543,19 +1541,20 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
*/
result = setstropt(&data->set.str[STRING_FTPPORT],
va_arg(param, char *));
data->set.ftp_use_port = (bool)(NULL != data->set.str[STRING_FTPPORT]);
data->set.ftp_use_port = (NULL != data->set.str[STRING_FTPPORT]) ?
TRUE:FALSE;
break;
case CURLOPT_FTP_USE_EPRT:
data->set.ftp_use_eprt = (bool)(0 != va_arg(param, long));
data->set.ftp_use_eprt = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_USE_EPSV:
data->set.ftp_use_epsv = (bool)(0 != va_arg(param, long));
data->set.ftp_use_epsv = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_USE_PRET:
data->set.ftp_use_pret = (bool)(0 != va_arg(param, long));
data->set.ftp_use_pret = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_SSL_CCC:
@ -1567,7 +1566,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the
* bypass of the IP address in PASV responses.
*/
data->set.ftp_skip_ip = (bool)(0 != va_arg(param, long));
data->set.ftp_skip_ip = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_INFILE:
@ -1937,7 +1936,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/*
* Kludgy option to enable CRLF conversions. Subject for removal.
*/
data->set.crlf = (bool)(0 != va_arg(param, long));
data->set.crlf = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_INTERFACE:
@ -1966,7 +1965,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
*/
result = setstropt(&data->set.str[STRING_KRB_LEVEL],
va_arg(param, char *));
data->set.krb = (bool)(NULL != data->set.str[STRING_KRB_LEVEL]);
data->set.krb = (NULL != data->set.str[STRING_KRB_LEVEL])?TRUE:FALSE;
break;
case CURLOPT_GSSAPI_DELEGATION:
/*
@ -2004,7 +2003,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
data->set.ssl.fsslctxp = va_arg(param, void *);
break;
case CURLOPT_CERTINFO:
data->set.ssl.certinfo = (bool)(0 != va_arg(param, long));
data->set.ssl.certinfo = (0 != va_arg(param, long))?TRUE:FALSE;
break;
#endif
case CURLOPT_CAINFO:
@ -2064,7 +2063,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* The application asks not to set any signal() or alarm() handlers,
* even when using a timeout.
*/
data->set.no_signal = (bool)(0 != va_arg(param, long));
data->set.no_signal = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_SHARE:
@ -2168,7 +2167,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* Enable or disable TCP_NODELAY, which will disable/enable the Nagle
* algorithm
*/
data->set.tcp_nodelay = (bool)(0 != va_arg(param, long));
data->set.tcp_nodelay = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_ACCOUNT:
@ -2177,14 +2176,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
break;
case CURLOPT_IGNORE_CONTENT_LENGTH:
data->set.ignorecl = (bool)(0 != va_arg(param, long));
data->set.ignorecl = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_CONNECT_ONLY:
/*
* No data transfer, set up connection and let application use the socket
*/
data->set.connect_only = (bool)(0 != va_arg(param, long));
data->set.connect_only = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_FTP_ALTERNATIVE_TO_USER:
@ -2237,7 +2236,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
break;
case CURLOPT_SSL_SESSIONID_CACHE:
data->set.ssl.sessionid = (bool)(0 != va_arg(param, long));
data->set.ssl.sessionid = (0 != va_arg(param, long))?TRUE:FALSE;
break;
#ifdef USE_LIBSSH2
@ -2298,14 +2297,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
/*
* disable libcurl transfer encoding is used
*/
data->set.http_te_skip = (bool)(0 == va_arg(param, long));
data->set.http_te_skip = (0 == va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_HTTP_CONTENT_DECODING:
/*
* raw data passed to the application when content encoding is used
*/
data->set.http_ce_skip = (bool)(0 == va_arg(param, long));
data->set.http_ce_skip = (0 == va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_NEW_FILE_PERMS:
@ -2467,7 +2466,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
break;
case CURLOPT_WILDCARDMATCH:
data->set.wildcardmatch = (bool)(0 != va_arg(param, long));
data->set.wildcardmatch = (0 != va_arg(param, long))?TRUE:FALSE;
break;
case CURLOPT_CHUNK_BGN_FUNCTION:
data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback);
@ -2766,11 +2765,11 @@ static struct SessionHandle* gethandleathead(struct curl_llist *pipeline)
void Curl_getoff_all_pipelines(struct SessionHandle *data,
struct connectdata *conn)
{
bool recv_head = (bool)(conn->readchannel_inuse &&
(gethandleathead(conn->recv_pipe) == data));
bool recv_head = (conn->readchannel_inuse &&
(gethandleathead(conn->recv_pipe) == data)) ? TRUE : FALSE;
bool send_head = (bool)(conn->writechannel_inuse &&
(gethandleathead(conn->send_pipe) == data));
bool send_head = (conn->writechannel_inuse &&
(gethandleathead(conn->send_pipe) == data)) ? TRUE : FALSE;
if(Curl_removeHandleFromPipeline(data, conn->recv_pipe) && recv_head)
conn->readchannel_inuse = FALSE;
@ -3505,18 +3504,18 @@ static struct connectdata *allocate_conn(struct SessionHandle *data)
/* note that these two proxy bits are now just on what looks to be
requested, they may be altered down the road */
conn->bits.proxy = (bool)(data->set.str[STRING_PROXY] &&
*data->set.str[STRING_PROXY]);
conn->bits.httpproxy = (bool)(conn->bits.proxy &&
(conn->proxytype == CURLPROXY_HTTP ||
conn->proxytype == CURLPROXY_HTTP_1_0));
conn->bits.proxy = (data->set.str[STRING_PROXY] &&
*data->set.str[STRING_PROXY])?TRUE:FALSE;
conn->bits.httpproxy = (conn->bits.proxy &&
(conn->proxytype == CURLPROXY_HTTP ||
conn->proxytype == CURLPROXY_HTTP_1_0))?TRUE:FALSE;
conn->bits.proxy_user_passwd =
(bool)(NULL != data->set.str[STRING_PROXYUSERNAME]);
(NULL != data->set.str[STRING_PROXYUSERNAME])?TRUE:FALSE;
conn->bits.tunnel_proxy = data->set.tunnel_thru_httpproxy;
#endif /* CURL_DISABLE_PROXY */
conn->bits.user_passwd = (bool)(NULL != data->set.str[STRING_USERNAME]);
conn->bits.user_passwd = (NULL != data->set.str[STRING_USERNAME])?TRUE:FALSE;
conn->bits.ftp_use_epsv = data->set.ftp_use_epsv;
conn->bits.ftp_use_eprt = data->set.ftp_use_eprt;
@ -3860,7 +3859,7 @@ static CURLcode setup_range(struct SessionHandle *data)
else
s->range = strdup(data->set.str[STRING_SET_RANGE]);
s->rangestringalloc = (bool)(s->range?TRUE:FALSE);
s->rangestringalloc = (s->range)?TRUE:FALSE;
if(!s->range)
return CURLE_OUT_OF_MEMORY;

View File

@ -2139,7 +2139,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->disable_epsv = toggle;
break;
case 'E': /* --epsv */
config->disable_epsv = (bool)(!toggle);
config->disable_epsv = (!toggle)?TRUE:FALSE;
break;
#ifdef USE_ENVIRONMENT
case 'f':
@ -2325,7 +2325,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->disable_eprt = toggle;
break;
case 'Z': /* --eprt */
config->disable_eprt = (bool)(!toggle);
config->disable_eprt = (!toggle)?TRUE:FALSE;
break;
default: /* the URL! */
@ -2456,7 +2456,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->ftp_ssl_reqd = toggle;
break;
case 'w': /* --no-sessionid */
config->disable_sessionid = (bool)(!toggle);
config->disable_sessionid = (!toggle)?TRUE:FALSE;
break;
case 'x': /* --ftp-ssl-control */
if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
@ -2482,7 +2482,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->post301 = toggle;
break;
case '1': /* --no-keepalive */
config->nokeepalive = (bool)(!toggle);
config->nokeepalive = (!toggle)?TRUE:FALSE;
break;
case '3': /* --keepalive-time */
if(str2num(&config->alivetime, nextarg))
@ -2894,7 +2894,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
nextarg,
&config->httppost,
&config->last_post,
(bool) (subletter=='s'))) /* 's' means literal string */
(subletter=='s')?TRUE:FALSE)) /* 's' means literal string */
return PARAM_BAD_USE;
if(SetHTTPrequest(config, HTTPREQ_POST, &config->httpreq))
return PARAM_BAD_USE;
@ -3004,7 +3004,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
/* disable the output I/O buffering. note that the option is called
--buffer but is mostly used in the negative form: --no-buffer */
if(longopt)
config->nobuffer = (bool)(!toggle);
config->nobuffer = (!toggle)?TRUE:FALSE;
else
config->nobuffer = toggle;
break;
@ -3130,7 +3130,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->mute = config->noprogress = TRUE;
else
config->mute = config->noprogress = FALSE;
config->showerror = (bool)(!toggle); /* toggle off */
config->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
break;
case 'S':
/* show errors */
@ -3995,7 +3995,7 @@ int my_trace(CURL *handle, curl_infotype type,
if(!newl)
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
(void)fwrite(data+st, i-st+1, 1, output);
newl = (bool)(size && (data[size-1] != '\n'));
newl = (size && (data[size-1] != '\n'))?TRUE:FALSE;
traced_data = FALSE;
break;
case CURLINFO_TEXT:
@ -4003,7 +4003,7 @@ int my_trace(CURL *handle, curl_infotype type,
if(!newl)
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
(void)fwrite(data, size, 1, output);
newl = (bool)(size && (data[size-1] != '\n'));
newl = (size && (data[size-1] != '\n'))?TRUE:FALSE;
traced_data = FALSE;
break;
case CURLINFO_DATA_OUT:
@ -4395,8 +4395,8 @@ static void dumpeasycode(struct Configurable *config)
static bool stdin_upload(const char *uploadfile)
{
return (bool)(curlx_strequal(uploadfile, "-") ||
curlx_strequal(uploadfile, "."));
return (curlx_strequal(uploadfile, "-") ||
curlx_strequal(uploadfile, ".")) ? TRUE : FALSE;
}
/* Adds the file name to the URL if it doesn't already have one.

View File

@ -254,7 +254,7 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
break;
}
}
if(FALSE == match) {
if(!match) {
fprintf(stderr, "curl: unknown --write-out variable: '%s'\n", ptr);
}
ptr=end+1; /* pass the end */

View File

@ -166,7 +166,7 @@ int main(int argc, char *argv[])
logmsg("fake_ntlm (user: %s) (proto: %s) (domain: %s) (cached creds: %s)",
helper_user, helper_proto, helper_domain,
(use_cached_creds == TRUE) ? "yes" : "no");
(use_cached_creds) ? "yes" : "no");
env = getenv("CURL_NTLM_AUTH_TESTNUM");
if (env) {