]> sjero.net Git - wget/blobdiff - src/init.c
[svn] New option --protocol-directories.
[wget] / src / init.c
index a92b5e114d2fba846b0d5d955d4a0990a4fa9645..6ece81cd80f5e44a8c5118a2a720ba48ed529f04 100644 (file)
@@ -43,16 +43,6 @@ so, delete this exception statement from your version.  */
 #endif
 #include <errno.h>
 
-#ifdef WINDOWS
-# include <winsock.h>
-#else
-# include <sys/socket.h>
-# include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#endif
-#endif
-
 #ifdef HAVE_PWD_H
 # include <pwd.h>
 #endif
@@ -155,7 +145,7 @@ static struct {
   { "forcehtml",       &opt.force_html,        cmd_boolean },
   { "ftpproxy",                &opt.ftp_proxy,         cmd_string },
   { "glob",            &opt.ftp_glob,          cmd_boolean },
-  { "header",          NULL,                   cmd_spec_header },
+  { "header",          &opt.user_headers,      cmd_spec_header },
   { "htmlextension",   &opt.html_extension,    cmd_boolean },
   { "htmlify",         NULL,                   cmd_spec_htmlify },
   { "httpkeepalive",   &opt.http_keep_alive,   cmd_boolean },
@@ -166,6 +156,10 @@ static struct {
   { "ignorelength",    &opt.ignore_length,     cmd_boolean },
   { "ignoretags",      &opt.ignore_tags,       cmd_vector },
   { "includedirectories", &opt.includes,       cmd_directory_vector },
+#ifdef ENABLE_IPV6
+  { "inet4only",       &opt.ipv4_only,         cmd_boolean },
+  { "inet6only",       &opt.ipv6_only,         cmd_boolean },
+#endif
   { "input",           &opt.input_filename,    cmd_file },
   { "keepsessioncookies", &opt.keep_session_cookies, cmd_boolean },
   { "killlonger",      &opt.kill_longer,       cmd_boolean },
@@ -185,7 +179,9 @@ static struct {
   { "passwd",          &opt.ftp_pass,          cmd_string },
   { "postdata",                &opt.post_data,         cmd_string },
   { "postfile",                &opt.post_file_name,    cmd_file },
+  { "preservepermissions", &opt.preserve_perm, cmd_boolean },
   { "progress",                &opt.progress_type,     cmd_spec_progress },
+  { "protocoldirectories", &opt.protocol_directories, cmd_boolean },
   { "proxypasswd",     &opt.proxy_passwd,      cmd_string },
   { "proxyuser",       &opt.proxy_user,        cmd_string },
   { "quiet",           &opt.quiet,             cmd_boolean },
@@ -559,6 +555,7 @@ static int
 setval_internal (int comind, const char *com, const char *val)
 {
   assert (0 <= comind && comind < countof (commands));
+  DEBUGP (("Setting %s (%d) to %s\n", com, comind, val));
   return ((*commands[comind].action) (com, val, commands[comind].closure));
 }
 
@@ -575,6 +572,7 @@ setval_internal (int comind, const char *com, const char *val)
 void
 setoptval (const char *com, const char *val)
 {
+  assert (val != NULL);
   if (!setval_internal (command_by_name (com), com, val))
     exit (2);
 }
@@ -1043,32 +1041,13 @@ cmd_spec_dirstruct (const char *com, const char *val, void *closure)
 static int
 cmd_spec_header (const char *com, const char *val, void *closure)
 {
-  if (!*val)
-    {
-      /* Empty header means reset headers.  */
-      xfree_null (opt.user_header);
-      opt.user_header = NULL;
-    }
-  else
+  if (!check_user_specified_header (val))
     {
-      int i;
-
-      if (!check_user_specified_header (val))
-       {
-         fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"),
-                  exec_name, com, val);
-         return 0;
-       }
-      i = opt.user_header ? strlen (opt.user_header) : 0;
-      opt.user_header = (char *)xrealloc (opt.user_header, i + strlen (val)
-                                         + 2 + 1);
-      strcpy (opt.user_header + i, val);
-      i += strlen (val);
-      opt.user_header[i++] = '\r';
-      opt.user_header[i++] = '\n';
-      opt.user_header[i] = '\0';
+      fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"),
+              exec_name, com, val);
+      return 0;
     }
-  return 1;
+  return cmd_vector (com, val, closure);
 }
 
 static int
@@ -1306,8 +1285,13 @@ cleanup (void)
 {
   /* Free external resources, close files, etc. */
 
-  if (opt.dfp)
-    fclose (opt.dfp);
+  {
+    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.  */
+  }
 
   /* We're exiting anyway so there's no real need to call free()
      hundreds of times.  Skipping the frees will make Wget exit