Commit b914e7ed authored by Steve Holme's avatar Steve Holme
Browse files

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 ee23d13a, 33b8960d and aba98991, updated the operate
based functions to return CURLcode error codes.
parent ee23d13a
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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
}

+8 −7
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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 */