aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/w3mman/w3mman.in
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:18:09 +0000
committerTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:18:09 +0000
commit5f8e0f8ef9a422691dd72e8a953a42a41478fcb4 (patch)
tree4b2df4796a534793648b3c4fc532fc36bd0cd525 /scripts/w3mman/w3mman.in
parentReleasing debian version 0.3-2.4 (diff)
downloadw3m-5f8e0f8ef9a422691dd72e8a953a42a41478fcb4.tar.gz
w3m-5f8e0f8ef9a422691dd72e8a953a42a41478fcb4.zip
Releasing debian version 0.5.1-1debian/0.5.1-1
Diffstat (limited to '')
-rw-r--r--scripts/w3mman/w3mman.in41
1 files changed, 41 insertions, 0 deletions
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 <path>] [[<section>] <command>]\n";
+ print STDERR "$_ [-M <path>] [-k <keyword>]\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 .= "&section=" . &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 $_;
+}
+