diff -ur wget-1.8.2.orig/src/init.c wget-1.8.2/src/init.c --- wget-1.8.2.orig/src/init.c Wed Jan 15 19:23:23 2003 +++ wget-1.8.2/src/init.c Wed Jan 15 21:54:32 2003 @@ -159,6 +159,7 @@ #endif { "input", &opt.input_filename, cmd_file }, { "killlonger", &opt.kill_longer, cmd_boolean }, + { "lamefs", &opt.lame_fs, cmd_boolean }, { "limitrate", &opt.limit_rate, cmd_bytes }, { "loadcookies", &opt.cookies_input, cmd_file }, { "logfile", &opt.lfilename, cmd_file }, diff -ur wget-1.8.2.orig/src/main.c wget-1.8.2/src/main.c --- wget-1.8.2.orig/src/main.c Wed Jan 15 19:23:23 2003 +++ wget-1.8.2/src/main.c Wed Jan 15 21:52:47 2003 @@ -180,6 +180,7 @@ -Y, --proxy=on/off turn proxy on or off.\n\ -Q, --quota=NUMBER set retrieval quota to NUMBER.\n\ --limit-rate=RATE limit download rate to RATE.\n\ + -f, --lame-fs create files with simple names.\n\ \n"), stdout); #ifdef INET6 fputs (_("\ @@ -276,6 +277,7 @@ { "inet", no_argument, NULL, '4' }, { "inet6", no_argument, NULL, '6' }, #endif + { "lame-fs", no_argument, NULL, 'f' }, { "mirror", no_argument, NULL, 'm' }, { "no-clobber", no_argument, NULL, 141 }, { "no-directories", no_argument, NULL, 147 }, @@ -373,7 +375,7 @@ that the options with required arguments must be followed by a ':'. -- Dan Harkless ] */ 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:", +hpVqvdkKsxmNWrHSLcFbEfY: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) @@ -515,6 +517,9 @@ case 'x': setval ("dirstruct", "on"); break; + case 'f': + setval ("lamefs", "on"); + break; /* Options accepting an argument: */ case 129: diff -ur wget-1.8.2.orig/src/options.h wget-1.8.2/src/options.h --- wget-1.8.2.orig/src/options.h Wed Jan 15 19:23:23 2003 +++ wget-1.8.2/src/options.h Wed Jan 15 21:34:10 2003 @@ -183,6 +183,8 @@ int cookies; char *cookies_input; char *cookies_output; + int lame_fs; /* create files storable on file system with + limited charset */ }; #ifndef OPTIONS_DEFINED_HERE diff -ur wget-1.8.2.orig/src/url.c wget-1.8.2/src/url.c --- wget-1.8.2.orig/src/url.c Wed Jan 15 19:23:23 2003 +++ wget-1.8.2/src/url.c Wed Jan 15 21:55:43 2003 @@ -1389,12 +1389,47 @@ return xstrdup (result); } +/* Modify file name so it can be stored on lame file system such as + * FAT used in some odd operating systems. */ +char * +filename_for_lame_fs(char *name) { + const char allowed_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890/_.-"; + int size_diff = 0; + unsigned char *p1, *p2, *lame_name; + + p1 = name; + while(*p1) { + if(strchr(allowed_chars, *p1) == NULL) + size_diff += 2; + p1++; + } + + lame_name = xmalloc(strlen(name)+size_diff+1); + + p1 = name; + p2 = lame_name; + while(*p1) { + if(strchr(allowed_chars, *p1) == NULL) { + *p2++ = '_'; + *p2++ = XDIGIT_TO_XCHAR (*p1 >> 4); + *p2++ = XDIGIT_TO_XCHAR (*p1 & 0xf); + } else { + *p2 = *p1; + p2++; + } + p1++; + } + *p2 = '\0'; + + return lame_name; +} + /* Create a unique filename, corresponding to a given URL. Calls mkstruct if necessary. Does *not* actually create any directories. */ char * url_filename (const struct url *u) { - char *file, *name; + char *file, *name, *tmp; int have_prefix = 0; /* whether we must prepend opt.dir_prefix */ if (opt.dirstruct) @@ -1408,7 +1444,11 @@ char *query = u->query && *u->query ? u->query : NULL; file = compose_file_name (base, query); } - + if(opt.lame_fs) { + tmp = file; + file = filename_for_lame_fs(file); + /* xfree(tmp); shouldn't we free this? But it segfaults then. */ + } if (!have_prefix) { /* Check whether the prefix directory is something other than "."