]> sjero.net Git - wget/blobdiff - src/main.c
[svn] hniksic@srce.hr -> hniksic@iskon.hr
[wget] / src / main.c
index 65d5f6ac1eae9d2a88c78d40af0905bfec0b743a..f96d2ebfb596ee7e08455aa9e309758ee5b70420 100644 (file)
@@ -87,7 +87,11 @@ i18n_initialize (void)
      things up.  For example, when in a foreign locale, Solaris
      strptime() fails to handle international dates correctly, which
      makes http_atotm() malfunction.  */
+#ifdef LC_MESSAGES
   setlocale (LC_MESSAGES, "");
+#else
+  setlocale (LC_ALL, "");
+#endif
   /* Set the text message domain.  */
   bindtextdomain ("wget", LOCALEDIR);
   textdomain ("wget");
@@ -142,6 +146,7 @@ Download:\n\
        --spider                 don\'t download anything.\n\
   -T,  --timeout=SECONDS        set the read timeout to SECONDS.\n\
   -w,  --wait=SECONDS           wait SECONDS between retrievals.\n\
+       --waitretry=SECONDS     wait 0..max SECONDS between retries of a retrieval.\n\
   -Y,  --proxy=on/off           turn proxy on or off.\n\
   -Q,  --quota=NUMBER           set retrieval quota to NUMBER.\n\
 \n"),  _("\
@@ -178,13 +183,15 @@ Recursive retrieval:\n\
   -nr, --dont-remove-listing   don\'t remove `.listing\' files.\n\
 \n"), _("\
 Recursive accept/reject:\n\
-  -A,  --accept=LIST                list of accepted extensions.\n\
-  -R,  --reject=LIST                list of rejected extensions.\n\
-  -D,  --domains=LIST               list of accepted domains.\n\
+  -A,  --accept=LIST                comma-separated list of accepted extensions.\n\
+  -R,  --reject=LIST                comma-separated list of rejected extensions.\n\
+  -D,  --domains=LIST               comma-separated list of accepted domains.\n\
        --exclude-domains=LIST       comma-separated list of rejected domains.\n\
-  -L,  --relative                   follow relative links only.\n\
        --follow-ftp                 follow FTP links from HTML documents.\n\
+       --follow-tags=LIST           comma-separated list of followed HTML tags.\n\
+  -G,  --ignore-tags=LIST           comma-separated list of ignored HTML tags.\n\
   -H,  --span-hosts                 go to foreign hosts when recursive.\n\
+  -L,  --relative                   follow relative links only.\n\
   -I,  --include-directories=LIST   list of allowed directories.\n\
   -X,  --exclude-directories=LIST   list of excluded directories.\n\
   -nh, --no-host-lookup             don\'t DNS-lookup hosts.\n\
@@ -197,9 +204,11 @@ main (int argc, char *const *argv)
 {
   char **url, **t;
   int i, c, nurl, status, append_to_log;
+  int wr = 0;
 
   static struct option long_options[] =
   {
+    /* Options without arguments: */
     { "background", no_argument, NULL, 'b' },
     { "continue", no_argument, NULL, 'c' },
     { "convert-links", no_argument, NULL, 'k' },
@@ -233,6 +242,7 @@ main (int argc, char *const *argv)
     { "verbose", no_argument, NULL, 'v' },
     { "version", no_argument, NULL, 'V' },
 
+    /* Options accepting an argument: */
     { "accept", required_argument, NULL, 'A' },
     { "append-output", required_argument, NULL, 'a' },
     { "backups", required_argument, NULL, 23 }, /* undocumented */
@@ -246,11 +256,13 @@ main (int argc, char *const *argv)
     { "execute", required_argument, NULL, 'e' },
     { "exclude-directories", required_argument, NULL, 'X' },
     { "exclude-domains", required_argument, NULL, 12 },
+    { "follow-tags", required_argument, NULL, 25 },
     { "glob", required_argument, NULL, 'g' },
     { "header", required_argument, NULL, 3 },
     { "htmlify", required_argument, NULL, 7 },
     { "http-passwd", required_argument, NULL, 2 },
     { "http-user", required_argument, NULL, 1 },
+    { "ignore-tags", required_argument, NULL, 'G' },
     { "include-directories", required_argument, NULL, 'I' },
     { "input-file", required_argument, NULL, 'i' },
     { "level", required_argument, NULL, 'l' },
@@ -265,8 +277,10 @@ main (int argc, char *const *argv)
     { "timeout", required_argument, NULL, 'T' },
     { "tries", required_argument, NULL, 't' },
     { "user-agent", required_argument, NULL, 'U' },
+    { "referer", required_argument, NULL, 129 }, /* undocumented */
     { "use-proxy", required_argument, NULL, 'Y' },
     { "wait", required_argument, NULL, 'w' },
+    { "waitretry", required_argument, NULL, 24 }, /* partially undocumented */
     { 0, 0, 0, 0 }
   };
 
@@ -288,7 +302,7 @@ main (int argc, char *const *argv)
   initialize ();
 
   while ((c = getopt_long (argc, argv, "\
-hVqvdkKsxmNWrHSLcFbEY:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:",
+hVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:",
                           long_options, (int *)0)) != EOF)
     {
       switch (c)
@@ -368,12 +382,12 @@ hVqvdkKsxmNWrHSLcFbEY:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:",
 #endif
          exit (0);
          break;
-       case 'k':
-         setval ("convertlinks", "on");
-         break;
        case 'K':
          setval ("backupconverted", "on");
          break;
+       case 'k':
+         setval ("convertlinks", "on");
+         break;
        case 'L':
          setval ("relativeonly", "on");
          break;
@@ -403,7 +417,7 @@ This program is distributed in the hope that it will be useful,\n\
 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\
 GNU General Public License for more details.\n"));
-         printf (_("\nWritten by Hrvoje Niksic <hniksic@srce.hr>.\n"));
+         printf (_("\nOriginally written by Hrvoje Niksic <hniksic@iskon.hr>.\n"));
          exit (0);
          break;
        case 'v':
@@ -441,6 +455,16 @@ GNU General Public License for more details.\n"));
        case 23:
          setval ("backups", optarg);
          break;
+       case 24:
+         setval ("waitretry", optarg);
+         wr = 1;
+         break;
+       case 25:
+         setval ("followtags", optarg);
+         break;
+       case 129:
+         setval ("referer", optarg);
+         break;
        case 'A':
          setval ("accept", optarg);
          break;
@@ -475,6 +499,9 @@ GNU General Public License for more details.\n"));
            free (val);
          }
          break;
+       case 'G':
+         setval ("ignoretags", optarg);
+         break;
        case 'g':
          setval ("glob", optarg);
          break;
@@ -570,6 +597,18 @@ GNU General Public License for more details.\n"));
   if (opt.verbose == -1)
     opt.verbose = !opt.quiet;
 
+  /* Retain compatibility with previous scripts.
+     if wait has been set, but waitretry has not, give it the wait value.
+     A simple check on the values is not enough, I could have set
+     wait to n>0 and waitretry to 0 - HEH */
+  if (opt.wait && !wr)
+    {
+      char  opt_wait_str[256];  /* bigger than needed buf to prevent overflow */
+
+      sprintf(opt_wait_str, "%ld", opt.wait);
+      setval ("waitretry", opt_wait_str);
+    }
+    
   /* Sanity checks.  */
   if (opt.verbose && opt.quiet)
     {