]> sjero.net Git - wget/blobdiff - src/main.c
[svn] --delete-after wasn't implemented for files retrieved by FTP or corresponding to
[wget] / src / main.c
index fb72913efd631dea7343430a3e7a4a1c6ecf00af..1218b1d6c0886502b50b5ab15662ee8acda4b006 100644 (file)
@@ -162,6 +162,7 @@ HTTP options:\n\
        --http-user=USER      set http user to USER.\n\
        --http-passwd=PASS    set http password to PASS.\n\
   -C,  --cache=on/off        (dis)allow server-cached data (normally allowed).\n\
+  -E,  --html-extension      save all text/html documents with .html extension.\n\
        --ignore-length       ignore `Content-Length\' header field.\n\
        --header=STRING       insert STRING among the headers.\n\
        --proxy-user=USER     set USER as proxy username.\n\
@@ -171,7 +172,7 @@ HTTP options:\n\
   -U,  --user-agent=AGENT    identify as AGENT instead of Wget/VERSION.\n\
 \n"), _("\
 FTP options:\n\
-       --retr-symlinks   retrieve FTP symbolic links.\n\
+       --retr-symlinks   when recursing, retrieve linked-to files (not dirs).\n\
   -g,  --glob=on/off     turn file name globbing on or off.\n\
        --passive-ftp     use the \"passive\" transfer mode.\n\
 \n"), _("\
@@ -218,12 +219,13 @@ main (int argc, char *const *argv)
     { "backup-converted", no_argument, NULL, 'K' },
     { "debug", no_argument, NULL, 'd' },
     { "dont-remove-listing", no_argument, NULL, 21 },
-    { "email-address", no_argument, NULL, 'E' }, /* undocumented (debug) */
+    { "email-address", no_argument, NULL, 26 }, /* undocumented (debug) */
     { "follow-ftp", no_argument, NULL, 14 },
     { "force-directories", no_argument, NULL, 'x' },
     { "force-hier", no_argument, NULL, 'x' }, /* obsolete */
     { "force-html", no_argument, NULL, 'F'},
     { "help", no_argument, NULL, 'h' },
+    { "html-extension", no_argument, NULL, 'E' },
     { "ignore-length", no_argument, NULL, 10 },
     { "mirror", no_argument, NULL, 'm' },
     { "no-clobber", no_argument, NULL, 13 },
@@ -303,7 +305,7 @@ main (int argc, char *const *argv)
   windows_main_junk (&argc, (char **) argv, (char **) &exec_name);
 #endif
 
-  initialize (); /* sets option defaults; reads the system.wgetrc and .wgetrc */
+  initialize (); /* sets option defaults; reads the system wgetrc and .wgetrc */
 
   /* [Is the order of the option letters significant?  If not, they should be
       alphabetized, like the long_options.  The only thing I know for sure is
@@ -358,6 +360,11 @@ hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:",
        case 22:
          setval ("simplehostcheck", "on");
          break;
+       case 26:
+         /* For debugging purposes.  */
+         printf ("%s\n", ftp_getaddress ());
+         exit (0);
+         break;
        case 'b':
          setval ("background", "on");
          break;
@@ -373,9 +380,7 @@ hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:",
 #endif /* not DEBUG */
          break;
        case 'E':
-         /* For debugging purposes.  */
-         printf ("%s\n", ftp_getaddress ());
-         exit (0);
+         setval ("htmlextension", "on");
          break;
        case 'F':
          setval ("forcehtml", "on");
@@ -428,7 +433,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 (_("\nOriginally written by Hrvoje Niksic <hniksic@iskon.hr>.\n"));
+         printf (_("\nOriginally written by Hrvoje Niksic <hniksic@arsdigita.com>.\n"));
          exit (0);
          break;
        case 'v':
@@ -725,13 +730,23 @@ Can't timestamp and not clobber old files at the same time.\n"));
   /* Retrieve the URLs from argument list.  */
   for (t = url; *t; t++)
     {
-      char *filename, *new_file;
+      char *filename, *redirected_URL;
       int dt;
 
-      status = retrieve_url (*t, &filename, &new_file, NULL, &dt);
+      status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt);
       if (opt.recursive && status == RETROK && (dt & TEXTHTML))
-       status = recursive_retrieve (filename, new_file ? new_file : *t);
-      FREE_MAYBE (new_file);
+       status = recursive_retrieve (filename,
+                                    redirected_URL ? redirected_URL : *t);
+
+      if (opt.delete_after && file_exists_p(filename))
+       {
+         DEBUGP (("Removing file due to --delete-after in main():\n"));
+         logprintf (LOG_VERBOSE, _("Removing %s.\n"), filename);
+         if (unlink (filename))
+           logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
+       }
+
+      FREE_MAYBE (redirected_URL);
       FREE_MAYBE (filename);
     }
 
@@ -758,7 +773,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
                   _("Download quota (%s bytes) EXCEEDED!\n"),
                   legible (opt.quota));
     }
-  if (opt.convert_links)
+  if (opt.convert_links & !opt.delete_after)
     {
       convert_all_links ();
     }