From 72f72d64a422d6628c4796f5c0bf2e508f134214 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:05:14 +0900 Subject: Adding upstream version 0.5.1 --- scripts/w3mman/w3mman.in | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/w3mman/w3mman.in (limited to 'scripts/w3mman/w3mman.in') diff --git a/scripts/w3mman/w3mman.in b/scripts/w3mman/w3mman.in new file mode 100644 index 0000000..6c6f65d --- /dev/null +++ b/scripts/w3mman/w3mman.in @@ -0,0 +1,41 @@ +#!@PERL@ + +@W3M = split(' ', $ENV{'W3MMAN_W3M'} || '@W3M@'); +$ENV{'W3MMAN_MAN'} ||= '@MAN@'; +$SCRIPT = 'file:///$LIB/w3mman2html.cgi'; + +sub usage { + ($_ = $0) =~ s@.*/@@; + print STDERR "$_ [-M ] [[
] ]\n"; + print STDERR "$_ [-M ] [-k ]\n"; + exit 1; +} + +$query = ""; +while (@ARGV) { + $_ = shift @ARGV; + if (/^-M$/) { + @ARGV || &usage(); + $ENV{'MANPATH'} = shift @ARGV; + } elsif (/^-k$/) { + @ARGV || &usage(); + $query = "?keyword=" . &form_encode(shift @ARGV); + } elsif (/^-/) { + &usage(); + } elsif (/^\d/ || $_ eq 'n') { + @ARGV || &usage(); + $query = "?quit=ok&man=" . &form_encode(shift @ARGV); + $query .= "§ion=" . &form_encode($_); + } else { + $query = "?quit=ok&man=" . &form_encode($_); + } +} + +exec @W3M, "$SCRIPT$query"; + +sub form_encode { + local($_) = @_; + s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; + return $_; +} + -- cgit v1.2.3