]> sjero.net Git - wget/blobdiff - src/main.c
[svn] Added string.c module. Updated copyright information and added names of new...
[wget] / src / main.c
index 0fb65f3b655d2f4f2ab3852661d88d0770b07b57..2facb8bd3567fb6da12bf2b3e2cf0fd3f7e0e4ef 100644 (file)
@@ -1,5 +1,5 @@
 /* Command line parsing.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -145,7 +145,7 @@ struct cmdline_option {
     OPT__NO,
     OPT__PARENT,
   } type;
-  void *data;                  /* for standard options */
+  const void *data;            /* for standard options */
   int argtype;                 /* for non-standard options */
 };
 
@@ -216,6 +216,7 @@ struct cmdline_option option_data[] =
     { "post-file", 0, OPT_VALUE, "postfile", -1 },
     { "preserve-permissions", 0, OPT_BOOLEAN, "preservepermissions", -1 },
     { "progress", 0, OPT_VALUE, "progress", -1 },
+    { "protocol-directories", 0, OPT_BOOLEAN, "protocoldirectories", -1 },
     { "proxy", 'Y', OPT_BOOLEAN, "useproxy", -1 },
     { "proxy-passwd", 0, OPT_VALUE, "proxypasswd", -1 },
     { "proxy-user", 0, OPT_VALUE, "proxyuser", -1 },
@@ -475,6 +476,8 @@ Directories:\n"),
   -x,  --force-directories        force creation of directories.\n"),
     N_("\
   -nH, --no-host-directories      don't create host directories.\n"),
+    N_("\
+       --protocol-directories     use protocol name in directories.\n"),
     N_("\
   -P,  --directory-prefix=PREFIX  save files to PREFIX/...\n"),
     N_("\
@@ -547,13 +550,13 @@ HTTPS (SSL) options:\n"),
     N_("\
 FTP options:\n"),
     N_("\
-       --no-remove-listing  don't remove `.listing' files.\n"),
+       --no-remove-listing     don't remove `.listing' files.\n"),
     N_("\
-       --no-glob            turn off FTP file name globbing.\n"),
+       --no-glob               turn off FTP file name globbing.\n"),
     N_("\
-       --passive-ftp        use the \"passive\" transfer mode.\n"),
+       --passive-ftp           use the \"passive\" transfer mode.\n"),
     N_("\
-       --retr-symlinks      when recursing, get linked-to files (not dir).\n"),
+       --retr-symlinks         when recursing, get linked-to files (not dir).\n"),
     N_("\
        --preserve-permissions  preserve remote file permissions.\n"),
     "\n",
@@ -618,9 +621,6 @@ Recursive accept/reject:\n"),
   for (i = 0; i < countof (help); i++)
     fputs (_(help[i]), stdout);
 
-#ifdef WINDOWS
-  ws_help (exec_name);
-#endif
   exit (0);
 }
 
@@ -629,7 +629,7 @@ print_version (void)
 {
   printf ("GNU Wget %s\n\n", version_string);
   fputs (_("\
-Copyright (C) 2003 Free Software Foundation, Inc.\n"), stdout);
+Copyright (C) 2005 Free Software Foundation, Inc.\n"), stdout);
   fputs (_("\
 This program is distributed in the hope that it will be useful,\n\
 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
@@ -658,6 +658,7 @@ main (int argc, char *const *argv)
     ++exec_name;
 
 #ifdef WINDOWS
+  /* Drop extension (typically .EXE) from executable filename. */
   windows_main_junk (&argc, (char **) argv, (char **) &exec_name);
 #endif
 
@@ -671,18 +672,21 @@ main (int argc, char *const *argv)
     {
       int val;
       struct cmdline_option *opt;
-      if (ret == '?')
-       {
-         print_usage ();
-         printf ("\n");
-         printf (_("Try `%s --help' for more options.\n"), exec_name);
-         exit (2);
-       }
 
       /* If LONGINDEX is unchanged, it means RET is referring a short
-        option.  Look it up in the mapping table.  */
+        option.  */
       if (longindex == -1)
-       longindex = optmap[ret - 32];
+       {
+         if (ret == '?')
+           {
+             print_usage ();
+             printf ("\n");
+             printf (_("Try `%s --help' for more options.\n"), exec_name);
+             exit (2);
+           }
+         /* Find the short option character in the mapping.  */
+         longindex = optmap[ret - 32];
+       }
       val = long_options[longindex].val;
 
       /* Use the retrieved value to locate the option in the
@@ -807,12 +811,14 @@ Can't timestamp and not clobber old files at the same time.\n"));
       print_usage ();
       exit (1);
     }
+#ifdef ENABLE_IPV6
   if (opt.ipv4_only && opt.ipv6_only)
     {
       printf (_("Cannot specify both --inet4-only and --inet6-only.\n"));
       print_usage ();
       exit (1);
     }
+#endif
 
   nurl = argc - optind;
   if (!nurl && !opt.input_filename)
@@ -847,12 +853,6 @@ Can't timestamp and not clobber old files at the same time.\n"));
     }
   url[i] = NULL;
 
-  /* Change the title of console window on Windows.  #### I think this
-     statement should belong to retrieve_url().  --hniksic.  */
-#ifdef WINDOWS
-  ws_changetitle (*url, nurl);
-#endif
-
   /* Initialize logging.  */
   log_init (opt.lfilename, append_to_log);
 
@@ -862,19 +862,23 @@ Can't timestamp and not clobber old files at the same time.\n"));
   /* Open the output filename if necessary.  */
   if (opt.output_document)
     {
+      extern FILE *output_stream;
+      extern int output_stream_regular;
+
       if (HYPHENP (opt.output_document))
-       opt.dfp = stdout;
+       output_stream = stdout;
       else
        {
          struct stat st;
-         opt.dfp = fopen (opt.output_document, opt.always_rest ? "ab" : "wb");
-         if (opt.dfp == NULL)
+         output_stream = fopen (opt.output_document,
+                                opt.always_rest ? "ab" : "wb");
+         if (output_stream == NULL)
            {
              perror (opt.output_document);
              exit (1);
            }
-         if (fstat (fileno (opt.dfp), &st) == 0 && S_ISREG (st.st_mode))
-           opt.od_known_regular = 1;
+         if (fstat (fileno (output_stream), &st) == 0 && S_ISREG (st.st_mode))
+           output_stream_regular = 1;
        }
     }
 
@@ -980,9 +984,9 @@ Can't timestamp and not clobber old files at the same time.\n"));
 static RETSIGTYPE
 redirect_output_signal (int sig)
 {
-  char *signal_name = (sig == SIGHUP ? "SIGHUP" :
-                      (sig == SIGUSR1 ? "SIGUSR1" :
-                       "WTF?!"));
+  const char *signal_name = (sig == SIGHUP ? "SIGHUP" :
+                            (sig == SIGUSR1 ? "SIGUSR1" :
+                             "WTF?!"));
   log_request_redirect_output (signal_name);
   progress_schedule_redirect ();
   signal (sig, redirect_output_signal);