Renamed a couple of global variables to avoid shadowing warnings
This commit is contained in:
parent
048bfeaaef
commit
059707be32
@ -34,8 +34,8 @@ int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
|
|||||||
return select(num_fds, rd, wr, exc, tv);
|
return select(num_fds, rd, wr, exc, tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *arg2=NULL;
|
char *libtest_arg2=NULL;
|
||||||
char *arg3=NULL;
|
char *libtest_arg3=NULL;
|
||||||
int test_argc;
|
int test_argc;
|
||||||
char **test_argv;
|
char **test_argv;
|
||||||
|
|
||||||
@ -73,10 +73,10 @@ int main(int argc, char **argv)
|
|||||||
test_argv = argv;
|
test_argv = argv;
|
||||||
|
|
||||||
if(argc>2)
|
if(argc>2)
|
||||||
arg2=argv[2];
|
libtest_arg2=argv[2];
|
||||||
|
|
||||||
if(argc>3)
|
if(argc>3)
|
||||||
arg3=argv[3];
|
libtest_arg3=argv[3];
|
||||||
|
|
||||||
URL = argv[1]; /* provide this to the rest */
|
URL = argv[1]; /* provide this to the rest */
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ int test(char *URL)
|
|||||||
return TEST_ERR_MAJOR_BAD;
|
return TEST_ERR_MAJOR_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(c, CURLOPT_PROXY, arg2); /* set in first.c */
|
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
|
||||||
curl_easy_setopt(c, CURLOPT_URL, URL);
|
curl_easy_setopt(c, CURLOPT_URL, URL);
|
||||||
curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing");
|
curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing");
|
||||||
curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
|
curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
|
||||||
|
@ -53,7 +53,7 @@ int test(char *URL)
|
|||||||
|
|
||||||
/* the point here being that there must not run anything on the given
|
/* the point here being that there must not run anything on the given
|
||||||
proxy port */
|
proxy port */
|
||||||
curl_easy_setopt(c, CURLOPT_PROXY, arg2);
|
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
|
||||||
curl_easy_setopt(c, CURLOPT_URL, URL);
|
curl_easy_setopt(c, CURLOPT_URL, URL);
|
||||||
curl_easy_setopt(c, CURLOPT_VERBOSE, 1);
|
curl_easy_setopt(c, CURLOPT_VERBOSE, 1);
|
||||||
|
|
||||||
|
@ -49,36 +49,36 @@ int test(char *URL)
|
|||||||
const char *buf_1 = "RNFR 505";
|
const char *buf_1 = "RNFR 505";
|
||||||
const char *buf_2 = "RNTO 505-forreal";
|
const char *buf_2 = "RNTO 505-forreal";
|
||||||
|
|
||||||
if (!arg2) {
|
if (!libtest_arg2) {
|
||||||
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the file size of the local file */
|
/* get the file size of the local file */
|
||||||
hd = stat(arg2, &file_info);
|
hd = stat(libtest_arg2, &file_info);
|
||||||
if(hd == -1) {
|
if(hd == -1) {
|
||||||
/* can't open file, bail out */
|
/* can't open file, bail out */
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
fprintf(stderr, "stat() failed with error: %d %s\n",
|
fprintf(stderr, "stat() failed with error: %d %s\n",
|
||||||
error, strerror(error));
|
error, strerror(error));
|
||||||
fprintf(stderr, "WARNING: cannot open file %s\n", arg2);
|
fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! file_info.st_size) {
|
if(! file_info.st_size) {
|
||||||
fprintf(stderr, "WARNING: file %s has no size!\n", arg2);
|
fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get a FILE * of the same file, could also be made with
|
/* get a FILE * of the same file, could also be made with
|
||||||
fdopen() from the previous descriptor, but hey this is just
|
fdopen() from the previous descriptor, but hey this is just
|
||||||
an example! */
|
an example! */
|
||||||
hd_src = fopen(arg2, "rb");
|
hd_src = fopen(libtest_arg2, "rb");
|
||||||
if(NULL == hd_src) {
|
if(NULL == hd_src) {
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||||
error, strerror(error));
|
error, strerror(error));
|
||||||
fprintf(stderr, "Error opening file: %s\n", arg2);
|
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
|
||||||
return -2; /* if this happens things are major weird */
|
return -2; /* if this happens things are major weird */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,8 +206,8 @@ int test(char *URL)
|
|||||||
char ml_timedout = FALSE;
|
char ml_timedout = FALSE;
|
||||||
char mp_timedout = FALSE;
|
char mp_timedout = FALSE;
|
||||||
|
|
||||||
if(arg2) {
|
if(libtest_arg2) {
|
||||||
portnum = atoi(arg2);
|
portnum = atoi(libtest_arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||||
|
@ -27,7 +27,7 @@ int test(char *URL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||||
curl_easy_setopt(curl, CURLOPT_PORT, atoi(arg2));
|
curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2));
|
||||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ int test(char *URL)
|
|||||||
return TEST_ERR_MAJOR_BAD;
|
return TEST_ERR_MAJOR_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXY, arg2);
|
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||||
curl_easy_setopt(curl, CURLOPT_PORT, 19999);
|
curl_easy_setopt(curl, CURLOPT_PORT, 19999);
|
||||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||||
|
@ -35,25 +35,25 @@ int test(char *URL)
|
|||||||
char ml_timedout = FALSE;
|
char ml_timedout = FALSE;
|
||||||
char mp_timedout = FALSE;
|
char mp_timedout = FALSE;
|
||||||
|
|
||||||
if (!arg2) {
|
if (!libtest_arg2) {
|
||||||
fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n");
|
fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the file size of the local file */
|
/* get the file size of the local file */
|
||||||
hd = open(arg2, O_RDONLY) ;
|
hd = open(libtest_arg2, O_RDONLY) ;
|
||||||
fstat(hd, &file_info);
|
fstat(hd, &file_info);
|
||||||
close(hd) ;
|
close(hd) ;
|
||||||
|
|
||||||
/* get a FILE * of the same file, could also be made with
|
/* get a FILE * of the same file, could also be made with
|
||||||
fdopen() from the previous descriptor, but hey this is just
|
fdopen() from the previous descriptor, but hey this is just
|
||||||
an example! */
|
an example! */
|
||||||
hd_src = fopen(arg2, "rb");
|
hd_src = fopen(libtest_arg2, "rb");
|
||||||
if(NULL == hd_src) {
|
if(NULL == hd_src) {
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||||
error, strerror(error));
|
error, strerror(error));
|
||||||
fprintf(stderr, "Error opening file: %s\n", arg2);
|
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
|
||||||
return TEST_ERR_MAJOR_BAD;
|
return TEST_ERR_MAJOR_BAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ int test(char *URL)
|
|||||||
/* make us re-use the same handle all the time, and try resetting
|
/* make us re-use the same handle all the time, and try resetting
|
||||||
the handle first too */
|
the handle first too */
|
||||||
curl_easy_reset(curl);
|
curl_easy_reset(curl);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, arg2);
|
curl_easy_setopt(curl, CURLOPT_URL, libtest_arg2);
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
|
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ int test(char *URL)
|
|||||||
curl_easy_reset(easy);
|
curl_easy_reset(easy);
|
||||||
|
|
||||||
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1);
|
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1);
|
||||||
curl_easy_setopt(easy, CURLOPT_URL, arg2);
|
curl_easy_setopt(easy, CURLOPT_URL, libtest_arg2);
|
||||||
|
|
||||||
if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
|
if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
|
||||||
printf("curl_multi_add_handle() 2 failed\n");
|
printf("curl_multi_add_handle() 2 failed\n");
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
#define PROXY arg2
|
#define PROXY libtest_arg2
|
||||||
#define PROXYUSERPWD arg3
|
#define PROXYUSERPWD libtest_arg3
|
||||||
#define HOST test_argv[4]
|
#define HOST test_argv[4]
|
||||||
|
|
||||||
static void init(CURLM *cm, const char* url, const char* userpwd,
|
static void init(CURLM *cm, const char* url, const char* userpwd,
|
||||||
|
@ -41,36 +41,36 @@ int test(char *URL)
|
|||||||
struct_stat file_info;
|
struct_stat file_info;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (!arg2) {
|
if (!libtest_arg2) {
|
||||||
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the file size of the local file */
|
/* get the file size of the local file */
|
||||||
hd = stat(arg2, &file_info);
|
hd = stat(libtest_arg2, &file_info);
|
||||||
if(hd == -1) {
|
if(hd == -1) {
|
||||||
/* can't open file, bail out */
|
/* can't open file, bail out */
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
fprintf(stderr, "stat() failed with error: %d %s\n",
|
fprintf(stderr, "stat() failed with error: %d %s\n",
|
||||||
error, strerror(error));
|
error, strerror(error));
|
||||||
fprintf(stderr, "WARNING: cannot open file %s\n", arg2);
|
fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! file_info.st_size) {
|
if(! file_info.st_size) {
|
||||||
fprintf(stderr, "WARNING: file %s has no size!\n", arg2);
|
fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get a FILE * of the same file, could also be made with
|
/* get a FILE * of the same file, could also be made with
|
||||||
fdopen() from the previous descriptor, but hey this is just
|
fdopen() from the previous descriptor, but hey this is just
|
||||||
an example! */
|
an example! */
|
||||||
hd_src = fopen(arg2, "rb");
|
hd_src = fopen(libtest_arg2, "rb");
|
||||||
if(NULL == hd_src) {
|
if(NULL == hd_src) {
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||||
error, strerror(error));
|
error, strerror(error));
|
||||||
fprintf(stderr, "Error opening file: %s\n", arg2);
|
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
|
||||||
return -2; /* if this happens things are major weird */
|
return -2; /* if this happens things are major weird */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
#define TEST_ERR_MAJOR_BAD 100
|
#define TEST_ERR_MAJOR_BAD 100
|
||||||
#define TEST_ERR_RUNS_FOREVER 99
|
#define TEST_ERR_RUNS_FOREVER 99
|
||||||
|
|
||||||
extern char *arg2; /* set by first.c to the argv[2] or NULL */
|
extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */
|
||||||
extern char *arg3; /* set by first.c to the argv[3] or NULL */
|
extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
|
||||||
|
|
||||||
/* argc and argv as passed in to the main() function */
|
/* argc and argv as passed in to the main() function */
|
||||||
extern int test_argc;
|
extern int test_argc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user