w3mman.in (1120B)
1 #!@PERL@ 2 3 @W3M = split(' ', $ENV{'W3MMAN_W3M'} || '@W3M@'); 4 $ENV{'W3MMAN_MAN'} ||= '@MAN@'; 5 $SCRIPT = 'file:///$LIB/w3mman2html.cgi'; 6 7 sub usage { 8 ($_ = $0) =~ s@.*/@@; 9 print STDERR "$_ [-M <path>] [[<section>] <command>]\n"; 10 print STDERR "$_ [-M <path>] [-k <keyword>]\n"; 11 print STDERR "$_ [-l <file>]\n"; 12 exit 1; 13 } 14 15 $query = ""; 16 while (@ARGV) { 17 $_ = shift @ARGV; 18 if (/^-M$/) { 19 @ARGV || &usage(); 20 $ENV{'MANPATH'} = shift @ARGV; 21 } elsif (/^-k$/) { 22 @ARGV || &usage(); 23 $query = "?keyword=" . &form_encode(shift @ARGV); 24 } elsif (/^-l$/) { 25 @ARGV || &usage(); 26 $query = "?quit=ok&local=" . &form_encode(shift @ARGV); 27 $query .= "&pwd=" . &form_encode($ENV{'PWD'}); 28 } elsif (/^-/) { 29 &usage(); 30 } elsif (/^\d/ || $_ eq 'n') { 31 @ARGV || &usage(); 32 $query = "?quit=ok&man=" . &form_encode(shift @ARGV); 33 $query .= "§ion=" . &form_encode($_); 34 } else { 35 $query = "?quit=ok&man=" . &form_encode($_); 36 } 37 } 38 39 exec @W3M, "$SCRIPT$query"; 40 41 sub form_encode { 42 local($_) = @_; 43 s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; 44 return $_; 45 } 46