1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
21 ###########################################################################
24 'content' => "This file should have permissions 444\n",
25 'perm' => 'r--r--r--',
26 'time' => 'Jan 11 10:00',
27 'dostime' => '01-11-10 10:00AM',
32 'content' => "This file should have permissions 666\n",
33 'perm' => 'rw-rw-rw-',
34 'time' => 'Feb 1 8:00',
35 'dostime' => '02-01-10 08:00AM',
40 'content' => "This file should have permissions 777\n",
41 'perm' => 'rwxrwxrwx',
42 'time' => 'Feb 1 8:00',
43 'dostime' => '02-01-10 08:00AM',
49 'content' => "This file should have permissions 001\n",
50 'perm' => '--S--S--t',
51 'time' => 'May 4 4:31',
52 'dostime' => '05-04-10 04:31AM'
58 'content' => "This file should have permissions 110\n",
59 'perm' => '--s--s--T',
60 'time' => 'May 4 4:31',
61 'dostime' => '05-04-10 04:31AM'
66 'name' => 'link -> file.txt',
68 'perm' => 'rwxrwxrwx',
69 'time' => 'Jan 6 4:42'
72 %link_link_absolute = (
74 'name' => 'link_absolute -> /data/ftp/file.txt',
76 'perm' => 'rwxrwxrwx',
77 'time' => 'Jan 6 4:45'
84 'time' => "Apr 27 5:12",
86 'dostime' => "04-27-10 05:12AM",
95 'time' => "Apr 23 3:12",
96 'dostime' => "04-23-10 03:12AM",
100 %dir_weirddir_txt = (
102 'name' => "weirddir.txt",
105 'time' => "Apr 23 3:12",
106 'dostime' => "04-23-10 03:12AM",
107 'perm' => "rwxr-xrwx"
115 'time' => "Nov 01 2008",
116 'dostime' => "11-01-08 11:11AM",
117 'perm' => "rwx--x--x"
125 'time' => "Nov 01 2008",
126 'dostime' => "11-01-08 11:11AM",
127 'perm' => "rwx--x--x"
135 'time' => "Jan 23 2:05",
136 'dostime' => "01-23-05 02:05AM",
137 'perm' => "rwxrwxrwx"
140 %file_empty_file_dat = (
141 'name' => "empty_file.dat",
143 'perm' => "rw-r--r--",
144 'time' => "Apr 27 11:01",
145 'dostime' => "04-27-10 11:01AM"
149 'name' => "file.txt",
150 'content' => "This is content of file \"file.txt\"\n",
151 'time' => "Apr 27 11:01",
152 'dostime' => "04-27-10 11:01AM",
153 'perm' => "rw-r--r--"
156 %file_someothertext_txt = (
157 'name' => "someothertext.txt",
158 'content' => "Some junk ;-) This file does not really exist.\n",
159 'time' => "Apr 27 11:01",
160 'dostime' => "04-27-10 11:01AM",
161 'perm' => "rw-r--r--"
165 '/fully_simulated/' => {
166 'files' => [ \%dir_dot, \%dir_ddot, \%dir_DOS, \%dir_UNIX ],
170 '/fully_simulated/UNIX/' => {
171 'files' => [ \%dir_dot, \%dir_ddot,
172 \%file_chmod1, \%file_chmod2, \%file_chmod3, \%file_chmod4, \%file_chmod5,
173 \%file_empty_file_dat, \%file_file_txt,
174 \%link_link, \%link_link_absolute, \%dir_dot_NeXT,
175 \%file_someothertext_txt, \%dir_weirddir_txt ],
179 '/fully_simulated/DOS/' => {
180 'files' => [ \%dir_dot, \%dir_ddot,
181 \%file_chmod1, \%file_chmod2, \%file_chmod3, \%file_chmod4, \%file_chmod5,
182 \%file_empty_file_dat, \%file_file_txt,
183 \%dir_dot_NeXT, \%file_someothertext_txt, \%dir_weirddir_txt ],
189 sub ftp_createcontent($) {
192 $type = $$list{'type'};
193 $eol = $$list{'eol'};
194 $list_ref = $$list{'files'};
198 if($type eq "unix") {
202 my $ftype = $file{'type'} ? $file{'type'} : "-";
203 my $fperm = $file{'perm'} ? $file{'perm'} : "rwxr-xr-x";
204 my $fuser = $file{'user'} ? sprintf("%15s", $file{'user'}) : "ftp-default";
205 my $fgroup = $file{'group'} ? sprintf("%15s", $file{'group'}) : "ftp-default";
207 if($file{'type'} eq "d") {
208 $fsize = $file{'size'} ? sprintf("%7s", $file{'size'}) : sprintf("%7d", 4096);
211 $fsize = sprintf("%7d", length $file{'content'});
213 my $fhlink = $file{'hlink'} ? sprintf("%4d", $file{'hlink'}) : " 1";
214 my $ftime = $file{'time'} ? sprintf("%10s", $file{'time'}) : "Jan 9 1933";
215 push(@contentlist, "$ftype$fperm $fhlink $fuser $fgroup $fsize $ftime $file{'name'}$eol");
220 elsif($type =~ /^dos$/) {
224 my $time = $file{'dostime'} ? $file{'dostime'} : "06-25-97 09:12AM";
226 if($file{'type'} =~ /^d$/) {
227 $size_or_dir = " <DIR> ";
230 $size_or_dir = sprintf("%20d", length $file{'content'});
232 push(@contentlist, "$time $size_or_dir $file{'name'}$eol");
238 sub wildcard_filesize($$) {
239 my ($list_type, $file) = @_;
240 $list = $lists{$list_type};
242 my $files = $list->{'files'};
245 if ($f{'name'} eq $file) {
247 return length $f{'content'};
249 elsif ($f{'type'} ne "d"){
260 sub wildcard_getfile($$) {
261 my ($list_type, $file) = @_;
262 $list = $lists{$list_type};
264 my $files = $list->{'files'};
267 if ($f{'name'} eq $file) {
269 return (length $f{'content'}, $f{'content'});
271 elsif ($f{'type'} ne "d"){
283 sub ftp_contentlist {
284 my $listname = $_[0];
285 $list = $lists{$listname};
286 return ftp_createcontent(\$list);