Commit bd3dca96 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

somewhat more functioning FTP

parent 3cd77a19
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ else {
    $protocol="HTTP";
}


socket(Server, PF_INET, SOCK_STREAM, $proto)|| die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
           pack("l", 1)) || die "setsockopt: $!";
@@ -40,14 +39,19 @@ sub REAPER {
    logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
}

$commandok{ USER => 'fresh'}; # USER is ok in fresh state

print "TEST: ".$commandok{"USER"}."\n";

# USER is ok in fresh state
%commandok = ( "USER" => "fresh",
               "PASS" => "passwd",
               "PASV" => "loggedin",
               );

$statechange{ 'USER' => 'passwd'}; # USER goes to passwd state
%statechange = ( 'USER' => 'passwd',   # USER goes to passwd state
                 'PASS' => 'loggedin', # PASS goes to loggedin state
                 );

$displaytext{'USER' => '331 We are happy you arrived!'}; # output FTP line
%displaytext = ('USER' => '331 We are happy you popped in!', # output FTP line
                'PASS' => '230 Welcome you silly person',
                );

$SIG{CHLD} = \&REAPER;

@@ -117,10 +121,12 @@ for ( $waitedpid = 0;
                }

                $state=$statechange{$FTPCMD};
                if($command{$1} eq "") {
                    print "314 Wwwwweeeeird internal error\r\n";
                    exit
                if($state eq "") {
                    print "314 Wwwwweeeeird internal error state: $state\r\n";
                    exit;
                }
                print STDERR "gone to state $state\n";

                $text = $displaytext{$FTPCMD};
                print "$text\r\n";
            }