/* It turns out, that sometimes the file format allows the path
field to remain not filled in, we try to detect this and work
around it! Andrés García made us aware of this... */
- if (strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
+ if(strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
/* only if the path doesn't look like a boolean option! */
co->path = strdup(ptr);
if(!co->path)
while(co) {
format_ptr = get_netscape_format(co);
- if (format_ptr == NULL) {
+ if(format_ptr == NULL) {
fprintf(out, "#\n# Fatal libcurl error\n");
fclose(out);
return 1;
struct Cookie *c;
char *line;
- if ((data->cookies == NULL) ||
+ if((data->cookies == NULL) ||
(data->cookies->numcookies == 0))
return NULL;
c = data->cookies->cookies;
beg = list;
- while (c) {
+ while(c) {
/* fill the list with _all_ the cookies we know */
line = get_netscape_format(c);
- if (line == NULL) {
+ if(line == NULL) {
curl_slist_free_all(beg);
return NULL;
}
list = curl_slist_append(list, line);
free(line);
- if (list == NULL) {
+ if(list == NULL) {
curl_slist_free_all(beg);
return NULL;
}
- else if (beg == NULL) {
+ else if(beg == NULL) {
beg = list;
}
c = c->next;
for(ptr = newp;
(byte = *ptr) != 0;
ptr++) {
- if ((byte <= 32) || (byte == 127) ||
+ if((byte <= 32) || (byte == 127) ||
(byte == '\'') || (byte == '\"') || (byte == '\\')) {
dictp[olen++] = '\\';
}
/* AUTH is missing */
}
- if (strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
+ if(strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
word = strchr(path, ':');
- if (word) {
+ if(word) {
word++;
database = strchr(word, ':');
- if (database) {
+ if(database) {
*database++ = (char)0;
strategy = strchr(database, ':');
- if (strategy) {
+ if(strategy) {
*strategy++ = (char)0;
nthdef = strchr(strategy, ':');
- if (nthdef) {
+ if(nthdef) {
*nthdef++ = (char)0;
}
}
}
}
- if ((word == NULL) || (*word == (char)0)) {
+ if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing");
word=(char *)"default";
}
- if ((database == NULL) || (*database == (char)0)) {
+ if((database == NULL) || (*database == (char)0)) {
database = (char *)"!";
}
- if ((strategy == NULL) || (*strategy == (char)0)) {
+ if((strategy == NULL) || (*strategy == (char)0)) {
strategy = (char *)".";
}
if(result)
return result;
}
- else if (strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
+ else if(strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
word = strchr(path, ':');
- if (word) {
+ if(word) {
word++;
database = strchr(word, ':');
- if (database) {
+ if(database) {
*database++ = (char)0;
nthdef = strchr(database, ':');
- if (nthdef) {
+ if(nthdef) {
*nthdef++ = (char)0;
}
}
}
- if ((word == NULL) || (*word == (char)0)) {
+ if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing");
word=(char *)"default";
}
- if ((database == NULL) || (*database == (char)0)) {
+ if((database == NULL) || (*database == (char)0)) {
database = (char *)"!";
}
else {
ppath = strchr(path, '/');
- if (ppath) {
+ if(ppath) {
int i;
ppath++;
for (i = 0; ppath[i]; i++) {
- if (ppath[i] == ':')
+ if(ppath[i] == ':')
ppath[i] = ' ';
}
result = Curl_sendf(sockfd, conn,
#ifdef CURL_DOES_CONVERSIONS
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
- if (!handle ||
+ if(!handle ||
(Curl_convert_to_network(handle, &in, 1) != CURLE_OK)) {
/* Curl_convert_to_network calls failf if unsuccessful */
free(ns);
#ifdef CURL_DOES_CONVERSIONS
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
- if (!handle ||
+ if(!handle ||
(Curl_convert_from_network(handle, &in, 1) != CURLE_OK)) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(ns);
sessionhandle, deal with it */
Curl_reset_reqproto(conn);
- if (!data->reqdata.proto.file) {
+ if(!data->reqdata.proto.file) {
file = (struct FILEPROTO *)calloc(sizeof(struct FILEPROTO), 1);
if(!file) {
free(real_path);
with a drive letter.
*/
actual_path = real_path;
- if ((actual_path[0] == '/') &&
+ if((actual_path[0] == '/') &&
actual_path[1] &&
(actual_path[2] == ':' || actual_path[2] == '|'))
{
/* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
for (i=0; actual_path[i] != '\0'; ++i)
- if (actual_path[i] == '/')
+ if(actual_path[i] == '/')
actual_path[i] = '\\';
fd = open(actual_path, O_RDONLY | O_BINARY); /* no CR/LF translation! */
fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC,
conn->data->set.new_file_perms);
#endif /* !(WIN32 || MSDOS || __EMX__) */
- if (fd < 0) {
+ if(fd < 0) {
failf(data, "Can't open %s for writing", file->path);
return CURLE_WRITE_ERROR;
}
data->reqdata.resume_from = (curl_off_t)file_stat.st_size;
}
- while (res == CURLE_OK) {
+ while(res == CURLE_OK) {
int readcount;
res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
if(res)
break;
- if (readcount <= 0) /* fix questionable compare error. curlvms */
+ if(readcount <= 0) /* fix questionable compare error. curlvms */
break;
nread = (size_t)readcount;
return result;
}
- if (data->reqdata.resume_from <= expected_size)
+ if(data->reqdata.resume_from <= expected_size)
expected_size -= data->reqdata.resume_from;
else {
failf(data, "failed to resume file:// transfer");
return CURLE_BAD_DOWNLOAD_RESUME;
}
- if (fstated && (expected_size == 0))
+ if(fstated && (expected_size == 0))
return CURLE_OK;
/* The following is a shortcut implementation of file reading
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
- while (res == CURLE_OK) {
+ while(res == CURLE_OK) {
nread = read(fd, buf, BUFSIZE-1);
- if ( nread > 0)
+ if( nread > 0)
buf[nread] = 0;
- if (nread <= 0)
+ if(nread <= 0)
break;
bytecount += nread;
#endif
#ifdef CURL_DISABLE_VERBOSE_STRINGS
-#define ftp_pasv_verbose(a,b,c,d) do { } while (0)
+#define ftp_pasv_verbose(a,b,c,d) do { } while(0)
#endif
/* Local API functions */
char env[MAX_PATH]; /* MAX_PATH is from windef.h */
char *temp = getenv(variable);
env[0] = '\0';
- if (temp != NULL)
+ if(temp != NULL)
ExpandEnvironmentStrings(temp, env, sizeof(env));
return (env[0] != '\0')?strdup(env):NULL;
#else
char *env = getenv(variable);
#ifdef VMS
- if (env && strcmp("HOME",variable) == 0)
+ if(env && strcmp("HOME",variable) == 0)
env = decc$translate_vms(env);
#endif
return (env && env[0])?strdup(env):NULL;
info->httpversion=0;
info->filetime=-1; /* -1 is an illegal time and thus means unknown */
- if (info->contenttype)
+ if(info->contenttype)
free(info->contenttype);
info->contenttype = NULL;
/* determine if ssl */
if(c->ssl[FIRSTSOCKET].use) {
/* use the SSL context */
- if (!Curl_ssl_check_cxn(c))
+ if(!Curl_ssl_check_cxn(c))
*param_longp = -1; /* FIN received */
}
/* Minix 3.1 doesn't support any flags on recv; just assume socket is OK */
static int _Curl_gtls_init(void)
{
int ret = 1;
- if (!gtls_inited) {
+ if(!gtls_inited) {
ret = gnutls_global_init()?0:1;
#ifdef GTLSDEBUG
gnutls_global_set_log_function(tls_log_func);
int Curl_gtls_cleanup(void)
{
- if (gtls_inited)
+ if(gtls_inited)
gnutls_global_deinit();
return 1;
}
{
struct SessionHandle *data = conn->data;
int rc;
- if (!gtls_inited)
+ if(!gtls_inited)
_Curl_gtls_init();
do {
rc = gnutls_handshake(session);
break;
} while(1);
- if (rc < 0) {
+ if(rc < 0) {
failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
}
void *ssl_sessionid;
size_t ssl_idsize;
- if (!gtls_inited) _Curl_gtls_init();
+ if(!gtls_inited) _Curl_gtls_init();
/* GnuTLS only supports TLSv1 (and SSLv3?) */
if(data->set.ssl.version == CURL_SSLVERSION_SSLv2) {
failf(data, "GnuTLS does not support SSLv2");
if(rc < 0) {
infof(data, "error reading ca cert file %s (%s)\n",
data->set.ssl.CAfile, gnutls_strerror(rc));
- if (data->set.ssl.verifypeer)
+ if(data->set.ssl.verifypeer)
return CURLE_SSL_CACERT_BADFILE;
}
else
gnutls_certificate_set_verify_limits(). */
rc = gnutls_certificate_verify_peers2(session, &verify_status);
- if (rc < 0) {
+ if(rc < 0) {
failf(data, "server cert verify failed: %d", rc);
return CURLE_SSL_CONNECT_ERROR;
}
/* verify_status is a bitmask of gnutls_certificate_status bits */
if(verify_status & GNUTLS_CERT_INVALID) {
- if (data->set.ssl.verifypeer) {
+ if(data->set.ssl.verifypeer) {
failf(data, "server certificate verification failed. CAfile: %s",
data->set.ssl.CAfile?data->set.ssl.CAfile:"none");
return CURLE_SSL_CACERT;
rc = gnutls_x509_crt_check_hostname(x509_cert, conn->host.name);
if(!rc) {
- if (data->set.ssl.verifyhost > 1) {
+ if(data->set.ssl.verifyhost > 1) {
failf(data, "SSL: certificate subject name (%s) does not match "
"target host name '%s'", certbuf, conn->host.dispname);
gnutls_x509_crt_deinit(x509_cert);
}
if(clock < time(NULL)) {
- if (data->set.ssl.verifypeer) {
+ if(data->set.ssl.verifypeer) {
failf(data, "server certificate expiration date has passed.");
return CURLE_PEER_FAILED_VERIFICATION;
}
}
if(clock > time(NULL)) {
- if (data->set.ssl.verifypeer) {
+ if(data->set.ssl.verifypeer) {
failf(data, "server certificate not activated yet.");
return CURLE_PEER_FAILED_VERIFICATION;
}
}
*wouldblock = FALSE;
- if (!ret) {
+ if(!ret) {
failf(conn->data, "Peer closed the TLS connection");
return -1;
}
- if (ret < 0) {
+ if(ret < 0) {
failf(conn->data, "GnuTLS recv error (%d): %s",
(int)ret, gnutls_strerror(ret));
return -1;
struct curl_hash *h = (struct curl_hash *) user;
struct curl_hash_element *e = (struct curl_hash_element *) element;
- if (e->key)
+ if(e->key)
free(e->key);
h->dtor(e->ptr);
{
int i;
- if (!slots || !hfunc || !comparator ||!dtor) {
+ if(!slots || !hfunc || !comparator ||!dtor) {
return 1; /* failure */
}
{
struct curl_hash *h;
- if (!slots || !hfunc || !comparator ||!dtor) {
+ if(!slots || !hfunc || !comparator ||!dtor) {
return NULL; /* failure */
}
h = (struct curl_hash *) malloc(sizeof(struct curl_hash));
- if (h) {
+ if(h) {
if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) {
/* failure */
free(h);
for (le = l->head; le; le = le->next) {
he = (struct curl_hash_element *) le->ptr;
- if (h->comp_func(he->key, he->key_len, key, key_len)) {
+ if(h->comp_func(he->key, he->key_len, key, key_len)) {
h->dtor(p); /* remove the NEW entry */
return he->ptr; /* return the EXISTING entry */
}
}
he = mk_hash_element(key, key_len, p);
- if (he) {
+ if(he) {
if(Curl_llist_insert_next(l, l->tail, he)) {
++h->size;
return p; /* return the new entry */
for (le = l->head; le; le = le->next) {
he = le->ptr;
- if (h->comp_func(he->key, he->key_len, key, key_len)) {
+ if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *) h);
return 0;
}
for (le = l->head; le; le = le->next) {
he = le->ptr;
- if (h->comp_func(he->key, he->key_len, key, key_len)) {
+ if(h->comp_func(he->key, he->key_len, key, key_len)) {
return he->ptr;
}
}
struct curl_hash_element *he = le->ptr;
lnext = le->next;
/* ask the callback function if we shall remove this entry or not */
- if (comp(user, he->ptr)) {
+ if(comp(user, he->ptr)) {
Curl_llist_remove(list, le, (void *) h);
--h->size; /* one less entry in the hash now */
}
void
Curl_hash_destroy(struct curl_hash *h)
{
- if (!h)
+ if(!h)
return;
Curl_hash_clean(h);
const char *end = key_str + key_length;
unsigned long h = 5381;
- while (key_str < end) {
+ while(key_str < end) {
h += h << 5;
h ^= (unsigned long) *key_str++;
}
char *key1 = (char *)k1;
char *key2 = (char *)k2;
- if (key1_len == key2_len &&
+ if(key1_len == key2_len &&
*key1 == *key2 &&
memcmp(key1, key2, key1_len) == 0) {
return 1;
struct curl_llist_element *le;
struct curl_llist *list;
struct curl_hash_element *he;
- if (!h)
+ if(!h)
return;
fprintf(stderr, "=Hash dump=\n");
timeout = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve timeout */
/* Wait for the name resolve query to complete. */
- while (1) {
+ while(1) {
struct timeval *tvp, tv, store;
struct timeval now = Curl_tvnow();
long timediff;
timediff = Curl_tvdiff(Curl_tvnow(), now); /* spent time */
timeout -= timediff?timediff:1; /* always deduct at least 1 */
- if (timeout < 0) {
+ if(timeout < 0) {
/* our timeout, so we cancel the ares operation */
ares_cancel(data->state.areschannel);
break;
*waitp = FALSE;
- if (in != CURL_INADDR_NONE) {
+ if(in != CURL_INADDR_NONE) {
/* This is a dotted IP address 123.123.123.123-style */
return Curl_ip2addr(in, hostname, port);
}
*/
void Curl_global_host_cache_init(void)
{
- if (!host_cache_initialized) {
+ if(!host_cache_initialized) {
Curl_hash_init(&hostname_cache, 7, Curl_hash_str, Curl_str_key_compare,
freednsentry);
host_cache_initialized = 1;
*/
void Curl_global_host_cache_dtor(void)
{
- if (host_cache_initialized) {
+ if(host_cache_initialized) {
Curl_hash_clean(&hostname_cache);
host_cache_initialized = 0;
}
(struct hostcache_prune_data *) datap;
struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc;
- if ((data->now - c->timestamp < data->cache_timeout) ||
+ if((data->now - c->timestamp < data->cache_timeout) ||
c->inuse) {
/* please don't remove */
return 0;
time(&user.now);
user.cache_timeout = data->set.dns_cache_timeout;
- if ( !hostcache_timestamp_remove(&user,dns) )
+ if( !hostcache_timestamp_remove(&user,dns) )
return 0;
/* ok, we do need to clear the cache. although we need to remove just a
/* Create an entry id, based upon the hostname and port */
entry_id = create_hostcache_id(hostname, port);
/* If we can't create the entry id, fail */
- if (!entry_id)
+ if(!entry_id)
return NULL;
entry_len = strlen(entry_id);
/* Create a new cache entry */
dns = (struct Curl_dns_entry *) calloc(sizeof(struct Curl_dns_entry), 1);
- if (!dns) {
+ if(!dns) {
free(entry_id);
return NULL;
}
/* this allows us to time-out from the name resolver, as the timeout
will generate a signal and we will siglongjmp() from that here */
if(!data->set.no_signal) {
- if (sigsetjmp(curl_jmpenv, 1)) {
+ if(sigsetjmp(curl_jmpenv, 1)) {
/* this is coming from a siglongjmp() */
failf(data, "name lookup timed out");
return CURLRESOLV_ERROR;
/* Create an entry id, based upon the hostname and port */
entry_id = create_hostcache_id(hostname, port);
/* If we can't create the entry id, fail */
- if (!entry_id)
+ if(!entry_id)
return CURLRESOLV_ERROR;
entry_len = strlen(entry_id);
/* See whether the returned entry is stale. Deliberately done after the
locked block */
- if ( remove_entry_if_stale(data,dns) )
+ if( remove_entry_if_stale(data,dns) )
dns = NULL; /* the memory deallocation is being handled by the hash */
rc = CURLRESOLV_ERROR; /* default to failure */
- if (!dns) {
+ if(!dns) {
/* The entry was not in the cache. Resolve it to IP address */
Curl_addrinfo *addr;
resolve call */
addr = Curl_getaddrinfo(conn, hostname, port, &respwait);
- if (!addr) {
+ if(!addr) {
if(respwait) {
/* the response to our resolve call will come asynchronously at
a later time, good or bad */
#else
h = gethostbyname(hostname);
#endif
- if (!h)
+ if(!h)
infof(conn->data, "gethostbyname(2) failed for %s\n", hostname);
#endif /*HAVE_GETHOSTBYNAME_R */
}
if(h) {
ai = Curl_he2ai(h, port);
- if (buf) /* used a *_r() function */
+ if(buf) /* used a *_r() function */
free(buf);
}
if(data->set.ip_version == CURL_IPRESOLVE_V6) {
/* see if we have an IPv6 stack */
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
- if (s == CURL_SOCKET_BAD)
+ if(s == CURL_SOCKET_BAD)
/* an ipv6 address was requested and we can't get/use one */
return FALSE;
sclose(s);
printf(" fam %2d, CNAME %s, ",
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
- if (Curl_printable_address(ai, buf, sizeof(buf)))
+ if(Curl_printable_address(ai, buf, sizeof(buf)))
printf("%s\n", buf);
else
printf("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
/* see if we have an IPv6 stack */
s = socket(PF_INET6, SOCK_DGRAM, 0);
- if (s == CURL_SOCKET_BAD) {
+ if(s == CURL_SOCKET_BAD) {
/* Some non-IPv6 stacks have been found to make very slow name resolves
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
* the stack seems to be a non-ipv6 one. */
sbufptr=sbuf;
}
error = getaddrinfo(hostname, sbufptr, &hints, &res);
- if (error) {
+ if(error) {
infof(data, "getaddrinfo(3) failed for %s:%d\n", hostname, port);
return NULL;
}
/* the original data is written to the client, but we go on with the
chunk read process, to properly calculate the content length*/
- if (data->set.http_te_skip && !k->ignorebody)
+ if(data->set.http_te_skip && !k->ignorebody)
Curl_client_write(conn, CLIENTWRITE_BODY, datap,datalen);
while(length) {
if(*datap == 0x0a) {
/* we're now expecting data to come, unless size was zero! */
if(0 == ch->datasize) {
- if (conn->bits.trailerHdrPresent!=TRUE) {
+ if(conn->bits.trailerHdrPresent!=TRUE) {
/* No Trailer: header found - revert to original Curl processing */
ch->state = CHUNK_STOPCR;
case IDENTITY:
#endif
if(!k->ignorebody) {
- if ( !data->set.http_te_skip )
+ if( !data->set.http_te_skip )
result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
piece);
else
case CHUNK_TRAILER:
/* conn->trailer is assumed to be freed in url.c on a
connection basis */
- if (conn->trlPos >= conn->trlMax) {
+ if(conn->trlPos >= conn->trlMax) {
char *ptr;
if(conn->trlMax) {
conn->trlMax *= 2;
break;
case CHUNK_TRAILER_POSTCR:
- if (*datap == 0x0a) {
+ if(*datap == 0x0a) {
conn->trailer[conn->trlPos++]=0x0a;
conn->trailer[conn->trlPos]=0;
- if (conn->trlPos==2) {
+ if(conn->trlPos==2) {
ch->state = CHUNK_STOP;
datap++;
length--;
return(CHUNKE_BAD_CHUNK);
}
#endif /* CURL_DOES_CONVERSIONS */
- if ( !data->set.http_te_skip )
+ if( !data->set.http_te_skip )
Curl_client_write(conn, CLIENTWRITE_HEADER,
conn->trailer, conn->trlPos);
}
break;
case CHUNK_STOP:
- if (*datap == 0x0a) {
+ if(*datap == 0x0a) {
datap++;
length--;
if(!tmp)
return CURLDIGEST_NOMEM;
token = strtok_r(tmp, ",", &tok_buf);
- while (token != NULL) {
- if (strequal(token, "auth")) {
+ while(token != NULL) {
+ if(strequal(token, "auth")) {
foundAuth = TRUE;
}
- else if (strequal(token, "auth-int")) {
+ else if(strequal(token, "auth-int")) {
foundAuthInt = TRUE;
}
token = strtok_r(NULL, ",", &tok_buf);
}
free(tmp);
/*select only auth o auth-int. Otherwise, ignore*/
- if (foundAuth) {
+ if(foundAuth) {
d->qop = strdup("auth");
if(!d->qop)
return CURLDIGEST_NOMEM;
}
- else if (foundAuthInt) {
+ else if(foundAuthInt) {
d->qop = strdup("auth-int");
if(!d->qop)
return CURLDIGEST_NOMEM;
*/
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
- if (rc != CURLE_OK) { \
+ if(rc != CURLE_OK) { \
free(b); \
return rc; \
}
authp = &data->state.authhost;
}
- if (*allocuserpwd) {
+ if(*allocuserpwd) {
Curl_safefree(*allocuserpwd);
*allocuserpwd = NULL;
}
return CURLE_OUT_OF_MEMORY;
}
- if (d->qop && strequal(d->qop, "auth-int")) {
+ if(d->qop && strequal(d->qop, "auth-int")) {
/* We don't support auth-int at the moment. I can't see a easy way to get
entity-body here */
/* TODO: Append H(entity-body)*/
free(md5this); /* free this again */
md5_to_ascii(md5buf, ha2);
- if (d->qop) {
+ if(d->qop) {
md5this = (unsigned char *)aprintf("%s:%s:%08x:%s:%s:%s",
ha1,
d->nonce,
nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca"
*/
- if (d->qop) {
+ if(d->qop) {
*allocuserpwd =
aprintf( "%sAuthorization: Digest "
"username=\"%s\", "
return NULL;
dummy = socket(AF_INET, SOCK_STREAM, 0);
- if (SYS_ERROR == dummy) {
+ if(SYS_ERROR == dummy) {
return NULL;
}
else {
memcpy(req.ifr_name, interface, len+1);
req.ifr_addr.sa_family = AF_INET;
#ifdef IOCTL_3_ARGS
- if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
+ if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
#else
- if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
+ if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
#endif
sclose(dummy);
return NULL;
#else
const char *addr = inet_ntoa(*(struct in_addr*)src);
- if (strlen(addr) >= size)
+ if(strlen(addr) >= size)
{
SET_ERRNO(ENOSPC);
return (NULL);
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
- if (words[i] == 0)
+ if(words[i] == 0)
{
- if (cur.base == -1)
+ if(cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
}
- else if (cur.base != -1)
+ else if(cur.base != -1)
{
- if (best.base == -1 || cur.len > best.len)
+ if(best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
- if ((cur.base != -1) && (best.base == -1 || cur.len > best.len))
+ if((cur.base != -1) && (best.base == -1 || cur.len > best.len))
best = cur;
- if (best.base != -1 && best.len < 2)
+ if(best.base != -1 && best.len < 2)
best.base = -1;
/* Format the result.
{
/* Are we inside the best run of 0x00's?
*/
- if (best.base != -1 && i >= best.base && i < (best.base + best.len))
+ if(best.base != -1 && i >= best.base && i < (best.base + best.len))
{
- if (i == best.base)
+ if(i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex?
*/
- if (i != 0)
+ if(i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4?
*/
- if (i == 6 && best.base == 0 &&
+ if(i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
- if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
+ if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
{
SET_ERRNO(ENOSPC);
return (NULL);
/* Was it a trailing run of 0x00's?
*/
- if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
+ if(best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/* Check for overflow, copy, and we're done.
*/
- if ((size_t)(tp - tmp) > size)
+ if((size_t)(tp - tmp) > size)
{
SET_ERRNO(ENOSPC);
return (NULL);
octets = 0;
tp = tmp;
*tp = 0;
- while ((ch = *src++) != '\0') {
+ while((ch = *src++) != '\0') {
const char *pch;
if((pch = strchr(digits, ch)) != NULL) {
curtok = src;
saw_xdigit = 0;
val = 0;
- while ((ch = *src++) != '\0') {
+ while((ch = *src++) != '\0') {
const char *pch;
if((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
++p, ++src, ++n)
*p = *src;
*p = '\0';
- if (*src == '\0')
+ if(*src == '\0')
return n;
else
return n + strlen (src);
}
#ifdef HAVE_KRB_GET_OUR_IP_FOR_REALM
- if (krb_get_config_bool("nat_in_use")) {
+ if(krb_get_config_bool("nat_in_use")) {
struct sockaddr_in *localaddr = (struct sockaddr_in *)LOCAL_ADDR;
struct in_addr natAddr;
- if (krb_get_our_ip_for_realm(krb_realmofhost(host),
+ if(krb_get_our_ip_for_realm(krb_realmofhost(host),
&natAddr) != KSUCCESS
&& krb_get_our_ip_for_realm(NULL, &natAddr) != KSUCCESS)
infof(data, "Can't get address for realm %s\n",
krb_realmofhost(host));
else {
- if (natAddr.s_addr != localaddr->sin_addr.s_addr) {
+ if(natAddr.s_addr != localaddr->sin_addr.s_addr) {
#ifdef HAVE_INET_NTOA_R
char ntoa_buf[64];
char *ip = (char *)inet_ntoa_r(natAddr, ntoa_buf, sizeof(ntoa_buf));
des_pcbc_encrypt((void *)tkt.dat, (void *)tktcopy.dat,
tkt.length,
schedule, &key, DES_DECRYPT);
- if (strcmp ((char*)tktcopy.dat + 8,
+ if(strcmp ((char*)tktcopy.dat + 8,
KRB_TICKET_GRANTING_TICKET) != 0) {
afs_string_to_key(passwd,
krb_realmofhost(conn->host.name),
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 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
return 0;
ne->ptr = (void *) p;
- if (list->size == 0) {
+ if(list->size == 0) {
list->head = ne;
list->head->prev = NULL;
list->head->next = NULL;
else {
ne->next = e->next;
ne->prev = e;
- if (e->next) {
+ if(e->next) {
e->next->prev = ne;
}
else {
Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e,
void *user)
{
- if (e == NULL || list->size == 0)
+ if(e == NULL || list->size == 0)
return 1;
- if (e == list->head) {
+ if(e == list->head) {
list->head = e->next;
- if (list->head == NULL)
+ if(list->head == NULL)
list->tail = NULL;
else
e->next->prev = NULL;
} else {
e->prev->next = e->next;
- if (!e->next)
+ if(!e->next)
list->tail = e->prev;
else
e->next->prev = e->prev;
Curl_llist_destroy(struct curl_llist *list, void *user)
{
if(list) {
- while (list->size > 0)
+ while(list->size > 0)
Curl_llist_remove(list, list->tail, user);
free(list);
/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 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
* are also available at http://curl.haxx.se/docs/copyright.html.
- *
+ *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
+ if((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
-
+
partLen = 64 - bufindex;
/* Transform as many times as possible. */
- if (inputLen >= partLen) {
+ if(inputLen >= partLen) {
memcpy((void *)&context->buffer[bufindex], (void *)input, partLen);
MD5Transform(context->state, context->buffer);
-
+
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform(context->state, &input[i]);
-
+
bufindex = 0;
}
else
/* this sets the log file name */
void curl_memdebug(const char *logname)
{
- if (!logfile) {
+ if(!logfile) {
if(logname)
logfile = fopen(logname, "w");
else
successfully! */
void curl_memlimit(long limit)
{
- if (!memlimit) {
+ if(!memlimit) {
memlimit = TRUE;
memsize = limit;
}
len=strlen(str)+1;
mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */
- if (mem)
- memcpy(mem, str, len);
+ if(mem)
+ memcpy(mem, str, len);
if(logfile)
fprintf(logfile, "MEM %s:%d strdup(%p) (%zd) = %p\n",
char *override = curl_getenv("CURL_DEBUG_NETRC");
- if (override) {
+ if(override) {
fprintf(stderr, "NETRC: overridden " NETRC " file: %s\n", override);
netrcfile = override;
netrc_alloc = TRUE;
else {
struct passwd *pw;
pw= getpwuid(geteuid());
- if (pw) {
+ if(pw) {
#ifdef VMS
home = decc$translate_vms(pw->pw_dir);
#else
tok=strtok_r(netrcbuffer, " \t\n", &tok_buf);
while(!done && tok) {
- if (login[0] && password[0]) {
+ if(login[0] && password[0]) {
done=TRUE;
break;
}
case HOSTVALID:
/* we are now parsing sub-keywords concerning "our" host */
if(state_login) {
- if (specific_login) {
+ if(specific_login) {
state_our_login = strequal(login, tok);
}
else {
state_login=0;
}
else if(state_password) {
- if (state_our_login || !specific_login) {
+ if(state_our_login || !specific_login) {
strncpy(password, tok, PASSWORDSIZE-1);
#ifdef _NETRC_DEBUG
fprintf(stderr, "PASSWORD: %s\n", password);
} /* switch (state) */
tok = strtok_r(NULL, " \t\n", &tok_buf);
- } /* while (tok) */
+ } /* while(tok) */
} /* while fgets() */
fclose(file);
const char **messages )
{
NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
-
+
#ifndef __GNUC__
#pragma unused(cmdLine)
#pragma unused(loadDirPath)
"<library-name> memory allocations",
AllocSignature);
- if (!gAllocTag) {
+ if(!gAllocTag) {
OutputToScreen(errorScreen, "Unable to allocate resource tag for "
"library memory allocations.\n");
return -1;
gLibId = register_library(DisposeLibraryData);
- if (gLibId < -1) {
+ if(gLibId < -1) {
OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
return -1;
}
gLibHandle = NLMHandle;
gLibLock = NXMutexAlloc(0, 0, &liblock);
-
- if (!gLibLock) {
+
+ if(!gLibLock) {
OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
return -1;
}
*/
app_data = (libdata_t *) get_app_data(id);
- if (!app_data) {
+ if(!app_data) {
/*
** This application hasn't called us before; set up application AND per-thread
** data. Of course, just in case a thread from this same application is calling
*/
NXLock(gLibLock);
- if (!(app_data = (libdata_t *) get_app_data(id))) {
+ if(!(app_data = (libdata_t *) get_app_data(id))) {
app_data = (libdata_t *) malloc(sizeof(libdata_t));
- if (app_data) {
+ if(app_data) {
memset(app_data, 0, sizeof(libdata_t));
-
+
app_data->tenbytes = malloc(10);
app_data->lock = NXMutexAlloc(0, 0, &liblock);
-
- if (!app_data->tenbytes || !app_data->lock) {
- if (app_data->lock)
+
+ if(!app_data->tenbytes || !app_data->lock) {
+ if(app_data->lock)
NXMutexFree(app_data->lock);
-
+
free(app_data);
app_data = (libdata_t *) NULL;
err = ENOMEM;
}
-
- if (app_data) {
+
+ if(app_data) {
/*
** Here we burn in the application data that we were trying to get by calling
** get_app_data(). Next time we call the first function, we'll get this data
** thread the first time it calls us.
*/
err = set_app_data(gLibId, app_data);
-
- if (err) {
+
+ if(err) {
free(app_data);
app_data = (libdata_t *) NULL;
err = ENOMEM;
else {
/* create key for thread-specific data... */
err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
-
- if (err) /* (no more keys left?) */
+
+ if(err) /* (no more keys left?) */
key = -1;
-
+
app_data->perthreadkey = key;
}
}
}
}
-
+
NXUnlock(gLibLock);
}
- if (app_data) {
+ if(app_data) {
key = app_data->perthreadkey;
-
- if (key != -1 /* couldn't create a key? no thread data */
+
+ if(key != -1 /* couldn't create a key? no thread data */
&& !(err = NXKeyGetValue(key, (void **) &thread_data))
&& !thread_data) {
/*
** complex per-thread data.
*/
thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
-
- if (thread_data) {
+
+ if(thread_data) {
thread_data->_errno = 0;
thread_data->twentybytes = malloc(20);
-
- if (!thread_data->twentybytes) {
+
+ if(!thread_data->twentybytes) {
free(thread_data);
thread_data = (libthreaddata_t *) NULL;
err = ENOMEM;
}
-
- if ((err = NXKeySetValue(key, thread_data))) {
+
+ if((err = NXKeySetValue(key, thread_data))) {
free(thread_data->twentybytes);
free(thread_data);
thread_data = (libthreaddata_t *) NULL;
}
}
- if (appData)
+ if(appData)
*appData = app_data;
- if (threadData)
+ if(threadData)
*threadData = thread_data;
return err;
int DisposeLibraryData( void *data )
{
- if (data) {
+ if(data) {
void *tenbytes = ((libdata_t *) data)->tenbytes;
-
- if (tenbytes)
+
+ if(tenbytes)
free(tenbytes);
-
+
free(data);
}
void DisposeThreadData( void *data )
{
- if (data) {
+ if(data) {
void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
-
- if (twentybytes)
+
+ if(twentybytes)
free(twentybytes);
-
+
free(data);
}
}
{
/* initialize any globals here... */
- /* do this if any global initializing was done
+ /* do this if any global initializing was done
SynchronizeStart();
*/
ExitThread (TSR_THREAD, 0);
/* import UseAccurateCaseForPaths dynamically for NW3.x compatibility */
void (*pUseAccurateCaseForPaths)(int) = (void(*)(int))
ImportSymbol(myHandle, "UseAccurateCaseForPaths");
- if (pUnAugmentAsterisk)
+ if(pUnAugmentAsterisk)
pUnAugmentAsterisk(1);
- if (pUseAccurateCaseForPaths)
+ if(pUseAccurateCaseForPaths)
pUseAccurateCaseForPaths(1);
UnimportSymbol(myHandle, "UnAugmentAsterisk");
UnimportSymbol(myHandle, "UseAccurateCaseForPaths");
/* set long name space */
- if ((SetCurrentNameSpace(4) == 255)) {
+ if((SetCurrentNameSpace(4) == 255)) {
rc = 1;
}
- if ((SetTargetNameSpace(4) == 255)) {
+ if((SetTargetNameSpace(4) == 255)) {
rc = rc + 2;
}
return rc;
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 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
yearnum = val;
found = TRUE;
if(yearnum < 1900) {
- if (yearnum > 70)
+ if(yearnum > 70)
yearnum += 1900;
else
yearnum += 2000;
certname = data->set.str[STRING_CERT];
- if (!certname) {
+ if(!certname) {
certname = data->set.str[STRING_SSL_CAFILE];
- if (!certname)
+ if(!certname)
return CURLE_OK; /* Use previous setup. */
}
initappstr.sessionType = SSL_REGISTERED_AS_CLIENT;
rc = SSL_Init_Application(&initappstr);
- if (rc == SSL_ERROR_NOT_REGISTERED) {
+ if(rc == SSL_ERROR_NOT_REGISTERED) {
initstr.keyringFileName = certname;
initstr.keyringPassword = data->set.str[STRING_KEY];
initstr.cipherSuiteList = NULL; /* Use default. */
h = SSL_Create(conn->sock[sockindex], SSL_ENCRYPT);
- if (!h) {
+ if(!h) {
failf(conn->data, "SSL_Create() I/O error: %s\n", strerror(errno));
return CURLE_SSL_CONNECT_ERROR;
}
h->exitPgm = NULL;
- if (!data->set.ssl.verifyhost)
+ if(!data->set.ssl.verifyhost)
h->exitPgm = Curl_qsossl_trap_cert;
- if (data->set.connecttimeout) {
+ if(data->set.connecttimeout) {
timeout_ms = data->set.connecttimeout;
- if (data->set.timeout)
- if (timeout_ms > data->set.timeout)
+ if(data->set.timeout)
+ if(timeout_ms > data->set.timeout)
timeout_ms = data->set.timeout;
}
- else if (data->set.timeout)
+ else if(data->set.timeout)
timeout_ms = data->set.timeout;
else
timeout_ms = DEFAULT_CONNECT_TIMEOUT;
rc = Curl_qsossl_init_session(data);
- if (rc == CURLE_OK) {
+ if(rc == CURLE_OK) {
rc = Curl_qsossl_create(conn, sockindex);
- if (rc == CURLE_OK)
+ if(rc == CURLE_OK)
rc = Curl_qsossl_handshake(conn, sockindex);
else {
SSL_Destroy(connssl->handle);
rc = SSL_Destroy(conn->handle);
if(rc) {
- if (rc == SSL_ERROR_IO) {
+ if(rc == SSL_ERROR_IO) {
failf(data, "SSL_Destroy() I/O error: %s\n", strerror(errno));
return -1;
}
int rc;
char buf[120];
- if (!connssl->handle)
+ if(!connssl->handle)
return 0;
- if (data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
+ if(data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
return 0;
- if (Curl_qsossl_close_one(connssl, data))
+ if(Curl_qsossl_close_one(connssl, data))
return -1;
rc = 0;
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
for (;;) {
- if (what < 0) {
+ if(what < 0) {
/* anything that gets here is fatally bad */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
rc = -1;
break;
}
- if (!what) { /* timeout */
+ if(!what) { /* timeout */
failf(data, "SSL shutdown timeout");
break;
}
nread = read(conn->sock[sockindex], buf, sizeof(buf));
- if (nread < 0) {
+ if(nread < 0) {
failf(data, "read: %s\n", strerror(errno));
rc = -1;
}
- if (nread <= 0)
+ if(nread <= 0)
break;
what = Curl_socket_ready(conn->sock[sockindex], CURL_SOCKET_BAD, 0);
/* The only thing that can be tested here is at the socket level. */
- if (!cxn->ssl[FIRSTSOCKET].handle)
+ if(!cxn->ssl[FIRSTSOCKET].handle)
return 0; /* connection has been closed */
err = 0;
errlen = sizeof err;
- if (getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
+ if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
(unsigned char *) &err, &errlen) ||
errlen != sizeof err || err)
return 0; /* connection has been closed */
*
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
+ *
+ * Copyright (C) 2001 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#define min(a, b) ((a) < (b) ? (a) : (b))
static const struct {
- enum protection_level level;
- const char *name;
+ enum protection_level level;
+ const char *name;
} level_names[] = {
- { prot_clear, "clear" },
- { prot_safe, "safe" },
- { prot_confidential, "confidential" },
- { prot_private, "private" }
+ { prot_clear, "clear" },
+ { prot_safe, "safe" },
+ { prot_confidential, "confidential" },
+ { prot_private, "private" }
};
static enum protection_level
static const struct Curl_sec_client_mech * const mechs[] = {
#ifdef HAVE_GSSAPI
- &Curl_krb5_client_mech,
+ &Curl_krb5_client_mech,
#endif
#ifdef HAVE_KRB4
- &Curl_krb4_client_mech,
+ &Curl_krb4_client_mech,
#endif
- NULL
+ NULL
};
int
int b;
while(len) {
b = read(fd, p, len);
- if (b == 0)
+ if(b == 0)
return 0;
- else if (b < 0 && (errno == EINTR || errno == EAGAIN))
+ else if(b < 0 && (errno == EINTR || errno == EAGAIN))
continue;
- else if (b < 0)
+ else if(b < 0)
return -1;
len -= b;
p += b;
int b;
while(len) {
b = write(fd, p, len);
- if (b < 0 && (errno == EINTR || errno == EAGAIN))
+ if(b < 0 && (errno == EINTR || errno == EAGAIN))
continue;
else if(b < 0)
return -1;
int b;
b = block_read(fd, &len, sizeof(len));
- if (b == 0)
+ if(b == 0)
return 0;
- else if (b < 0)
+ else if(b < 0)
return -1;
len = ntohl(len);
buf->data = realloc(buf->data, len);
b = buf->data ? block_read(fd, buf->data, len) : -1;
- if (b == 0)
+ if(b == 0)
return 0;
- else if (b < 0)
+ else if(b < 0)
return -1;
buf->size = (conn->mech->decode)(conn->app_data, buf->data, len,
conn->data_prot, conn);
static size_t
buffer_read(struct krb4buffer *buf, void *data, size_t len)
{
- len = min(len, buf->size - buf->index);
- memcpy(data, (char*)buf->data + buf->index, len);
- buf->index += len;
- return len;
+ len = min(len, buf->size - buf->index);
+ memcpy(data, (char*)buf->data + buf->index, len);
+ buf->index += len;
+ return len;
}
static size_t
buffer_write(struct krb4buffer *buf, void *data, size_t len)
{
- if(buf->index + len > buf->size) {
- void *tmp;
- if(buf->data == NULL)
- tmp = malloc(1024);
- else
- tmp = realloc(buf->data, buf->index + len);
- if(tmp == NULL)
- return -1;
- buf->data = tmp;
- buf->size = buf->index + len;
- }
- memcpy((char*)buf->data + buf->index, data, len);
- buf->index += len;
- return len;
+ if(buf->index + len > buf->size) {
+ void *tmp;
+ if(buf->data == NULL)
+ tmp = malloc(1024);
+ else
+ tmp = realloc(buf->data, buf->index + len);
+ if(tmp == NULL)
+ return -1;
+ buf->data = tmp;
+ buf->size = buf->index + len;
+ }
+ memcpy((char*)buf->data + buf->index, data, len);
+ buf->index += len;
+ return len;
}
int
Curl_sec_read(struct connectdata *conn, int fd, void *buffer, int length)
{
- size_t len;
- int rx = 0;
+ size_t len;
+ int rx = 0;
- if(conn->sec_complete == 0 || conn->data_prot == 0)
- return read(fd, buffer, length);
+ if(conn->sec_complete == 0 || conn->data_prot == 0)
+ return read(fd, buffer, length);
- if(conn->in_buffer.eof_flag){
- conn->in_buffer.eof_flag = 0;
- return 0;
- }
+ if(conn->in_buffer.eof_flag){
+ conn->in_buffer.eof_flag = 0;
+ return 0;
+ }
+
+ len = buffer_read(&conn->in_buffer, buffer, length);
+ length -= len;
+ rx += len;
+ buffer = (char*)buffer + len;
+ while(length) {
+ if(sec_get_data(conn, fd, &conn->in_buffer) < 0)
+ return -1;
+ if(conn->in_buffer.size == 0) {
+ if(rx)
+ conn->in_buffer.eof_flag = 1;
+ return rx;
+ }
len = buffer_read(&conn->in_buffer, buffer, length);
length -= len;
rx += len;
buffer = (char*)buffer + len;
-
- while(length) {
- if(sec_get_data(conn, fd, &conn->in_buffer) < 0)
- return -1;
- if(conn->in_buffer.size == 0) {
- if(rx)
- conn->in_buffer.eof_flag = 1;
- return rx;
- }
- len = buffer_read(&conn->in_buffer, buffer, length);
- length -= len;
- rx += len;
- buffer = (char*)buffer + len;
- }
- return rx;
+ }
+ return rx;
}
static int
bytes = Curl_base64_encode(conn->data, (char *)buf, bytes, &cmdbuf);
if(bytes > 0) {
if(protlevel == prot_private)
- block_write(fd, "ENC ", 4);
+ block_write(fd, "ENC ", 4);
else
- block_write(fd, "MIC ", 4);
+ block_write(fd, "MIC ", 4);
block_write(fd, cmdbuf, bytes);
block_write(fd, "\r\n", 2);
- Curl_infof(conn->data, "%s %s\n", protlevel == prot_private ? "ENC" : "MIC", cmdbuf);
+ Curl_infof(conn->data, "%s %s\n",
+ protlevel == prot_private ? "ENC" : "MIC", cmdbuf);
free(cmdbuf);
}
- } else {
+ }
+ else {
bytes = htonl(bytes);
block_write(fd, &bytes, sizeof(bytes));
block_write(fd, buf, ntohl(bytes));
if(conn->data_prot != prot_clear) {
if(conn->out_buffer.index > 0){
Curl_sec_write(conn, fd,
- conn->out_buffer.data, conn->out_buffer.index);
+ conn->out_buffer.data, conn->out_buffer.index);
conn->out_buffer.index = 0;
}
sec_send(conn, fd, NULL, 0);
void *tmp;
tmp = realloc(conn->app_data, (*m)->size);
- if (tmp == NULL) {
+ if(tmp == NULL) {
failf (data, "realloc %u failed", (*m)->size);
return -1;
}
void
Curl_sec_end(struct connectdata *conn)
{
- if (conn->mech != NULL) {
+ if(conn->mech != NULL) {
if(conn->mech->end)
(conn->mech->end)(conn->app_data);
memset(conn->app_data, 0, conn->mech->size);
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 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
{
struct Curl_share *share =
(struct Curl_share *)malloc(sizeof(struct Curl_share));
- if (share) {
+ if(share) {
memset (share, 0, sizeof(struct Curl_share));
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
}
curl_unlock_function unlockfunc;
void *ptr;
- if (share->dirty)
+ if(share->dirty)
/* don't allow setting options while one or more handles are already
using this share */
return CURLSHE_IN_USE;
share->specifier |= (1<<type);
switch( type ) {
case CURL_LOCK_DATA_DNS:
- if (!share->hostcache) {
+ if(!share->hostcache) {
share->hostcache = Curl_mk_dnscache();
if(!share->hostcache)
return CURLSHE_NOMEM;
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
case CURL_LOCK_DATA_COOKIE:
- if (!share->cookies) {
+ if(!share->cookies) {
share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE );
if(!share->cookies)
return CURLSHE_NOMEM;
switch( type )
{
case CURL_LOCK_DATA_DNS:
- if (share->hostcache) {
+ if(share->hostcache) {
Curl_hash_destroy(share->hostcache);
share->hostcache = NULL;
}
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
case CURL_LOCK_DATA_COOKIE:
- if (share->cookies) {
+ if(share->cookies) {
Curl_cookie_cleanup(share->cookies);
share->cookies = NULL;
}
{
struct Curl_share *share = (struct Curl_share *)sh;
- if (share == NULL)
+ if(share == NULL)
return CURLSHE_INVALID;
if(share->lockfunc)
share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE,
share->clientdata);
- if (share->dirty) {
+ if(share->dirty) {
if(share->unlockfunc)
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
return CURLSHE_IN_USE;
{
struct Curl_share *share = data->share;
- if (share == NULL)
+ if(share == NULL)
return CURLSHE_INVALID;
if(share->specifier & (1<<type)) {
{
struct Curl_share *share = data->share;
- if (share == NULL)
+ if(share == NULL)
return CURLSHE_INVALID;
if(share->specifier & (1<<type)) {
struct ssh_conn *sshc = &conn->proto.sshc;
CURLcode result = CURLE_OK;
- while (sshc->state != SSH_STOP) {
+ while(sshc->state != SSH_STOP) {
result = ssh_statemach_act(conn);
if(result) {
break;
store->name = clone_host; /* clone host name */
store->remote_port = conn->remote_port; /* port number */
- if (!Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config))
+ if(!Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config))
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 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
int len;
char *newstr;
- if (!str)
+ if(!str)
return (char *)NULL;
len = strlen(str);
newstr = (char *) malloc((len+1)*sizeof(char));
- if (!newstr)
+ if(!newstr)
return (char *)NULL;
memcpy(newstr,str,(len+1)*sizeof(char));
#elif defined(HAVE_STRICMP)
return !(stricmp)(first, second);
#else
- while (*first && *second) {
- if (toupper(*first) != toupper(*second)) {
+ while(*first && *second) {
+ if(toupper(*first) != toupper(*second)) {
break;
}
first++;
#elif defined(HAVE_STRICMP)
return !strnicmp(first, second, max);
#else
- while (*first && *second && max) {
- if (toupper(*first) != toupper(*second)) {
+ while(*first && *second && max) {
+ if(toupper(*first) != toupper(*second)) {
break;
}
max--;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
- while (n-- != 0 && *d != '\0')
+ while(n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;
- if (n == 0)
+ if(n == 0)
return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
+ while(*s != '\0') {
+ if(n != 1) {
*d++ = *s;
n--;
}
*/
return "Unknown error";
#else
- if (error == CURLE_OK)
+ if(error == CURLE_OK)
return "No error";
else
return "Error";
return "Unknown error";
#else
- if (error == CURLM_OK)
+ if(error == CURLM_OK)
return "No error";
else
return "Error";
return "CURLSHcode unknown";
#else
- if (error == CURLSHE_OK)
+ if(error == CURLSHE_OK)
return "No error";
else
return "Error";
return NULL;
}
#else
- if (err == CURLE_OK)
+ if(err == CURLE_OK)
return NULL;
else
p = "error";
#else
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
- if (err >= 0 && err < sys_nerr)
+ if(err >= 0 && err < sys_nerr)
strncpy(buf, strerror(err), max);
else {
- if (!get_winsock_error(err, buf, max) &&
+ if(!get_winsock_error(err, buf, max) &&
!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
LANG_NEUTRAL, buf, (DWORD)max, NULL))
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
buf[max] = '\0'; /* make sure the string is zero terminated */
/* strip trailing '\r\n' or '\n'. */
- if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
+ if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
*p = '\0';
- if ((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
+ if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
*p = '\0';
return buf;
}
break;
}
#else
- if ((Idna_rc)err == IDNA_SUCCESS)
+ if((Idna_rc)err == IDNA_SUCCESS)
str = "No error";
else
str = "Error";
#endif
- if (str)
+ if(str)
strncpy(buf, str, max);
buf[max] = '\0';
return (buf);
/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 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
* are also available at http://curl.haxx.se/docs/copyright.html.
- *
+ *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
char *
Curl_strtok_r(char *ptr, const char *sep, char **end)
{
- if (!ptr)
+ if(!ptr)
/* we got NULL input so then we get our last position instead */
ptr = *end;
/* pass all letters that are including in the separator string */
- while (*ptr && strchr(sep, *ptr))
+ while(*ptr && strchr(sep, *ptr))
++ptr;
- if (*ptr) {
+ if(*ptr) {
/* so this is where the next piece of string starts */
char *start = ptr;
/* scan through the string to find where it ends, it ends on a
null byte or a character that exists in the separator string */
- while (**end && !strchr(sep, **end))
+ while(**end && !strchr(sep, **end))
++*end;
- if (**end) {
+ if(**end) {
/* the end is not a null byte */
**end = '\0'; /* zero terminate it! */
++*end; /* advance the last pointer to beyond the null byte */
struct TELNET *tn = (struct TELNET *)data->reqdata.proto.telnet;
#define startskipping() \
- if (startwrite >= 0) \
+ if(startwrite >= 0) \
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&inbuf[startwrite], in-startwrite); \
startwrite = -1
#define writebyte() \
- if (startwrite < 0) \
+ if(startwrite < 0) \
startwrite = in
#define bufferflush() startskipping()
file name so we skip the always-present first letter of the path string. */
filename = curl_easy_unescape(data, &state->conn->data->reqdata.path[1], 0,
NULL);
- if (!filename)
+ if(!filename)
return CURLE_OUT_OF_MEMORY;
snprintf((char *)&state->spacket.data[2],
/* Is this the block we expect? */
rblock = getrpacketblock(&state->rpacket);
- if ((state->block+1) != rblock) {
+ if((state->block+1) != rblock) {
/* No, log it, up the retry count and fail if over the limit */
infof(data,
"Received unexpected DATA packet block %d\n", rblock);
state->retries++;
- if (state->retries>state->retry_max) {
+ if(state->retries>state->retry_max) {
failf(data, "tftp_rx: giving up waiting for block %d\n",
state->block+1);
return CURLE_TFTP_ILLEGAL;
}
/* Check if completed (That is, a less than full packet is received) */
- if (state->rbytes < (int)sizeof(state->spacket)){
+ if(state->rbytes < (int)sizeof(state->spacket)){
state->state = TFTP_STATE_FIN;
}
else {
failf(data, "%s\n", Curl_strerror(conn, error));
event = TFTP_EVENT_ERROR;
}
- else if (rc==0) {
+ else if(rc==0) {
/* A timeout occured */
event = TFTP_EVENT_TIMEOUT;
}
/* Sanity check packet length */
- if (state->rbytes < 4) {
+ if(state->rbytes < 4) {
failf(conn->data, "Received too short packet\n");
/* Not a timeout, but how best to handle it? */
event = TFTP_EVENT_TIMEOUT;
switch(event) {
case TFTP_EVENT_DATA:
/* Don't pass to the client empty or retransmitted packets */
- if (state->rbytes > 4 &&
+ if(state->rbytes > 4 &&
((state->block+1) == getrpacketblock(&state->rpacket))) {
code = Curl_client_write(conn, CLIENTWRITE_BODY,
(char *)&state->rpacket.data[4],
* we'll try to get now! */
type = strstr(data->reqdata.path, ";mode=");
- if (!type)
+ if(!type)
type = strstr(conn->host.rawalloc, ";mode=");
- if (type) {
+ if(type) {
*type = 0; /* it was in the middle of the hostname */
command = (char) toupper((int) type[6]);
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2007, 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
left -= len;
ptr += len;
- if (left > 1) {
+ if(left > 1) {
len = Curl_ssl_version(ptr + 1, left - 1);
- if (len > 0) {
+ if(len > 0) {
*ptr = ' ';
left -= ++len;
ptr += len;