aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-02-22 18:57:02 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-02-22 18:57:02 +0000
commitb914e7ed02d7e69cfcc47e8a3f47eaaaf111b4cb (patch)
tree52c8fd0ec865d57fa1744ab6ea683cbdc48f4f64
parentee23d13a79b185f117580773be9c5171097f8311 (diff)
tool_operate: Start to use CURLcode rather than int for return codes
To help assist with the detection of incorrect return codes, as per commits ee23d13a79, 33b8960dc8 and aba98991a5, updated the operate based functions to return CURLcode error codes.
-rw-r--r--src/tool_main.c12
-rw-r--r--src/tool_operate.c15
-rw-r--r--src/tool_operate.h4
3 files changed, 16 insertions, 15 deletions
diff --git a/src/tool_main.c b/src/tool_main.c
index ecf9f9f38..dabd5c95c 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -161,7 +161,7 @@ static void main_free(void)
*/
int main(int argc, char *argv[])
{
- int res;
+ CURLcode result = CURLE_OK;
struct Configurable *config;
main_checkfds();
@@ -182,10 +182,10 @@ int main(int argc, char *argv[])
/* Initialize the curl library - do not call any libcurl functions before
this point */
- res = main_init(config);
- if(!res) {
+ result = main_init(config);
+ if(!result) {
/* Start our curl operation */
- res = operate(config, argc, argv);
+ result = operate(config, argc, argv);
/* Perform the main cleanup */
main_free();
@@ -202,7 +202,7 @@ int main(int argc, char *argv[])
}
else {
helpf(stderr, "error initializing curl\n");
- res = CURLE_FAILED_INIT;
+ result = CURLE_FAILED_INIT;
}
#ifdef __NOVELL_LIBC__
@@ -213,7 +213,7 @@ int main(int argc, char *argv[])
#ifdef __VMS
vms_special_exit(res, vms_show);
#else
- return res;
+ return (int)result;
#endif
}
diff --git a/src/tool_operate.c b/src/tool_operate.c
index b77411bf1..0a3c4f6ac 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -112,7 +112,7 @@ CURLcode curl_easy_perform_ev(CURL *easy);
"If you'd like to turn off curl's verification of the certificate, use\n" \
" the -k (or --insecure) option.\n"
-static int is_fatal_error(int code)
+static bool is_fatal_error(CURLcode code)
{
switch(code) {
/* TODO: Should CURLE_SSL_CACERT be included as critical error ? */
@@ -122,12 +122,13 @@ static int is_fatal_error(int code)
case CURLE_FUNCTION_NOT_FOUND:
case CURLE_BAD_FUNCTION_ARGUMENT:
/* critical error */
- return 1;
+ return TRUE;
default:
break;
}
+
/* no error or not critical */
- return 0;
+ return FALSE;
}
#ifdef __VMS
@@ -202,7 +203,7 @@ static CURLcode operate_init(struct Configurable *config)
return CURLE_OK;
}
-static int operate_do(struct Configurable *config)
+static CURLcode operate_do(struct Configurable *config)
{
char errorbuffer[CURL_ERROR_SIZE];
struct ProgressData progressbar;
@@ -1787,7 +1788,7 @@ static int operate_do(struct Configurable *config)
dumpeasysrc(config);
#endif
- return res;
+ return (CURLcode)res;
}
static void operate_free(struct Configurable *config)
@@ -1801,9 +1802,9 @@ static void operate_free(struct Configurable *config)
clean_metalink(config);
}
-int operate(struct Configurable *config, int argc, argv_item_t argv[])
+CURLcode operate(struct Configurable *config, int argc, argv_item_t argv[])
{
- int result = 0;
+ CURLcode result = CURLE_OK;
/* Initialize the easy interface */
result = operate_init(config);
diff --git a/src/tool_operate.h b/src/tool_operate.h
index 5a0a4a06b..01c5fd42b 100644
--- a/src/tool_operate.h
+++ b/src/tool_operate.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, 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
@@ -23,7 +23,7 @@
***************************************************************************/
#include "tool_setup.h"
-int operate(struct Configurable *config, int argc, argv_item_t argv[]);
+CURLcode operate(struct Configurable *config, int argc, argv_item_t argv[]);
#endif /* HEADER_CURL_TOOL_OPERATE_H */