atoi: remove atoi usage
This commit is contained in:
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
|
|||||||
} else if (strncasecmp(*argv, "-T", 2) == 0) {
|
} else if (strncasecmp(*argv, "-T", 2) == 0) {
|
||||||
prttime = 1;
|
prttime = 1;
|
||||||
} else if (strncasecmp(*argv, "-M=", 3) == 0) {
|
} else if (strncasecmp(*argv, "-M=", 3) == 0) {
|
||||||
int m = atoi(*argv + 3);
|
long m = strtol(argv+3, NULL, 10);
|
||||||
switch(m) {
|
switch(m) {
|
||||||
case 1: url = URL_1M;
|
case 1: url = URL_1M;
|
||||||
break;
|
break;
|
||||||
|
@@ -353,8 +353,8 @@ Curl_cookie_add(struct SessionHandle *data,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
co->expires =
|
co->expires =
|
||||||
atoi((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0]) +
|
strtol((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0],NULL,10)
|
||||||
(long)now;
|
+ (long)now;
|
||||||
}
|
}
|
||||||
else if(Curl_raw_equal("expires", name)) {
|
else if(Curl_raw_equal("expires", name)) {
|
||||||
strstore(&co->expirestr, whatptr);
|
strstore(&co->expirestr, whatptr);
|
||||||
|
@@ -379,7 +379,7 @@ static int ftp_endofresp(struct pingpong *pp,
|
|||||||
size_t len = pp->nread_resp;
|
size_t len = pp->nread_resp;
|
||||||
|
|
||||||
if((len > 3) && LASTLINE(line)) {
|
if((len > 3) && LASTLINE(line)) {
|
||||||
*code = atoi(line);
|
*code = strtol(line, NULL, 10);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -473,7 +473,7 @@ static void _ldap_trace (const char *fmt, ...)
|
|||||||
|
|
||||||
if(do_trace == -1) {
|
if(do_trace == -1) {
|
||||||
const char *env = getenv("CURL_TRACE");
|
const char *env = getenv("CURL_TRACE");
|
||||||
do_trace = (env && atoi(env) > 0);
|
do_trace = (env && strtol(env, NULL, 10) > 0);
|
||||||
}
|
}
|
||||||
if(!do_trace)
|
if(!do_trace)
|
||||||
return;
|
return;
|
||||||
|
@@ -226,7 +226,7 @@ static int smtp_endofresp(struct pingpong *pp, int *resp)
|
|||||||
return FALSE; /* Nothing for us. */
|
return FALSE; /* Nothing for us. */
|
||||||
|
|
||||||
if((result = line[3] == ' '))
|
if((result = line[3] == ' '))
|
||||||
*resp = atoi(line);
|
*resp = strtol(line, NULL, 10);
|
||||||
|
|
||||||
line += 4;
|
line += 4;
|
||||||
len -= 4;
|
len -= 4;
|
||||||
|
@@ -4155,7 +4155,7 @@ static CURLcode parse_proxy(struct SessionHandle *data,
|
|||||||
*prox_portno = 0x0; /* cut off number from host name */
|
*prox_portno = 0x0; /* cut off number from host name */
|
||||||
prox_portno ++;
|
prox_portno ++;
|
||||||
/* now set the local port number */
|
/* now set the local port number */
|
||||||
conn->port = atoi(prox_portno);
|
conn->port = strtol(prox_portno, NULL, 10);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* without a port number after the host name, some people seem to use
|
/* without a port number after the host name, some people seem to use
|
||||||
|
27
src/main.c
27
src/main.c
@@ -1509,12 +1509,15 @@ static void cleanarg(char *str)
|
|||||||
|
|
||||||
static int str2num(long *val, const char *str)
|
static int str2num(long *val, const char *str)
|
||||||
{
|
{
|
||||||
int retcode = 0;
|
if(str && ISDIGIT(*str)) {
|
||||||
if(str && ISDIGIT(*str))
|
char *endptr;
|
||||||
*val = atoi(str);
|
long num = strtol(str, &endptr, 10);
|
||||||
else
|
if((endptr != str) && (endptr == str + strlen(str))) {
|
||||||
retcode = 1; /* badness */
|
*val = num;
|
||||||
return retcode;
|
return 0; /* Ok */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1; /* badness */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3711,7 +3714,12 @@ void progressbarinit(struct ProgressData *bar,
|
|||||||
* we're using our own way to determine screen width */
|
* we're using our own way to determine screen width */
|
||||||
colp = curlx_getenv("COLUMNS");
|
colp = curlx_getenv("COLUMNS");
|
||||||
if(colp != NULL) {
|
if(colp != NULL) {
|
||||||
bar->width = atoi(colp);
|
char *endptr;
|
||||||
|
long num = strtol(colp, &endptr, 10);
|
||||||
|
if((endptr != colp) && (endptr == colp + strlen(colp)) && (num > 0))
|
||||||
|
bar->width = (int)num;
|
||||||
|
else
|
||||||
|
bar->width = 79;
|
||||||
curl_free(colp);
|
curl_free(colp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -4513,7 +4521,10 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
}
|
}
|
||||||
env = curlx_getenv("CURL_MEMLIMIT");
|
env = curlx_getenv("CURL_MEMLIMIT");
|
||||||
if(env) {
|
if(env) {
|
||||||
curl_memlimit(atoi(env));
|
char *endptr;
|
||||||
|
long num = strtol(env, &endptr, 10);
|
||||||
|
if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
|
||||||
|
curl_memlimit(num);
|
||||||
curl_free(env);
|
curl_free(env);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -59,7 +59,10 @@ int main(int argc, char **argv)
|
|||||||
/* this enables the fail-on-alloc-number-N functionality */
|
/* this enables the fail-on-alloc-number-N functionality */
|
||||||
env = curl_getenv("CURL_MEMLIMIT");
|
env = curl_getenv("CURL_MEMLIMIT");
|
||||||
if(env) {
|
if(env) {
|
||||||
curl_memlimit(atoi(env));
|
char *endptr;
|
||||||
|
long num = strtol(env, &endptr, 10);
|
||||||
|
if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
|
||||||
|
curl_memlimit(num);
|
||||||
curl_free(env);
|
curl_free(env);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -28,7 +28,7 @@ int test(char *URL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_setopt(curl, CURLOPT_URL, URL);
|
test_setopt(curl, CURLOPT_URL, URL);
|
||||||
test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2));
|
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
|
||||||
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ int test(char *URL)
|
|||||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||||
|
|
||||||
/* set port number */
|
/* set port number */
|
||||||
test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) );
|
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
|
||||||
|
|
||||||
/* specify target */
|
/* specify target */
|
||||||
test_setopt(curl,CURLOPT_URL, URL);
|
test_setopt(curl,CURLOPT_URL, URL);
|
||||||
|
@@ -531,8 +531,8 @@ static int ProcessRequest(struct httprequest *req)
|
|||||||
/* if the host name starts with test, the port number used in the
|
/* if the host name starts with test, the port number used in the
|
||||||
CONNECT line will be used as test number! */
|
CONNECT line will be used as test number! */
|
||||||
char *portp = strchr(doc, ':');
|
char *portp = strchr(doc, ':');
|
||||||
if(portp)
|
if(portp && (*(portp+1) != '\0') && ISDIGIT(*(portp+1)))
|
||||||
req->testno = atoi(portp+1);
|
req->testno = strtol(portp+1, NULL, 10);
|
||||||
else
|
else
|
||||||
req->testno = DOCNUMBER_CONNECT;
|
req->testno = DOCNUMBER_CONNECT;
|
||||||
}
|
}
|
||||||
|
@@ -467,8 +467,8 @@ static int ProcessRequest(struct httprequest *req)
|
|||||||
/* if the host name starts with test, the port number used in the
|
/* if the host name starts with test, the port number used in the
|
||||||
CONNECT line will be used as test number! */
|
CONNECT line will be used as test number! */
|
||||||
char *portp = strchr(doc, ':');
|
char *portp = strchr(doc, ':');
|
||||||
if(portp)
|
if(portp && (*(portp+1) != '\0') && ISDIGIT(*(portp+1)))
|
||||||
req->testno = atoi(portp+1);
|
req->testno = strtol(portp+1, NULL, 10);
|
||||||
else
|
else
|
||||||
req->testno = DOCNUMBER_CONNECT;
|
req->testno = DOCNUMBER_CONNECT;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user