# gopher.pl - an incomplete gopher gateway # # Sven Rudolph (sr1@irz.inf.tu-dresden.de) # $Id: gopher.pl,v 1.19 1993/11/17 17:16:49 www Exp www $ # # The plexus 3.0 license ( see the file NOTICE) applies. # # the local.conf entries : # set gopher_use_forms 0 # use
\n"; if ($descr =~ /^.\/$/) { print "\n"; if ($debug) { print "
\n";
print "Address: $thathost Port: $thatport, Type : $itemtype , ";
print "Itemflag : $itemflag \n";
print "Description : $descr \n";
print "Queries : $query\n" if $itemflag eq "?";
print "\n\n";
}
}
sub read_directory {
print "";
print "\n"; # print "State : $state
\n"; if ($state == $state_pending) { # no views specified @views = (" "); &print_anchor(); } elsif ($state == $state_views) { if ($#views == 0) { # one view specified # @views = (" $view: "); &print_anchor(); } else { # multiple views specified &print_anchor(); } } &split_selector($rest); $state = $state_pending; $reading_views = 0; @views = (); } elsif ($key eq "VIEWS") { $state = $state_views; $reading_views = 1; } else { $reading_views = 0; } } else { if ( ( $reading_views ) && ( ($state == $state_views) || ($state == $state_pending) ) ) { ($line) = $line =~ /^ *([^:]*)/; unshift(@views, $line); # print "view : $line
"; } else { # print "data : $line
"; } } # print "
\n"; } } print "
\n";
print &encapsulate_for_html($title) . "\n (";
foreach $view (@views) {
$pview = &encapsulate_for_url($view);
($gopher_view,$gopher_language) = split(/ /,$view);
print "";
print &gopher2description($gopher_view) ;
print ",";
print &gopher2language($gopher_language) ;
print "; ";
}
print ")\n";
}
}
sub connect_to_gopher {
local($this) = pack($sockaddr, &main'AF_INET, 0, $thisaddr);
local($that) = pack($sockaddr, &main'AF_INET, $thatport, $thataddr);
socket(FS, &main'AF_INET, &main'SOCK_STREAM, $proto) ||
&error('internal_error', "socket: $!");
bind(FS, $this) || &main'error('internal_error', "bind: $!");
#connect to gopher server
connect(FS, $that) || &main'error('internal_error', "connect 1: $!");
select((select(FS), $| = 1)[0]);
};
sub get_gopher_views {
local($itmeflag, $descr) = @_;
local($a, @gopher_views);
if ( $itemflag ne "+") { # no gopher+
@gopher_views = ();
} else {
print FS "$descr\t!\n";
while (