]> sjero.net Git - wget/blobdiff - src/init.c
[svn] Move extern declarations to .h files.
[wget] / src / init.c
index c81a67bc2cda05d4382b8e2b0a5e1fc9a7abbdff..db2d274233d9bb639c83ece523ecdc38091ab2c2 100644 (file)
@@ -51,6 +51,8 @@ so, delete this exception statement from your version.  */
 #include "recur.h"             /* for INFINITE_RECURSION */
 #include "convert.h"           /* for convert_cleanup */
 #include "res.h"               /* for res_cleanup */
+#include "http.h"              /* for http_cleanup */
+#include "retr.h"              /* for output_stream */
 
 /* We want tilde expansion enabled only when reading `.wgetrc' lines;
    otherwise, it will be performed by the shell.  This variable will
@@ -63,7 +65,7 @@ static bool enable_tilde_expansion;
 
 CMD_DECLARE (cmd_boolean);
 CMD_DECLARE (cmd_bytes);
-CMD_DECLARE (cmd_bytes_large);
+CMD_DECLARE (cmd_bytes_sum);
 #ifdef HAVE_SSL
 CMD_DECLARE (cmd_cert_type);
 #endif
@@ -89,6 +91,7 @@ CMD_DECLARE (cmd_spec_secure_protocol);
 #endif
 CMD_DECLARE (cmd_spec_timeout);
 CMD_DECLARE (cmd_spec_useragent);
+CMD_DECLARE (cmd_spec_verbose);
 
 /* List of recognized commands, each consisting of name, place and
    function.  When adding a new command, simply add it to the list,
@@ -199,7 +202,7 @@ static struct {
   { "proxypassword",   &opt.proxy_passwd,      cmd_string },
   { "proxyuser",       &opt.proxy_user,        cmd_string },
   { "quiet",           &opt.quiet,             cmd_boolean },
-  { "quota",           &opt.quota,             cmd_bytes_large },
+  { "quota",           &opt.quota,             cmd_bytes_sum },
 #ifdef HAVE_SSL
   { "randomfile",      &opt.random_file,       cmd_file },
 #endif
@@ -230,7 +233,7 @@ static struct {
   { "useproxy",                &opt.use_proxy,         cmd_boolean },
   { "user",            &opt.user,              cmd_string },
   { "useragent",       NULL,                   cmd_spec_useragent },
-  { "verbose",         &opt.verbose,           cmd_boolean },
+  { "verbose",         NULL,                   cmd_spec_verbose },
   { "wait",            &opt.wait,              cmd_time },
   { "waitretry",       &opt.waitretry,         cmd_time }
 };
@@ -861,7 +864,7 @@ cmd_directory_vector (const char *com, const char *val, void *place)
   return true;
 }
 
-/* Engine for cmd_bytes and cmd_bytes_large: converts a string such as
+/* Engine for cmd_bytes and cmd_bytes_sum: converts a string such as
    "100k" or "2.5G" to a floating point number.  */
 
 static bool
@@ -947,12 +950,12 @@ cmd_bytes (const char *com, const char *val, void *place)
 }
 
 /* Like cmd_bytes, but PLACE is interpreted as a pointer to
-   LARGE_INT.  It works by converting the string to double, therefore
+   SIZE_SUM.  It works by converting the string to double, therefore
    working with values up to 2^53-1 without loss of precision.  This
    value (8192 TB) is large enough to serve for a while.  */
 
 static bool
-cmd_bytes_large (const char *com, const char *val, void *place)
+cmd_bytes_sum (const char *com, const char *val, void *place)
 {
   double byte_value;
   if (!parse_bytes_helper (val, &byte_value))
@@ -961,7 +964,7 @@ cmd_bytes_large (const char *com, const char *val, void *place)
               exec_name, com, val);
       return false;
     }
-  *(LARGE_INT *)place = (LARGE_INT)byte_value;
+  *(SUM_SIZE_INT *) place = (SUM_SIZE_INT) byte_value;
   return true;
 }
 
@@ -1254,6 +1257,22 @@ cmd_spec_useragent (const char *com, const char *val, void *place_ignored)
   opt.useragent = xstrdup (val);
   return true;
 }
+
+/* The "verbose" option cannot be cmd_boolean because the variable is
+   not bool -- it's of type int (-1 means uninitialized because of
+   some random hackery for disallowing -q -v).  */
+
+static bool
+cmd_spec_verbose (const char *com, const char *val, void *place_ignored)
+{
+  bool flag;
+  if (cmd_boolean (com, val, &flag))
+    {
+      opt.verbose = flag;
+      return true;
+    }
+  return false;
+}
 \f
 /* Miscellaneous useful routines.  */
 
@@ -1398,7 +1417,6 @@ decode_string (const char *val, const struct decode_item *items, int itemcount,
 
 \f
 void cleanup_html_url (void);
-void http_cleanup (void);
 
 
 /* Free the memory allocated by global variables.  */
@@ -1407,13 +1425,10 @@ cleanup (void)
 {
   /* Free external resources, close files, etc. */
 
-  {
-    extern FILE *output_stream;
-    if (output_stream)
-      fclose (output_stream);
-    /* No need to check for error because Wget flushes its output (and
-       checks for errors) after any data arrives.  */
-  }
+  if (output_stream)
+    fclose (output_stream);
+  /* No need to check for error because Wget flushes its output (and
+     checks for errors) after any data arrives.  */
 
   /* We're exiting anyway so there's no real need to call free()
      hundreds of times.  Skipping the frees will make Wget exit