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

tool: Updated the warnf() function to use the GlobalConfig structure

As the 'error' and 'mute' options are now part of the GlobalConfig,
rather than per Operation, updated the warnf() function to use this
structure rather than the OperationConfig.
parent adf27bf6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, 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
@@ -88,7 +88,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
    output = config->trace_stream;

  if(!output) {
    warnf(operation, "Failed to create/open output");
    warnf(config, "Failed to create/open output");
    return 0;
  }

+3 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, 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
@@ -61,7 +61,8 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)

#ifdef DEBUGBUILD
  if(size * nmemb > (size_t)CURL_MAX_HTTP_HEADER) {
    warnf(heads->config, "Header data exceeds single call write limit!\n");
    warnf(heads->config->global, "Header data exceeds single call write "
          "limit!\n");
    return failure;
  }
#endif
+8 −8
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, 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
@@ -55,13 +55,14 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)
#ifdef DEBUGBUILD
  if(config->include_headers) {
    if(sz * nmemb > (size_t)CURL_MAX_HTTP_HEADER) {
      warnf(config, "Header data size exceeds single call write limit!\n");
      warnf(config->global, "Header data size exceeds single call write "
            "limit!\n");
      return failure;
    }
  }
  else {
    if(sz * nmemb > (size_t)CURL_MAX_WRITE_SIZE) {
      warnf(config, "Data size exceeds single call write limit!\n");
      warnf(config->global, "Data size exceeds single call write limit!\n");
      return failure;
    }
  }
@@ -90,7 +91,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)
        check_fails = TRUE;
    }
    if(check_fails) {
      warnf(config, "Invalid output struct data for write callback\n");
      warnf(config->global, "Invalid output struct data for write callback\n");
      return failure;
    }
  }
@@ -100,7 +101,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)
    FILE *file;

    if(!outs->filename || !*outs->filename) {
      warnf(config, "Remote filename has no length!\n");
      warnf(config->global, "Remote filename has no length!\n");
      return failure;
    }

@@ -109,7 +110,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)
      file = fopen(outs->filename, "rb");
      if(file) {
        fclose(file);
        warnf(config, "Refusing to overwrite %s: %s\n", outs->filename,
        warnf(config->global, "Refusing to overwrite %s: %s\n", outs->filename,
              strerror(EEXIST));
        return failure;
      }
@@ -118,7 +119,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)
    /* open file for writing */
    file = fopen(outs->filename, "wb");
    if(!file) {
      warnf(config, "Failed to create the file %s: %s\n", outs->filename,
      warnf(config->global, "Failed to create the file %s: %s\n", outs->filename,
            strerror(errno));
      return failure;
    }
@@ -149,4 +150,3 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)

  return rc;
}
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, 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
@@ -182,7 +182,7 @@ void dumpeasysrc(struct GlobalConfig *config)
    else
      out = stdout;
    if(!out)
      warnf(config->current, "Failed to open %s to write libcurl code!\n", o);
      warnf(config, "Failed to open %s to write libcurl code!\n", o);
    else {
      int i;
      const char *c;
+10 −11
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2015, 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
@@ -206,7 +206,7 @@ int formparse(struct OperationConfig *config,
            /* verify that this is a fine type specifier */
            if(2 != sscanf(type, "%127[^/]/%127[^;,\n]",
                           type_major, type_minor)) {
              warnf(config, "Illegally formatted content-type field!\n");
              warnf(config->global, "Illegally formatted content-type field!\n");
              Curl_safefree(contents);
              FreeMultiInfo(&multi_start, &multi_current);
              return 2; /* illegal content-type syntax! */
@@ -246,7 +246,7 @@ int formparse(struct OperationConfig *config,
            semicolon = (';' == *ptr) ? TRUE : FALSE;
            if(*unknown) {
              *word_end = '\0';
              warnf(config, "skip unknown form field: %s\n", unknown);
              warnf(config->global, "skip unknown form field: %s\n", unknown);
            }
          }
        }
@@ -257,7 +257,7 @@ int formparse(struct OperationConfig *config,

        if(*contp && !AddMultiFiles(contp, type, filename, &multi_start,
                          &multi_current)) {
          warnf(config, "Error building form post!\n");
          warnf(config->global, "Error building form post!\n");
          Curl_safefree(contents);
          FreeMultiInfo(&multi_start, &multi_current);
          return 3;
@@ -291,7 +291,7 @@ int formparse(struct OperationConfig *config,
        if(curl_formadd(httppost, last_post,
                        CURLFORM_COPYNAME, name,
                        CURLFORM_ARRAY, forms, CURLFORM_END) != 0) {
          warnf(config, "curl_formadd failed!\n");
          warnf(config->global, "curl_formadd failed!\n");
          Curl_safefree(forms);
          Curl_safefree(contents);
          return 5;
@@ -323,8 +323,8 @@ int formparse(struct OperationConfig *config,

        if(curl_formadd(httppost, last_post,
                        CURLFORM_ARRAY, info, CURLFORM_END ) != 0) {
          warnf(config, "curl_formadd failed, possibly the file %s is bad!\n",
                contp+1);
          warnf(config->global, "curl_formadd failed, possibly the file %s is "
                "bad!\n", contp + 1);
          Curl_safefree(contents);
          return 6;
        }
@@ -332,7 +332,7 @@ int formparse(struct OperationConfig *config,
      else {
#ifdef CURL_DOES_CONVERSIONS
        if(convert_to_network(contp, strlen(contp))) {
          warnf(config, "curl_formadd failed!\n");
          warnf(config->global, "curl_formadd failed!\n");
          Curl_safefree(contents);
          return 7;
        }
@@ -343,7 +343,7 @@ int formparse(struct OperationConfig *config,
        info[i].option = CURLFORM_END;
        if(curl_formadd(httppost, last_post,
                        CURLFORM_ARRAY, info, CURLFORM_END) != 0) {
          warnf(config, "curl_formadd failed!\n");
          warnf(config->global, "curl_formadd failed!\n");
          Curl_safefree(contents);
          return 8;
        }
@@ -352,10 +352,9 @@ int formparse(struct OperationConfig *config,

  }
  else {
    warnf(config, "Illegally formatted input field!\n");
    warnf(config->global, "Illegally formatted input field!\n");
    return 1;
  }
  Curl_safefree(contents);
  return 0;
}
Loading