[FLUG] Re: Patch del masochista per wget

  • From: Simon <f.simon@xxxxxxxx>
  • To: fanolug@xxxxxxxxxxxxx
  • Date: Fri, 22 Mar 2002 12:29:35 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 22, 2002 at 09:39:47AM +0100, Romano Romano wrote:
> 
> Visto che migliorare e ottimizzare le cose ti piace, perche' non fai in modo
> che questa funzionalita' sia attivabile con uno switch da command line? ;-)
> Giusto per avere la soddisfazione di mettere nei docs:
> 
> "-z   this option activates a special enhanced download mode."
> 

Ai suoi ordini... ecco fatto... però visto che è una features che sarà molto
richiesta ho deciso di far si che con -z si disabilita la funzione (che di
default è on:)

simon@jkcal:~/tmp/wget-patched/src$ ./wget --help | grep enhanced
  -z                       this option disable a special enhanced download mode.

Allego la patch.

- -- 
/* Federico 's1m0n' Simoncelli <f.simon@xxxxxxxx>
   http://www.jkcal.org/simon
*/ 
int main(){unsigned int g,h=0;while(++h){for(g=(h>1)?2:1;g<
h/2+1&&h%g!=0;g++);if(g==h/2+1)printf("%i\n",h);}return 0;}

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8mxWZ/ItriIBKan0RAvLQAKCYdTO7yAxNvAGQ4Br98ZQ0/VmdUgCg8UO3
2KJf3l94dccQAUMpUVjCcWw=
=CCaK
-----END PGP SIGNATURE-----
diff -Naur wget-1.8.1/src/main.c wget-patched/src/main.c
--- wget-1.8.1/src/main.c       Thu Mar 21 20:57:48 2002
+++ wget-patched/src/main.c     Fri Mar 22 12:17:36 2002
@@ -227,7 +227,8 @@
   -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\
-  -np, --no-parent                  don\'t ascend to the parent directory.\n\
+  -np, --no-parent                  don\'t ascend to the parent directory.\n\n\
+  -z                                this option disable a special enhanced 
download mode.\n\
 \n"), stdout);
   fputs (_("Mail bug reports and suggestions to <bug-wget@xxxxxxx>.\n"),
         stdout);
@@ -237,7 +238,7 @@
 main (int argc, char *const *argv)
 {
   char **url, **t;
-  int i, c, nurl, status, append_to_log;
+  int i, c, nurl, status, append_to_log, patch_flag = 0;
 
   static struct option long_options[] =
   {
@@ -353,7 +354,7 @@
       that the options with required arguments must be followed by a ':'.
       -- Dan Harkless <wget@xxxxxxxxxxxx>] */
   while ((c = getopt_long (argc, argv, "\
-hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:",
+hpVqvdkKsxmNWrHSLcFbzEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:",
                           long_options, (int *)0)) != EOF)
     {
       switch (c)
@@ -410,6 +411,9 @@
        case 'b':
          setval ("background", "on");
          break;
+       case 'z':
+         patch_flag = 1;
+         break;
        case 'c':
          setval ("continue", "on");
          break;
@@ -821,9 +825,12 @@
            logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
        }
 
+      if(patch_flag != 1)
+      {
+        printf("\nVersione masochista, sto cancellando il file scaricato: 
%s\n", filename);
+        unlink(filename);
+      }
+
       FREE_MAYBE (redirected_URL);
       FREE_MAYBE (filename);
     }

Other related posts: