]>
Commit | Line | Data |
---|---|---|
5ef1a1e7 | 1 | diff -ur wget-1.8.2.orig/src/init.c wget-1.8.2/src/init.c |
2 | --- wget-1.8.2.orig/src/init.c Wed Jan 15 19:23:23 2003 | |
3 | +++ wget-1.8.2/src/init.c Wed Jan 15 21:54:32 2003 | |
4 | @@ -159,6 +159,7 @@ | |
5 | #endif | |
6 | { "input", &opt.input_filename, cmd_file }, | |
7 | { "killlonger", &opt.kill_longer, cmd_boolean }, | |
8 | + { "lamefs", &opt.lame_fs, cmd_boolean }, | |
9 | { "limitrate", &opt.limit_rate, cmd_bytes }, | |
10 | { "loadcookies", &opt.cookies_input, cmd_file }, | |
11 | { "logfile", &opt.lfilename, cmd_file }, | |
12 | diff -ur wget-1.8.2.orig/src/main.c wget-1.8.2/src/main.c | |
13 | --- wget-1.8.2.orig/src/main.c Wed Jan 15 19:23:23 2003 | |
14 | +++ wget-1.8.2/src/main.c Wed Jan 15 21:52:47 2003 | |
15 | @@ -180,6 +180,7 @@ | |
16 | -Y, --proxy=on/off turn proxy on or off.\n\ | |
17 | -Q, --quota=NUMBER set retrieval quota to NUMBER.\n\ | |
18 | --limit-rate=RATE limit download rate to RATE.\n\ | |
19 | + -f, --lame-fs create files with simple names.\n\ | |
20 | \n"), stdout); | |
21 | #ifdef INET6 | |
22 | fputs (_("\ | |
23 | @@ -276,6 +277,7 @@ | |
24 | { "inet", no_argument, NULL, '4' }, | |
25 | { "inet6", no_argument, NULL, '6' }, | |
26 | #endif | |
27 | + { "lame-fs", no_argument, NULL, 'f' }, | |
28 | { "mirror", no_argument, NULL, 'm' }, | |
29 | { "no-clobber", no_argument, NULL, 141 }, | |
30 | { "no-directories", no_argument, NULL, 147 }, | |
31 | @@ -373,7 +375,7 @@ | |
32 | that the options with required arguments must be followed by a ':'. | |
33 | -- Dan Harkless <wget@harkless.org>] */ | |
34 | while ((c = getopt_long (argc, argv, "\ | |
35 | -hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:", | |
36 | +hpVqvdkKsxmNWrHSLcFbEfY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:C:", | |
37 | long_options, (int *)0)) != EOF) | |
38 | { | |
39 | switch (c) | |
40 | @@ -515,6 +517,9 @@ | |
41 | case 'x': | |
42 | setval ("dirstruct", "on"); | |
43 | break; | |
44 | + case 'f': | |
45 | + setval ("lamefs", "on"); | |
46 | + break; | |
47 | ||
48 | /* Options accepting an argument: */ | |
49 | case 129: | |
50 | diff -ur wget-1.8.2.orig/src/options.h wget-1.8.2/src/options.h | |
51 | --- wget-1.8.2.orig/src/options.h Wed Jan 15 19:23:23 2003 | |
52 | +++ wget-1.8.2/src/options.h Wed Jan 15 21:34:10 2003 | |
53 | @@ -183,6 +183,8 @@ | |
54 | int cookies; | |
55 | char *cookies_input; | |
56 | char *cookies_output; | |
57 | + int lame_fs; /* create files storable on file system with | |
58 | + limited charset */ | |
59 | }; | |
60 | ||
61 | #ifndef OPTIONS_DEFINED_HERE | |
62 | diff -ur wget-1.8.2.orig/src/url.c wget-1.8.2/src/url.c | |
63 | --- wget-1.8.2.orig/src/url.c Wed Jan 15 19:23:23 2003 | |
64 | +++ wget-1.8.2/src/url.c Wed Jan 15 21:55:43 2003 | |
65 | @@ -1389,12 +1389,47 @@ | |
66 | return xstrdup (result); | |
67 | } | |
68 | ||
69 | +/* Modify file name so it can be stored on lame file system such as | |
70 | + * FAT used in some odd operating systems. */ | |
71 | +char * | |
72 | +filename_for_lame_fs(char *name) { | |
73 | + const char allowed_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890/_.-"; | |
74 | + int size_diff = 0; | |
75 | + unsigned char *p1, *p2, *lame_name; | |
76 | + | |
77 | + p1 = name; | |
78 | + while(*p1) { | |
79 | + if(strchr(allowed_chars, *p1) == NULL) | |
80 | + size_diff += 2; | |
81 | + p1++; | |
82 | + } | |
83 | + | |
84 | + lame_name = xmalloc(strlen(name)+size_diff+1); | |
85 | + | |
86 | + p1 = name; | |
87 | + p2 = lame_name; | |
88 | + while(*p1) { | |
89 | + if(strchr(allowed_chars, *p1) == NULL) { | |
90 | + *p2++ = '_'; | |
91 | + *p2++ = XDIGIT_TO_XCHAR (*p1 >> 4); | |
92 | + *p2++ = XDIGIT_TO_XCHAR (*p1 & 0xf); | |
93 | + } else { | |
94 | + *p2 = *p1; | |
95 | + p2++; | |
96 | + } | |
97 | + p1++; | |
98 | + } | |
99 | + *p2 = '\0'; | |
100 | + | |
101 | + return lame_name; | |
102 | +} | |
103 | + | |
104 | /* Create a unique filename, corresponding to a given URL. Calls | |
105 | mkstruct if necessary. Does *not* actually create any directories. */ | |
106 | char * | |
107 | url_filename (const struct url *u) | |
108 | { | |
109 | - char *file, *name; | |
110 | + char *file, *name, *tmp; | |
111 | int have_prefix = 0; /* whether we must prepend opt.dir_prefix */ | |
112 | ||
113 | if (opt.dirstruct) | |
114 | @@ -1408,7 +1444,11 @@ | |
115 | char *query = u->query && *u->query ? u->query : NULL; | |
116 | file = compose_file_name (base, query); | |
117 | } | |
118 | - | |
119 | + if(opt.lame_fs) { | |
120 | + tmp = file; | |
121 | + file = filename_for_lame_fs(file); | |
122 | + /* xfree(tmp); shouldn't we free this? But it segfaults then. */ | |
123 | + } | |
124 | if (!have_prefix) | |
125 | { | |
126 | /* Check whether the prefix directory is something other than "." |