aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
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
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/.cvsignore9
-rw-r--r--scripts/Makefile.in135
-rw-r--r--scripts/bm2menu/README21
-rw-r--r--scripts/bm2menu/bm2menu.pl58
-rwxr-xr-xscripts/dirlist.cgi.in536
-rw-r--r--scripts/multipart/.cvsignore2
-rw-r--r--scripts/multipart/Makefile.in75
-rw-r--r--scripts/multipart/README24
-rw-r--r--scripts/multipart/mailcap1
-rw-r--r--scripts/multipart/multipart.cgi.in313
-rw-r--r--scripts/w3mhelp-funcdesc.en.pl.in48
-rw-r--r--scripts/w3mhelp-funcdesc.ja.pl.in66
-rw-r--r--scripts/w3mhelp-funcname.pl.in105
-rw-r--r--scripts/w3mhelp.cgi.in323
-rwxr-xr-xscripts/w3mmail.cgi.in403
-rw-r--r--scripts/w3mman/.cvsignore5
-rw-r--r--scripts/w3mman/Makefile.in96
-rw-r--r--scripts/w3mman/README54
-rw-r--r--scripts/w3mman/hlink.cgi97
-rw-r--r--scripts/w3mman/w3mman.1.in53
-rw-r--r--scripts/w3mman/w3mman.in41
-rw-r--r--scripts/w3mman/w3mman2html.cgi.in274
-rw-r--r--scripts/xface2xbm.in0
-rw-r--r--scripts/xface2xpm.in94
24 files changed, 2833 insertions, 0 deletions
diff --git a/scripts/.cvsignore b/scripts/.cvsignore
new file mode 100644
index 0000000..67b6dc8
--- /dev/null
+++ b/scripts/.cvsignore
@@ -0,0 +1,9 @@
+dirlist.cgi
+w3mhelp.cgi
+w3mmail.cgi
+w3mhelp-funcdesc.en.pl
+w3mhelp-funcdesc.ja.pl
+w3mhelp-funcname.pl
+w3mhelp-funcdesc-stamp
+xface2xpm
+Makefile
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
new file mode 100644
index 0000000..c90ab2e
--- /dev/null
+++ b/scripts/Makefile.in
@@ -0,0 +1,135 @@
+@SET_MAKE@
+SHELL=@SHELL@
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+DOMAIN = $(PACKAGE)
+srcidr=@srcdir@
+top_srcdir=@top_srcdir@
+VPATH= $(srcdir):.
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+datadir = @datadir@
+libdir = @libdir@
+includedir = @includedir@
+infodir = @infodir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+top_srcdir = @top_srcdir@
+VPATH = $(srcdir):.
+DESTDIR =
+
+CGIBIN_DIR = $(libexecdir)/$(PACKAGE)/cgi-bin
+AUXBIN_DIR = $(libexecdir)/$(PACKAGE)
+HELP_DIR = @HELP_DIR@
+RC_DIR = @RC_DIR@
+ETC_DIR = $(sysconfdir)
+CONF_DIR = $(sysconfdir)/$(PACKAGE)
+DOCDIRS = @DOCDIRS@
+
+AUXBIN_TARGETS = xface2xpm
+LIB_TARGETS = dirlist.cgi w3mhelp.cgi w3mmail.cgi
+HELP_TARGETS = w3mhelp-funcname.pl w3mhelp-funcdesc-stamp
+SUBDIRS = multipart w3mman
+.PHONY: $(SUBDIRS)
+
+MKDIR = mkdir -p
+INSTALL = @INSTALL@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_DATA = @INSTALL_DATA@
+
+PERL = @PERL@
+
+all: $(LIB_TARGETS) $(AUXBIN_TARGETS) $(HELP_TARGETS) $(SUBDIRS)
+
+w3mhelp-funcname.pl: w3mhelp-funcname.pl.in ../funcname.tab $(top_srcdir)/doc/keymap.default $(top_srcdir)/doc/keymap.lynx
+ @echo "generating w3mhelp-funcname.pl..."
+ @echo '%funcname = (' > w3mhelp-funcname.pl
+ @sed -ne "/^[a-zA-Z@]/s/\([a-zA-Z@][a-zA-Z0-9@_]*\)[ ][ ]*\([^ ]*\)/'\1', '\2',/p" < ../funcname.tab >> w3mhelp-funcname.pl
+ @echo ');' >> w3mhelp-funcname.pl
+ @echo '%keyfunc = (' >> w3mhelp-funcname.pl
+ @case "$(KEYBIND_SRC)" in *lynx*) keymap=keymap.lynx;; *) keymap=keymap.default;; esac; \
+ sed -ne "/^keymap/s/^keymap[ ][ ]*\([^ ]*\)[ ][ ]*\([a-zA-Z@][a-zA-Z0-9@_]*\)/'\1', '\2', /p" < $(top_srcdir)/doc/$$keymap >> w3mhelp-funcname.pl
+ @echo ');' >> w3mhelp-funcname.pl
+ @cat $(srcdir)/w3mhelp-funcname.pl.in >> w3mhelp-funcname.pl
+ @echo "done"
+
+w3mhelp-funcdesc-stamp: $(top_srcdir)/doc/README.func $(top_srcdir)/doc-jp/README.func w3mhelp-funcdesc.en.pl.in w3mhelp-funcdesc.ja.pl.in
+ @echo "generating w3mhelp-funcdesc*.pl..."
+ @for dirlang in $(DOCDIRS); do \
+ dir=`expr "$$dirlang" : "\(.*\):.*"`; \
+ lang=`expr "$$dirlang" : ".*:\(.*\)_.*"`; \
+ echo '%funcdesc = (' > w3mhelp-funcdesc.$$lang.pl; \
+ sed -ne "/^[a-zA-Z@]/s/\([a-zA-Z@][a-zA-Z0-9@_]*\)[ ][ ]*\(.*\)/'\1', '\2',/p" < $(top_srcdir)/$$dir/README.func >> w3mhelp-funcdesc.$$lang.pl; \
+ echo ');' >> w3mhelp-funcdesc.$$lang.pl; \
+ cat $(srcdir)/w3mhelp-funcdesc.$$lang.pl.in >> w3mhelp-funcdesc.$$lang.pl; \
+ done
+ @echo done
+ @touch w3mhelp-funcdesc-stamp
+
+$(SUBDIRS):
+ for subdir in $(SUBDIRS); \
+ do \
+ (cd $$subdir && $(MAKE)); \
+ done
+
+install: $(LIB_TARGETS) $(HELP_TARGETS)
+ -$(MKDIR) $(DESTDIR)$(AUXBIN_DIR)
+ -$(MKDIR) $(DESTDIR)$(CGIBIN_DIR)
+ -$(MKDIR) $(DESTDIR)$(HELP_DIR)
+ for file in $(AUXBIN_TARGETS); \
+ do \
+ $(INSTALL_SCRIPT) $$file $(DESTDIR)$(AUXBIN_DIR); \
+ done
+ for file in $(LIB_TARGETS); \
+ do \
+ $(INSTALL_SCRIPT) $$file $(DESTDIR)$(CGIBIN_DIR); \
+ done
+ for file in w3mhelp-*.pl; \
+ do \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(HELP_DIR); \
+ done
+ for subdir in $(SUBDIRS); \
+ do \
+ (cd $$subdir && $(MAKE) install); \
+ done
+
+uninstall:
+ -for file in $(AUXBIN_TARGETS); \
+ do \
+ rm -f $(AUXBIN_DIR)/$$file; \
+ done
+ -for file in $(LIB_TARGETS); \
+ do \
+ rm -f $(LIB_DIR)/$$file; \
+ done
+ -for file in w3mhelp-*.pl; \
+ do \
+ rm -f $(HELP_DIR)/$$file; \
+ done
+ -for subdir in $(SUBDIRS); \
+ do \
+ (cd $$subdir && $(MAKE) uninstall); \
+ done
+
+clean:
+ -rm -f $(HELP_TARGETS) w3mhelp-*.pl
+ -for subdir in $(SUBDIRS); \
+ do \
+ (cd $$subdir && $(MAKE) clean); \
+ done
+
+distclean:
+ -rm -f $(LIB_TARGETS) $(AUXBIN_TARGETS)
+ -for subdir in $(SUBDIRS); \
+ do \
+ (cd $$subdir && $(MAKE) distclean); \
+ done
+ -rm -f Makefile
+
diff --git a/scripts/bm2menu/README b/scripts/bm2menu/README
new file mode 100644
index 0000000..b44f144
--- /dev/null
+++ b/scripts/bm2menu/README
@@ -0,0 +1,21 @@
+
+bm2menu.pl
+
+ �֥å��ޡ����ե����� ~/.w3m/bookmark.html ���Ѵ����� w3m ��
+ �֥å��ޡ�����˥塼�Ȥ��ƻȤ����ͤˤ��롣
+
+����ˡ
+
+ ~/.w3m/bookmark.html ���Ѵ����� ~/.w3m/menu ���ɲá�
+
+ perl bm2menu.pl ~/.w3m/bookmark.html >> ~/.w3m/menu
+
+ ���ˡ�~/.w3m/keymap ��
+
+ keymap x MENU Bookmarks
+
+ ���ͤ˥����γ�����Ƥ��ɲä��ޤ���
+
+ ����ǡ����� `x' �ǥ֥å��ޡ�����˥塼�������ޤ���
+ ��˥塼������ doc-jp/README.menu ���ɤ�Ǥ���������
+
diff --git a/scripts/bm2menu/bm2menu.pl b/scripts/bm2menu/bm2menu.pl
new file mode 100644
index 0000000..d89f2b5
--- /dev/null
+++ b/scripts/bm2menu/bm2menu.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+$PRE_MENU = "";
+$POST_MENU = <<EOF;
+ nop "----------------------"
+ func "�֥å��ޡ������ɲ� (a)" ADD_BOOKMARK "aA"
+EOF
+# $POST_MENU = <<EOF;
+# nop "----------------------"
+# func "Add Bookmark (a)" ADD_BOOKMARK "aA"
+# EOF
+
+@section = ();
+%title = ();
+%url = ();
+while(<>) {
+ if (/<h2>(.*)<\/h2>/) {
+ $s = &unquote($1);
+ push(@section, $s);
+ } elsif (/<li><a href=\"(.*)\">(.*)<\/a>/) {
+ $u = &unquote($1);
+ $t = &unquote($2);
+ $url{$s} .= "$u\n";
+ $title{$s} .= "$t\n";
+ }
+}
+
+print "menu Bookmarks\n";
+print $PRE_MENU;
+foreach(@section) {
+ print " popup\t\"$_\"\t\"$_\"\n";
+}
+print $POST_MENU;
+print "end\n";
+
+foreach(@section) {
+ print "\n";
+ print "menu \"$_\"\n";
+ @ts = split("\n", $title{$_});
+ @us = split("\n", $url{$_});
+ while(@ts) {
+ $t = shift @ts;
+ $u = shift @us;
+ print " func\t\"$t\"\tGOTO\t\"\"\t\"$u\"\n";
+ }
+ print "end\n";
+}
+
+sub unquote {
+ local($_) = @_;
+
+ s/\&lt;/\</g;
+ s/\&gt;/\>/g;
+ s/\&nbsp;/ /g;
+ s/\&amp;/\&/g;
+
+ return $_;
+}
diff --git a/scripts/dirlist.cgi.in b/scripts/dirlist.cgi.in
new file mode 100755
index 0000000..5cba1a8
--- /dev/null
+++ b/scripts/dirlist.cgi.in
@@ -0,0 +1,536 @@
+#!@PERL@
+#
+# Directory list CGI by Hironori Sakamoto (hsaka@mth.biglobe.ne.jp)
+#
+
+if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) {
+ $WIN32 = 1;
+ $CYGPATH = 1;
+}
+elsif ( $^O =~ /cygwin|os2/i ) {
+ $WIN32 = 1;
+ $CYGPATH = 0;
+}
+else {
+ $WIN32 = 0;
+ $CYGPATH = 0;
+}
+$RC_DIR = '@RC_DIR@';
+$RC_DIR =~ s@^~/@$ENV{'HOME'}/@;
+if ($CYGPATH) {
+ $RC_DIR = &cygwin_pathconv("$RC_DIR");
+}
+$CONFIG = "$RC_DIR/dirlist";
+$CGI = $ENV{'SCRIPT_NAME'} || $0;
+$CGI = "file://" . &file_encode("$CGI");
+
+$AFMT = '<a href="%s"><nobr>%s</nobr></a>';
+$NOW = time();
+
+@OPT = &init_option($CONFIG);
+
+$query = $ENV{'QUERY_STRING'};
+$dir = '';
+$cmd = '';
+$cookie = '';
+$local_cookie = '';
+foreach(split(/\&/, $query)) {
+ if (s/^dir=//) {
+ $dir = &form_decode($_);
+ }
+}
+$body = undef;
+if ($ENV{'REQUEST_METHOD'} eq 'POST') {
+ sysread(STDIN, $body, $ENV{'CONTENT_LENGTH'});
+ foreach(split(/\&/, $body)) {
+ if (s/^dir=//) {
+ $dir = &form_decode($_);
+ } elsif (s/^opt(\d+)=//) {
+ $OPT[$1] = $_;
+ } elsif (s/^cmd=//) {
+ $cmd = $_;
+ } elsif (s/^cookie=//) {
+ $cookie = &form_decode($_);
+ }
+ }
+}
+$cookie_file = $ENV{'LOCAL_COOKIE_FILE'};
+if (-f $cookie_file) {
+ open(F, "< $cookie_file");
+ $local_cookie = <F>;
+ close(F);
+}
+if ($local_cookie eq '' || (defined($body) && $cookie ne $local_cookie)) {
+ print <<EOF;
+Content-Type: text/plain
+
+Local cookie doesn't match: It may be an illegal execution
+EOF
+ exit(1);
+}
+$local_cookie = &html_quote($local_cookie);
+if ($dir !~ m@/$@) {
+ $dir .= '/';
+}
+if ($dir =~ m@^/@ && $CYGPATH) {
+ $dir = &cygwin_pathconv("$dir");
+}
+$ROOT = '';
+if ($WIN32) {
+ if (($dir =~ s@^//[^/]+@@) || ($dir =~ s@^[a-z]:@@i)) {
+ $ROOT = $&;
+ }
+ if ($CYGPATH) {
+ $ROOT = &cygwin_pathconv("$ROOT");
+ }
+}
+$dir = &cleanup($dir);
+
+$TYPE = $OPT[$OPT_TYPE];
+$FORMAT = $OPT[$OPT_FORMAT];
+$SORT = $OPT[$OPT_SORT];
+if ($cmd) {
+ &update_option($CONFIG);
+}
+
+$qdir = "$ROOT" . &html_quote("$dir");
+$edir = "$ROOT" . &file_encode("$dir");
+if (! opendir(DIR, "$ROOT$dir")) {
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head>
+<title>Directory list of $qdir</title>
+</head>
+<body>
+<b>$qdir</b>: $! !
+</body>
+</html>
+EOF
+ exit 1;
+}
+
+print <<EOF;
+Content-Type: text/html
+
+<html>
+<head>
+<title>Directory list of $qdir</title>
+</head>
+<body>
+<h1>Directory list of $qdir</h1>
+EOF
+&print_form($qdir, @OPT);
+print <<EOF;
+<hr>
+EOF
+$dir =~ s@/$@@;
+@sdirs = split('/', $dir);
+$_ = $sdirs[0];
+if ($_ eq '') {
+ $_ = '/';
+}
+if ($TYPE eq $TYPE_TREE) {
+ print <<EOF;
+<table hborder width="640">
+<tr valign=top><td width="160">
+<pre>
+EOF
+ $q = "$ROOT". &html_quote("$_");
+ $e = "$ROOT" . &file_encode("$_");
+ if ($dir =~ m@^$@) {
+ $n = "\" name=\"current";
+ } else {
+ $n = '';
+ }
+ printf("$AFMT\n", "$e$n", "<b>$q</b>");
+ $N = 0;
+ $SKIPLINE = "";
+
+ &left_dir('', @sdirs);
+
+ print <<EOF;
+</pre>
+</td><td width="400">
+<pre>$SKIPLINE
+EOF
+} else {
+ print <<EOF;
+<pre>
+EOF
+}
+
+&right_dir($dir);
+
+if ($TYPE eq $TYPE_TREE) {
+ print <<EOF;
+</pre>
+</td></tr>
+</table>
+</body>
+</html>
+EOF
+} else {
+ print <<EOF;
+</pre>
+</body>
+</html>
+EOF
+}
+
+sub left_dir {
+ local($pre, $dir, @sdirs) = @_;
+ local($ok) = (@sdirs == 0);
+ local(@cdirs) = ();
+ local($_, $dir0, $d, $qdir, $q, $edir, $e);
+
+ $dir0 = "$dir/";
+ $dir = "$dir0";
+ opendir(DIR, "$ROOT$dir") || return;
+
+ foreach(sort readdir(DIR)) {
+ -d "$ROOT$dir$_" || next;
+ /^\.$/ && next;
+ /^\.\.$/ && next;
+ push(@cdirs, $_);
+ }
+ closedir(DIR);
+
+ $qdir = "$ROOT" . &html_quote($dir);
+ $edir = "$ROOT" . &file_encode($dir);
+ while(@cdirs) {
+ $_ = shift @cdirs;
+ $q = &html_quote($_);
+ $e = &file_encode($_);
+ $N++;
+ if (!$ok && $_ eq $sdirs[0]) {
+ $d = $dir0 . shift @sdirs;
+ if (!@sdirs) {
+ $n = "\" name=\"current";
+ $SKIPLINE = "\n" x $N;
+ } else {
+ $n = '';
+ }
+ printf("${pre}o-$AFMT\n", "$edir$e$n", "<b>$q</b>");
+ &left_dir(@cdirs ? "$pre| " : "$pre ", $d, @sdirs);
+ $ok = 1;
+ } else {
+ printf("${pre}+-$AFMT\n", "$edir$e", $q);
+ }
+ }
+}
+
+sub right_dir {
+ local($dir) = @_;
+ local(@list);
+ local($_, $qdir, $q, $edir, $e, $f, $max, @d, $type, $u, $g);
+ local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks);
+ local(%sizes, %ctimes, %prints);
+
+ $dir = "$dir/";
+ opendir(DIR, "$ROOT$dir") || return;
+
+ $qdir = "$ROOT" . &html_quote($dir);
+ $edir = "$ROOT" . &file_encode($dir);
+ if ($TYPE eq $TYPE_TREE) {
+ print "<b>$qdir</b>\n";
+ }
+ @list = ();
+ $max = 0;
+ foreach(readdir(DIR)) {
+ /^\.$/ && next;
+# if ($TYPE eq $TYPE_TREE) {
+# /^\.\.$/ && next;
+# }
+ $f = "$ROOT$dir$_";
+ (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks) = lstat($f)) || next;
+ push(@list, $_);
+ $sizes{$_} = $size;
+ $ctimes{$_} = $ctime;
+
+ if ($FORMAT eq $FORMAT_COLUMN) {
+ if (length($_) > $max) {
+ $max = length($_);
+ }
+ next;
+ }
+ $type = &utype($mode);
+ if ($FORMAT eq $FORMAT_SHORT) {
+ $prints{$_} = sprintf("%-6s ", "[$type]");
+ next;
+ }
+ if ($type =~ /^[CB]/) {
+ $size = sprintf("%3u, %3u", ($rdev >> 8) & 0xff, $rdev & 0xffff00ff);
+ }
+ if ($FORMAT eq $FORMAT_LONG) {
+ $u = $USER{$uid} || ($USER{$uid} = getpwuid($uid) || $uid);
+ $g = $GROUP{$gid} || ($GROUP{$gid} = getgrgid($gid) || $gid);
+ $prints{$_} = sprintf( "%s %-8s %-8s %8s %s ",
+ &umode($mode), $u, $g, $size, &utime($ctime));
+# } elsif ($FORMAT eq $FORMAT_STANDARD) {
+ } else {
+ $prints{$_} = sprintf("%-6s %8s %s ", "[$type]", $size, &utime($ctime));
+ }
+ }
+ closedir(DIR);
+ if ($SORT eq $SORT_SIZE) {
+ @list = sort { $sizes{$b} <=> $sizes{$a} || $a cmp $b } @list;
+ } elsif ($SORT eq $SORT_TIME) {
+ @list = sort { $ctimes{$b} <=> $ctimes{$a} || $a cmp $b } @list;
+ } else {
+ @list = sort @list;
+ }
+ if ($FORMAT eq $FORMAT_COLUMN) {
+ local($COLS, $l, $nr, $n);
+ if ($TYPE eq $TYPE_TREE) {
+ $COLS = 60;
+ } else {
+ $COLS = 80;
+ }
+ $l = int($COLS / ($max + 2)) || 1;
+ $nr = int($#list / $l + 1);
+ $n = 0;
+ print "<table>\n<tr valign=top>";
+ foreach(@list) {
+ $f = "$ROOT$dir$_";
+ $q = &html_quote($_);
+ $e = &file_encode($_);
+ if ($n % $nr == 0) {
+ print "<td>";
+ }
+ if (-d $f) {
+ printf($AFMT, "$edir$e", "$q/");
+ } else {
+ printf($AFMT, "$edir$e", $q);
+ }
+ $n++;
+ if ($n % $nr == 0) {
+ print "</td>\n";
+ } else {
+ print "<br>\n";
+ }
+ }
+ print "</tr></table>\n";
+ return;
+ }
+ foreach(@list) {
+ $f = "$ROOT$dir$_";
+ $q = &html_quote($_);
+ $e = &file_encode($_);
+ print $prints{$_};
+ if (-d $f) {
+ printf($AFMT, "$edir$e", "$q/");
+ } else {
+ printf($AFMT, "$edir$e", $q);
+ }
+ if (-l $f) {
+ print " -> ", &html_quote(readlink($f));
+ }
+ print "\n";
+ }
+}
+
+sub init_option {
+ local($config) = @_;
+ $OPT_TYPE = 0;
+ $OPT_FORMAT = 1;
+ $OPT_SORT = 2;
+ $TYPE_TREE = 't';
+ $TYPE_STANDARD = 'd';
+ $FORMAT_SHORT = 's';
+ $FORMAT_STANDARD = 'd';
+ $FORMAT_LONG = 'l';
+ $FORMAT_COLUMN = 'c';
+ $SORT_NAME = 'n';
+ $SORT_SIZE = 's';
+ $SORT_TIME = 't';
+ local(@opt) = ($TYPE_TREE, $FORMAT_STANDARD, $SORT_NAME);
+ local($_);
+
+ open(CONFIG, "< $config") || return @opt;
+ while(<CONFIG>) {
+ chop;
+ s/^\s+//;
+ tr/A-Z/a-z/;
+ if (/^type\s+(\S)/i) {
+ $opt[$OPT_TYPE] = $1;
+ } elsif (/^format\s+(\S)/i) {
+ $opt[$OPT_FORMAT] = $1
+ } elsif (/^sort\s+(\S)/i) {
+ $opt[$OPT_SORT] = $1;
+ }
+ }
+ close(CONFIG);
+ return @opt;
+}
+
+sub update_option {
+ local($config) = @_;
+
+ open(CONFIG, "> $config") || return;
+ print CONFIG <<EOF;
+type $TYPE
+format $FORMAT
+sort $SORT
+EOF
+ close(CONFIG);
+}
+
+sub print_form {
+ local($d, @OPT) = @_;
+ local(@disc) = ('Type', 'Format', 'Sort');
+ local(@val) = (
+ "('t', 'd')",
+ "('s', 'd', 'c')",
+ "('n', 's', 't')",
+ );
+ local(@opt) = (
+ "('Tree', 'Standard')",
+ "('Short', 'Standard', 'Column')",
+ "('By Name', 'By Size', 'By Time')"
+ );
+ local($_, @vs, @os, $v, $o);
+
+ print <<EOF;
+<form method=post action=\"$CGI#current\">
+<center>
+<table cellpadding=0>
+<tr valign=top>
+EOF
+ foreach(0 .. 2) {
+ print "<td align>&nbsp;$disc[$_]</td>\n";
+ }
+ print "</tr><tr>\n";
+ foreach(0 .. 2) {
+ print "<td><select name=opt$_>\n";
+ eval "\@vs = $val[$_]";
+ eval "\@os = $opt[$_]";
+ foreach $v (@vs) {
+ $o = shift(@os);
+ if ($v eq $OPT[$_]) {
+ print "<option value=$v selected>$o\n";
+ } else {
+ print "<option value=$v>$o\n";
+ }
+ }
+ print "</select></td>\n";
+ }
+ print <<EOF;
+<td><input type=submit name=cmd value="Update"></td>
+</tr>
+</table>
+</center>
+<input type=hidden name=dir value="$d">
+<input type=hidden name=cookie value="$local_cookie">
+</form>
+EOF
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+sub file_encode {
+ local($_) = @_;
+ s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg;
+ return $_;
+}
+
+sub form_decode {
+ local($_) = @_;
+ s/\+/ /g;
+ s/%([\da-f][\da-f])/pack('C', hex($1))/egi;
+ return $_;
+}
+
+sub cleanup {
+ local($_) = @_;
+
+ s@//+@/@g;
+ s@/\./@/@g;
+ while(m@/\.\./@) {
+ s@^/(\.\./)+@/@;
+ s@/[^/]+/\.\./@/@;
+ }
+ return $_;
+}
+
+sub utype {
+ local($_) = @_;
+ local(%T) = (
+ 0010000, 'PIPE',
+ 0020000, 'CHR',
+ 0040000, 'DIR',
+ 0060000, 'BLK',
+ 0100000, 'FILE',
+ 0120000, 'LINK',
+ 0140000, 'SOCK',
+ );
+ return $T{($_ & 0170000)} || 'FILE';
+}
+
+sub umode {
+ local($_) = @_;
+ local(%T) = (
+ 0010000, 'p',
+ 0020000, 'c',
+ 0040000, 'd',
+ 0060000, 'b',
+ 0100000, '-',
+ 0120000, 'l',
+ 0140000, 's',
+ );
+
+ return ($T{($_ & 0170000)} || '-')
+ . (($_ & 00400) ? 'r' : '-')
+ . (($_ & 00200) ? 'w' : '-')
+ . (($_ & 04000) ? 's' :
+ (($_ & 00100) ? 'x' : '-'))
+ . (($_ & 00040) ? 'r' : '-')
+ . (($_ & 00020) ? 'w' : '-')
+ . (($_ & 02000) ? 's' :
+ (($_ & 00010) ? 'x' : '-'))
+ . (($_ & 00004) ? 'r' : '-')
+ . (($_ & 00002) ? 'w' : '-')
+ . (($_ & 01000) ? 't' :
+ (($_ & 00001) ? 'x' : '-'));
+}
+
+sub utime {
+ local($_) = @_;
+ local(@MON) = (
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ );
+ local($sec,$min,$hour,$mday,$mon,
+ $year,$wday,$yday,$isdst) = localtime($_);
+
+ if ($_ > $NOW - 182*24*60*60 && $_ < $NOW + 183*24*60*60) {
+ return sprintf("%3s %2d %.2d:%.2d", $MON[$mon], $mday, $hour, $min);
+ } else {
+ return sprintf("%3s %2d %5d", $MON[$mon], $mday, 1900+$year);
+ }
+}
+
+sub cygwin_pathconv {
+ local($_) = @_;
+ local(*CYGPATH);
+
+ open(CYGPATH, '-|') || exec('cygpath', '-w', $_);
+ $_ = <CYGPATH>;
+ close(CYGPATH);
+ s/\r?\n$//;
+ s!\\!/!g;
+ s!/$!!;
+ return $_;
+}
diff --git a/scripts/multipart/.cvsignore b/scripts/multipart/.cvsignore
new file mode 100644
index 0000000..db1dff2
--- /dev/null
+++ b/scripts/multipart/.cvsignore
@@ -0,0 +1,2 @@
+multipart.cgi
+Makefile
diff --git a/scripts/multipart/Makefile.in b/scripts/multipart/Makefile.in
new file mode 100644
index 0000000..ad472ee
--- /dev/null
+++ b/scripts/multipart/Makefile.in
@@ -0,0 +1,75 @@
+@SET_MAKE@
+SHELL=@SHELL@
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+DOMAIN = $(PACKAGE)
+srcidr=@srcdir@
+top_srcdir=@top_srcdir@
+VPATH= $(srcdir):.
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+datadir = @datadir@
+libdir = @libdir@
+includedir = @includedir@
+infodir = @infodir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+top_srcdir = @top_srcdir@
+VPATH = $(top_srcdir):.
+DESTDIR =
+
+CGIBIN_DIR = $(libexecdir)/$(PACKAGE)/cgi-bin
+AUXBIN_DIR = $(libexecdir)/$(PACKAGE)
+HELP_DIR = @HELP_DIR@
+RC_DIR = @RC_DIR@
+ETC_DIR = $(sysconfdir)
+CONF_DIR = $(sysconfdir)/$(PACKAGE)
+
+LIB_TARGETS = multipart.cgi
+
+MKDIR = mkdir -p
+INSTALL = @INSTALL@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+
+PERL = @PERL@
+NKF = @NKF@
+
+all: $(LIB_TARGETS)
+
+# do nothing
+$(LIB_TARGETS):
+
+install: $(LIB_TARGETS)
+ -$(MKDIR) $(DESTDIR)$(CGIBIN_DIR)
+ for file in $(LIB_TARGETS); \
+ do \
+ $(INSTALL_SCRIPT) $$file $(DESTDIR)$(CGIBIN_DIR); \
+ done
+
+uninstall:
+ -for file in $(LIB_TARGETS); \
+ do \
+ rm -f $(CGIBIN_DIR)/$$file; \
+ done
+
+clean:
+
+distclean:
+ -rm -f $(LIB_TARGETS)
+ -rm -f Makefile
+
+dist: all
+ @-rm -fr $(distdir)/multipart
+ $(MKDIR) $(distdir)/multipart
+ cp Makefile README multipart.cgi.in $(distdir)/multipart
+ ( cd $(distdir); tar -cf - multipart | GZIP='' gzip ) \
+ > $(distdir)/multipart.tar.gz
+ -rm -fr $(distdir)/multipart
+
diff --git a/scripts/multipart/README b/scripts/multipart/README
new file mode 100644
index 0000000..b82f585
--- /dev/null
+++ b/scripts/multipart/README
@@ -0,0 +1,24 @@
+
+Content-Type: multipart/* �򰷤� local-CGI
+
+ Content-Type: multipart/* �ʥե�����򰷤������ local-CGI �Ǥ���
+ ��� mailx �ʤɤǥ᡼��� PAGER="w3m -m" ���ɤ�������ꤷ�Ƥ��ޤ���
+
+���󥹥ȡ���
+
+ * make install
+ ɬ�פʤ� PERL, NKF, LIBDIR �����ꤷ�Ƥ���������
+
+ * mailcap �� ~/.w3m/mailcap �˥ޡ���
+ multipart.cgi �Υѥ�������
+
+ * w3m �� Option Setting Panel �ǡ�
+ ����¸���� Content-Transfer-Encoding ��ǥ����ɤ���٤� ON
+ ź�եե��������¸���������Ǥ���
+
+ɬ�פʤ��
+
+ * NKF �⥸�塼��ޤ��� nkf
+ ʸ���������Ѵ��� MIME �إå��Υǥ����ɤˤ�ȤäƤޤ���
+ ���ˤ���ʤ�����Ѥ��Ƥ���������
+
diff --git a/scripts/multipart/mailcap b/scripts/multipart/mailcap
new file mode 100644
index 0000000..323ee20
--- /dev/null
+++ b/scripts/multipart/mailcap
@@ -0,0 +1 @@
+multipart/*; /usr/local/lib/w3m/multipart.cgi %s %{boundary}; htmloutput
diff --git a/scripts/multipart/multipart.cgi.in b/scripts/multipart/multipart.cgi.in
new file mode 100644
index 0000000..db8001c
--- /dev/null
+++ b/scripts/multipart/multipart.cgi.in
@@ -0,0 +1,313 @@
+#!@PERL@
+
+eval "use NKF;";
+if (! $@) {
+ $use_NKF = 1;
+ $CONV = "-e";
+ $MIME_DECODE = "-m -e";
+} else {
+ $use_NKF = 0;
+# $CONV = "w3m -dump -e";
+ $CONV = "@NKF@ -e";
+ $MIME_DECODE = "@NKF@ -m -e";
+}
+$MIME_TYPE = "$ENV{'HOME'}/.mime.types";
+
+$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0;
+$CGI = "file://$SCRIPT_NAME";
+
+if ($ENV{'REQUEST_METHOD'} eq 'POST') {
+ sysread(STDIN, $query, $ENV{'CONTENT_LENGTH'});
+} elsif (defined($ENV{'QUERY_STRING'})) {
+ $query = $ENV{'QUERY_STRING'};
+}
+if (defined($query)) {
+ for (split('&', $query)) {
+ s/^([^=]*)=//;
+ $v{$1} = $_;
+ }
+ $file = &form_decode($v{'file'});
+ $boundary = &form_decode($v{'boundary'});
+} else {
+ $file = $ARGV[0];
+ if (@ARGV >= 2) {
+ $boundary = $ARGV[1];
+ }
+}
+(-f $file) || exit(1);
+open(F, "< $file") || exit(1);
+$end = 0;
+$mbody = '';
+if (defined($boundary)) {
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ ($_ eq "--$boundary--") && ($end = 1, last);
+ $mbody .= "$_\n";
+ }
+} else {
+ while(<F>) {
+ s/\r?\n$//;
+ if (s/^\-\-//) {
+ $boundary = $_;
+ last;
+ }
+ $mbody .= "$_\n";
+ }
+}
+
+if (defined($v{'count'})) {
+ $count = 0;
+ while($count < $v{'count'}) {
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ }
+ eof(F) && exit;
+ $count++;
+ }
+
+ %header = ();
+ $hbody = '';
+ while(<F>) {
+ /^\s*$/ && last;
+ $x = $_;
+ s/\r?\n$//;
+ if (/=\?/) {
+ $_ = &decode($_, $MIME_DECODE);
+ }
+ if (s/^(\S+)\s*:\s*//) {
+ $h = $&;
+ if ($h =~ /^w3m-control/i) {
+ $h = "WARNING: $h";
+ }
+ $hbody .= "$h$_\n";
+ $p = $1;
+ $p =~ tr/A-Z/a-z/;
+ $header{$p} = $_;
+ } elsif (s/^\s+//) {
+ chop $hbody;
+ $hbody .= "$_\n";
+ $header{$p} .= $_;
+ }
+ }
+ $type = $header{"content-type"};
+ $dispos = $header{"content-disposition"};
+ if ($type =~ /application\/octet-stream/) {
+ if ($type =~ /type\=gzip/) {
+ print "Content-Encoding: x-gzip\n";
+ }
+ if ($type =~ /name=\"?([^\"]+)\"?/ ||
+ $dispos =~ /filename=\"?([^\"]+)\"?/) {
+ $type = &guess_type($1);
+ if ($type) {
+ print "Content-Type: $type; name=\"$1\"\n";
+ } else {
+ print "Content-Type: text/plain; name=\"$1\"\n";
+ }
+ }
+ }
+ print $hbody;
+ print "\n";
+ while(<F>) {
+ $x = $_;
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ if ($_ eq "--$boundary--") {
+ last;
+ }
+ print $x;
+ }
+ close(F);
+ exit;
+}
+
+$qcgi = &html_quote($CGI);
+$qfile = &html_quote($file);
+$qboundary = &html_quote($boundary);
+
+if ($mbody =~ /\S/) {
+ $_ = $mbody;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ print "</pre>\n";
+}
+
+$count = 0;
+while(! $end) {
+ %header = ();
+ $hbody = '';
+ while(<F>) {
+ /^\s*$/ && last;
+ s/\r?\n$//;
+ if (/=\?/) {
+ $_ = &decode($_, $MIME_DECODE);
+ }
+ if (s/^(\S+)\s*:\s*//) {
+ $hbody .= "$&$_\n";
+ $p = $1;
+ $p =~ tr/A-Z/a-z/;
+ $header{$p} = $_;
+ } elsif (s/^\s+//) {
+ chop $hbody;
+ $hbody .= "$_\n";
+ $header{$p} .= $_;
+ }
+ }
+ $type = $header{"content-type"};
+ $dispos = $header{"content-disposition"};
+ $plain = 0;
+ $image = 0;
+ if (! $dispos || $dispos =~ /^inline/i) {
+ if (! $type || $type =~ /^text\/plain/i) {
+ $plain = 1;
+ } elsif ($type =~ /^image\//i) {
+ $image = 1;
+ }
+ }
+ $body = '';
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ if ($_ eq "--$boundary--") {
+ $end = 1;
+ last;
+ }
+ if ($plain) {
+ $body .= "$_\n";
+ }
+ }
+ $| = 1;
+ print "<hr>\n";
+ {
+ $_ = $hbody;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ print "</pre>\n";
+ if ($type =~ /name=\"?([^\"]+)\"?/ ||
+ $dispos =~ /filename=\"?([^\"]+)\"?/) {
+ $name = $1;
+ } else {
+ $name = "Content";
+ }
+ print "<form action=\"$qcgi\">\n";
+ print "<input type=hidden name=file value=\"$qfile\">\n";
+ print "<input type=hidden name=boundary value=\"$qboundary\">\n";
+ print "<input type=hidden name=count value=\"$count\">\n";
+ if ($image) {
+ print "<input type=image name=submit src=\"$qcgi?file=",
+ &html_quote(&form_encode($file)),
+ "&amp;boundary=",
+ &html_quote(&form_encode($boundary)),
+ "&amp;count=$count\" alt=\"",
+ &html_quote($name), "\">\n";
+ } else {
+ print "<input type=submit name=submit value=\"",
+ &html_quote($name), "\">\n";
+ }
+ print "</form>\n"
+ }
+ if ($plain) {
+ $body = &decode($body, $CONV);
+ $_ = $body;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n\n";
+ print $_;
+ print "</pre>\n";
+ }
+ eof(F) && last;
+ $count++;
+}
+close(F);
+
+sub decode {
+if ($use_NKF) {
+ local($body, $opt) = @_;
+ return nkf($opt, $body);
+}
+ local($body, @cmd) = @_;
+ local($_);
+
+ $| = 1;
+ pipe(R, W2);
+ pipe(R2, W);
+ if (! fork()) {
+ close(F);
+ close(R);
+ close(W);
+ open(STDIN, "<&R2");
+ open(STDOUT, ">&W2");
+ exec @cmd;
+ die;
+ }
+ close(R2);
+ close(W2);
+ print W $body;
+ close(W);
+ $body = '';
+ while(<R>) {
+ $body .= $_;
+ }
+ close(R);
+ return $body;
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub form_decode {
+ local($_) = @_;
+ s/\+/ /g;
+ s/%([\da-f][\da-f])/pack('c', hex($1))/egi;
+ return $_;
+}
+
+sub form_encode {
+ local($_) = @_;
+ s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg;
+ return $_;
+}
+
+sub guess_type {
+ local($_) = @_;
+
+ /\.(\w+)$/ || return "";
+ $_ = $1;
+ tr/A-Z/a-z/;
+ %mime_type = &load_mime_type($MIME_TYPE);
+ $mime_type{$_};
+}
+
+sub load_mime_type {
+ local($file) = @_;
+ local(%m, $a, @b, $_);
+
+ open(M, "< $file") || return ();
+ while(<M>) {
+ /^#/ && next;
+ chop;
+ (($a, @b) = split(" ")) >= 2 || next;
+ for(@b) {
+ $m{$_} = $a;
+ }
+ }
+ close(M);
+ return %m;
+}
diff --git a/scripts/w3mhelp-funcdesc.en.pl.in b/scripts/w3mhelp-funcdesc.en.pl.in
new file mode 100644
index 0000000..d854b59
--- /dev/null
+++ b/scripts/w3mhelp-funcdesc.en.pl.in
@@ -0,0 +1,48 @@
+# charset
+$charset = 'US-ASCII';
+
+# Buffer selection mode
+
+%buf_funcdesc = (
+ 'BUF:PREV', 'Select previous buffer',
+ 'BUF:NEXT', 'Select next buffer',
+ 'BUF:DELETE', 'Delete current buffer',
+ 'BUF:GO', 'Go to the selected buffer',
+);
+
+%lineedit_funcdesc = (
+ 'LINEEDIT:FORWARD', 'Move cursor forward',
+ 'LINEEDIT:BACK', 'Move cursor backward',
+ 'LINEEDIT:BS', 'Delete previous character',
+ 'LINEEDIT:DEL', 'Delete current character',
+ 'LINEEDIT:KILL_AFTER', 'Kill everything after cursor',
+ 'LINEEDIT:KILL_BEFORE', 'Kill everything before cursor',
+ 'LINEEDIT:TOP', 'Move to the top of line',
+ 'LINEEDIT:BOTTOM', 'Move to the bottom of line',
+ 'LINEEDIT:PREV', 'Fetch the previous string from the history list',
+ 'LINEEDIT:NEXT', 'Fetch the next string from the history list',
+ 'LINEEDIT:EDITOR', 'Edit with external editor',
+ 'LINEEDIT:COMPLETE', 'Complete filename',
+ 'LINEEDIT:ACCEPT', 'Accept',
+);
+
+%menu_funcdesc = (
+ 'MENU:SELECT', 'Select item',
+ 'MENU:CLOSE', 'Close menu',
+ 'MENU:CANCEL', 'Back',
+ 'MENU:DOWN', 'Move to next item',
+ 'MENU:UP', 'Move to previous item',
+ 'MENU:LINE_UP', 'Scroll up one item',
+ 'MENU:LINE_DOWN', 'Scroll down one item',
+ 'MENU:TOP', 'Go to top item',
+ 'MENU:LAST', 'Go to last item',
+ 'MENU:NEXT', 'Go to next page',
+ 'MENU:PREV', 'Go to previous page',
+ 'MENU:SEARCH_FORE', 'Search foreward',
+ 'MENU:SEARCH_BACK', 'Search backward',
+ 'MENU:SEARCH_NEXT', 'Search next regexp',
+ 'MENU:SEARCH_PREV', 'Search previous regexp',
+ 'MENU:SUSPEND', 'Suspend',
+);
+
+1;
diff --git a/scripts/w3mhelp-funcdesc.ja.pl.in b/scripts/w3mhelp-funcdesc.ja.pl.in
new file mode 100644
index 0000000..051c888
--- /dev/null
+++ b/scripts/w3mhelp-funcdesc.ja.pl.in
@@ -0,0 +1,66 @@
+# charset
+$charset = 'EUC-JP';
+
+# Buffer selection mode
+
+%buf_funcdesc = (
+ 'BUF:PREV', '��ľ�ΥХåե�������',
+ 'BUF:NEXT', '��IJ��ΥХåե�������',
+ 'BUF:DELETE', '�������򤷤Ƥ���Хåե�����',
+ 'BUF:GO', '�������򤷤Ƥ���Хåե���ɽ��',
+);
+
+%lineedit_funcdesc = (
+ 'LINEEDIT:FORWARD', '��������򱦤ذ�ư',
+ 'LINEEDIT:BACK', '��������򺸤ذ�ư',
+ 'LINEEDIT:BS', '����ʸ������',
+ 'LINEEDIT:DEL', '����������֤�ʸ������',
+ 'LINEEDIT:KILL_AFTER', '��������θ��������ƺ��',
+ 'LINEEDIT:KILL_BEFORE', '������������ޤǤ����ƺ��',
+ 'LINEEDIT:TOP', '��Ƭ�˰�ư',
+ 'LINEEDIT:BOTTOM', '�����ذ�ư',
+ 'LINEEDIT:PREV', '�ҥ��ȥ꤫��������ʸ�������Ф�',
+ 'LINEEDIT:NEXT', '�ҥ��ȥ꤫�鼡��ʸ�������Ф�',
+ 'LINEEDIT:EDITOR', '�������ǥ������Խ�',
+ 'LINEEDIT:COMPLETE', '�ե�����̾���䴰',
+ 'LINEEDIT:ACCEPT', '���Ͻ�λ',
+);
+
+%menu_funcdesc = (
+ 'MENU:SELECT', '���ܤ�����',
+ 'MENU:CLOSE', '��˥塼���Ĥ���',
+ 'MENU:CANCEL', '���',
+ 'MENU:DOWN', '��IJ��ι��ܤ�',
+ 'MENU:UP', '��ľ�ι��ܤ�',
+ 'MENU:LINE_UP', '���ܤ򲼤˥���������',
+ 'MENU:LINE_DOWN', '���ܤ��˥���������',
+ 'MENU:TOP', '��Ƭ�ι��ܤ�',
+ 'MENU:LAST', '�Ǹ�ι��ܤ�',
+ 'MENU:NEXT', '���ڡ����ι��ܤ�',
+ 'MENU:PREV', '���ڡ����ι��ܤ�',
+ 'MENU:SEARCH_FORE', '���ܤ򲼤˸����äƸ���',
+ 'MENU:SEARCH_BACK', '���ܤ��˸����äƸ���',
+ 'MENU:SEARCH_NEXT', '���ι��ܤ򸡺�',
+ 'MENU:SEARCH_PREV', '���ι��ܤ򸡺�',
+ 'MENU:SUSPEND', '�����ڥ��',
+);
+
+%title = (
+ "Show keymap file", 'keymap �ե�����򸫤�',
+ "Page/Cursor motion", '�ڡ���/���������ư',
+ "Hyperlink operation", '�ϥ��ѡ�������',
+ "File/Stream operation", '�ե�����/���ȥ꡼�����',
+ "Buffer operation", '�Хåե����',
+ "Tab operation", '�������',
+ "Buffer selection mode", '�Хåե�����⡼��',
+ "Bookmark operation", '�֥å��ޡ������',
+ "Search", '����',
+ "Dictionary look-up", '���񸡺�',
+ "Mark operation", '�ޡ������',
+ "Miscellany", '����¾',
+ "User defined keymaps", '�桼�����',
+ "Line-edit mode", '���Խ��⡼��',
+ "Popup menu", '��˥塼',
+);
+
+1;
diff --git a/scripts/w3mhelp-funcname.pl.in b/scripts/w3mhelp-funcname.pl.in
new file mode 100644
index 0000000..659b7ed
--- /dev/null
+++ b/scripts/w3mhelp-funcname.pl.in
@@ -0,0 +1,105 @@
+
+%buf_funcname = (
+ 'BUF:PREV', 'buffer_prev',
+ 'BUF:NEXT', 'buffer_next',
+ 'BUF:DELETE', 'buffer_delete',
+ 'BUF:GO', 'buffer_go',
+);
+
+%lineedit_funcname = (
+ 'LINEEDIT:FORWARD', 'lineedit_forward',
+ 'LINEEDIT:BACK', 'lineedit_back',
+ 'LINEEDIT:BS', 'lineedit_backspace',
+ 'LINEEDIT:DEL', 'lineedit_delete',
+ 'LINEEDIT:KILL_AFTER', 'lineedit_kill_after',
+ 'LINEEDIT:KILL_BEFORE', 'lineedit_kill_before',
+ 'LINEEDIT:TOP', 'lineedit_top',
+ 'LINEEDIT:BOTTOM', 'lineedit_bottom',
+ 'LINEEDIT:PREV', 'lineedit_prev',
+ 'LINEEDIT:NEXT', 'lineedit_next',
+ 'LINEEDIT:EDITOR', 'lineedit_editor',
+ 'LINEEDIT:COMPLETE', 'lineedit_complete',
+ 'LINEEDIT:ACCEPT', 'lineedit_accept',
+);
+
+%menu_funcname = (
+ 'MENU:SELECT', 'menu_select',
+ 'MENU:CLOSE', 'menu_close',
+ 'MENU:CANCEL', 'menu_cancel',
+ 'MENU:DOWN', 'menu_down',
+ 'MENU:UP', 'menu_up',
+ 'MENU:LINE_UP', 'menu_line_up',
+ 'MENU:LINE_DOWN', 'menu_line_down',
+ 'MENU:TOP', 'menu_top',
+ 'MENU:LAST', 'menu_last',
+ 'MENU:NEXT', 'menu_next',
+ 'MENU:PREV', 'menu_prev',
+ 'MENU:SEARCH_FORE', 'menu_search_fore',
+ 'MENU:SEARCH_BACK', 'menu_search_back',
+ 'MENU:SEARCH_NEXT', 'menu_search_next',
+ 'MENU:SEARCH_PREV', 'menu_search_prev',
+ 'MENU:SUSPEND', 'menu_suspend',
+);
+
+%buf_keyfunc = (
+ 'k', 'BUF:PREV',
+ 'C-p', 'BUF:PREV',
+ 'j', 'BUF:NEXT',
+ 'C-n', 'BUF:NEXT',
+ 'D', 'BUF:DELETE',
+ 'RET', 'BUF:GO'
+);
+
+%lineedit_keyfunc = (
+ 'C-f', 'LINEEDIT:FORWARD',
+ 'C-b', 'LINEEDIT:BACK',
+ 'C-h', 'LINEEDIT:BS',
+ 'C-d', 'LINEEDIT:DEL',
+ 'C-k', 'LINEEDIT:KILL_AFTER',
+ 'C-u', 'LINEEDIT:KILL_BEFORE',
+ 'C-a', 'LINEEDIT:TOP',
+ 'C-e', 'LINEEDIT:BOTTOM',
+ 'C-p', 'LINEEDIT:PREV',
+ 'C-n', 'LINEEDIT:NEXT',
+ 'C-o', 'LINEEDIT:EDITOR',
+ 'TAB', 'LINEEDIT:COMPLETE',
+ 'SPC', 'LINEEDIT:COMPLETE',
+ 'RET', 'LINEEDIT:ACCEPT'
+);
+
+%menu_keyfunc = (
+ 'RET', 'MENU:SELECT',
+ 'SPC', 'MENU:SELECT',
+ 'RIGHT', 'MENU:SELECT',
+ '^[[28~', 'MENU:CLOSE',
+ '^[[2~', 'MENU:CLOSE',
+ 'C-c', 'MENU:CLOSE',
+ 'C-h', 'MENU:CANCEL',
+ 'DEL', 'MENU:CANCEL',
+ 'LEFT', 'MENU:CANCEL',
+ 'C-n', 'MENU:DOWN',
+ 'j', 'MENU:DOWN',
+ 'DOWN', 'MENU:DOWN',
+ 'C-p', 'MENU:UP',
+ 'k', 'MENU:UP',
+ 'UP', 'MENU:UP',
+ 'K', 'MENU:LINE_UP',
+ 'J', 'MENU:LINE_DOWN',
+ 'C-a', 'MENU:TOP',
+ 'C-e', 'MENU:LAST',
+ 'C-f', 'MENU:NEXT',
+ 'C-v', 'MENU:NEXT',
+ '^[[6~', 'MENU:NEXT',
+ 'C-b', 'MENU:PREV',
+ 'ESC-v', 'MENU:PREV',
+ '^[[5~', 'MENU:PREV',
+ 'C-s', 'MENU:SEARCH_FORE',
+ '/', 'MENU:SEARCH_FORE',
+ 'C-r', 'MENU:SEARCH_BACK',
+ '?', 'MENU:SEARCH_BACK',
+ 'n', 'MENU:SEARCH_NEXT',
+ 'N', 'MENU:SEARCH_PREV',
+ 'C-z', 'MENU:SUSPEND',
+);
+
+1;
diff --git a/scripts/w3mhelp.cgi.in b/scripts/w3mhelp.cgi.in
new file mode 100644
index 0000000..135b835
--- /dev/null
+++ b/scripts/w3mhelp.cgi.in
@@ -0,0 +1,323 @@
+#!@PERL@
+# $Id: w3mhelp.cgi.in,v 1.28 2004/03/22 17:03:13 ukai Exp $
+
+if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) {
+ $CYGPATH = 1;
+}
+
+$prefix = "@prefix@";
+$helpdir = "@HELP_DIR@";
+if ($CYGPATH) {
+ $helpdir = &cygwin_pathconv($helpdir);
+}
+unshift(@INC, $helpdir);
+@docdirs = split(" ", "@DOCDIRS@");
+
+require "w3mhelp-funcname.pl";
+require "w3mhelp-funcdesc.en.pl";
+$lang = 'en';
+$charset = 'US-ASCII';
+
+%htmlesc = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;'
+);
+
+$RC_DIR = '@RC_DIR@';
+$RC_DIR =~ s/^~/$ENV{'HOME'}/;
+if ($CYGPATH) {
+ $RC_DIR = &cygwin_pathconv("$RC_DIR");
+}
+$keymap = "$RC_DIR/keymap";
+$version = '*unknown*';
+if (defined($ENV{'QUERY_STRING'})) {
+ print "QUERY_STRING=$ENV{'QUERY_STRING'}\n";
+ if ($ENV{'QUERY_STRING'} =~ /(^|&)version=([^&]*)/) {
+ $version = $2;
+ $version =~ s/\+|%([0-9A-Fa-f][0-9A-Fa-f])/$& eq '+' ? ' ' : pack('C', hex($1))/ge;
+ $version =~ s/w3m\///;
+ }
+ if ($ENV{'QUERY_STRING'} =~ /(^|&)lang=([^&]*)/) {
+ local($tlang) = $2;
+ $tlang =~ s/\+|%([0-9A-Fa-f][0-9A-Fa-f])/$& eq '+' ? ' ' : pack('C', hex($1))/ge;
+ $tlang =~ tr/A-Z/a-z/;
+ if ($tlang !~ /^[a-z][a-z]$/) {
+ $tlang = 'en';
+ }
+ # print "tlang=$tlang\n";
+ eval {require "w3mhelp-funcdesc.$tlang.pl";};
+ if (defined(%funcdesc)) {
+ $lang = $tlang;
+ }
+ }
+}
+
+%f = %keyfunc;
+%keyfunc = ();
+while (($key, $fname) = each %f) {
+ $key = &norm_key($key);
+ $keyfunc{$key} = $fname;
+}
+
+if (-f $keymap) {
+ open(KEYMAP, "< $keymap") || die "cannot open keymap: $keymap, $!";
+ &load_keymap(*KEYMAP, $func);
+ close(KEYMAP);
+}
+
+local (%funckeydesc, $key, $fname, $desc);
+
+%funcname = (%funcname, %buf_funcname, %lineedit_funcname, %menu_funcname);
+
+%funcdesc = (%funcdesc, %buf_funcdesc, %lineedit_funcdesc, %menu_funcdesc);
+while (($fname, $desc) = each %funcdesc) {
+ $funckeydesc{$funcname{$fname}} = "$fname\n$desc\n";
+}
+
+while (($key, $fname) = each %keyfunc) {
+ $keydata{$key} && next;
+ $funckeydesc{$funcname{$fname}} .= "$key,";
+}
+while (($key, $fname) = each %buf_keyfunc) {
+ $funckeydesc{$funcname{$fname}} .= "$key,";
+}
+while (($key, $fname) = each %lineedit_keyfunc) {
+ $funckeydesc{$funcname{$fname}} .= "$key,";
+}
+while (($key, $fname) = each %menu_keyfunc) {
+ $funckeydesc{$funcname{$fname}} .= "$key,";
+}
+
+print <<HEADING;
+Content-Type: text/html; charset=$charset
+
+<HTML>
+<HEAD>
+<TITLE>w3m help page</TITLE>
+</HEAD>
+<BODY>
+<CENTER>
+*******
+<A HREF="http://w3m.sourceforge.net/">w3m</A>
+ (WWW-wo-Miru) Version $version by
+<A HREF="mailto:aito\@fw.ipsj.or.jp">A.ITO</A> ********<BR>
+ ***** Key assign table *****
+</CENTER>
+
+HEADING
+
+$q_version = $version;
+$q_version =~ s/[^A-Za-z0-9_\$\.\-]/sprintf('%%%02X', ord($&))/ge;
+$script = "<A HREF=\"$ENV{'SCRIPT_NAME'}?version=$q_version&amp;lang=";
+
+# doc:en_English doc-jp:ja_Japanese
+for $otherlang (@docdirs) {
+ local(@d) = split(/[:_]/, $otherlang);
+
+ if ($d[1] ne $lang) {
+ $d[1] =~ s/[^A-Za-z0-9_\$\.\-]/sprintf('%%%02X', ord($&))/ge;
+ print $script, $d[1], "\">$d[2] version</A>\n";
+ }
+}
+
+$keymap =~ s/[<>&]/$htmlesc{$&}/ge;
+$head = "Show keymap file";
+if (defined($title{$head})) {
+ $head = $title{$head};
+ $head =~ s/[<>&]/$htmlesc{$&}/ge;
+}
+print "<P><A HREF=\"$keymap\">$head</A>\n";
+
+&show_keymap("Page/Cursor motion",
+ split(" ", "pgFore pgBack movR movL movD movU
+ movR1 movL1 movD1 movU1 ldown1 lup1
+ shiftl shiftr col1L col1R linbeg linend ctrCsrH ctrCsrV
+ goLine goLineF goLineL movRW movLW
+ topA lastA nextA prevA movlistMn
+ nextR nextL nextD nextU nextRD nextLU
+ undoPos redoPos"));
+
+&show_keymap("Hyperlink operation",
+ split(" ", "followA tabA svA followI svI submitForm
+ curURL peekURL peekIMG pginfo curlno chkURL chkWORD chkNMID
+ rFrame extbrz linkbrz linkLst listMn linkMn accessKey"));
+
+&show_keymap("File/Stream operation",
+ split(" ", "goURL gorURL tabURL tabrURL ldfile readsh pipesh
+ pipeBuf"));
+
+&show_keymap("Buffer operation",
+ split(" ", "backBf nextBf prevBf selMn selBuf vwSrc svSrc svBuf
+ editBf editScr reload reshape rdrwSc dispI stopI"));
+
+&show_keymap("Tab operation",
+ split(" ", "newT closeT nextT prevT tabMn tabR tabL"));
+
+&show_keymap("Bookmark operation",
+ split(" ", "ldBmark adBmark"));
+
+&show_keymap("Search",
+ split(" ", "srchfor srchbak srchnxt srchprv isrchfor isrchbak"));
+
+&show_keymap("Dictionary look-up",
+ split(" ", "dictword dictwordat"));
+
+&show_keymap("Mark operation",
+ split(" ", "_mark nextMk prevMk reMark"));
+
+&show_keymap("Miscellany",
+ split(" ", "mainMn ldhelp ldOpt dispVer cooLst ldHist ldDL
+ docCSet defCSet
+ msgs msToggle wrapToggle execCmd setAlarm setOpt setEnv defKey
+ reinit execsh susp qquitfm quitfm"));
+
+&show_keymap_data("User defined keymaps");
+
+print "<BR>\n<HR WIDTH=80%>\n";
+
+&show_keymap("Buffer selection mode",
+ split(" ", "buffer_next buffer_prev buffer_delete buffer_go"));
+
+print "<BR>\n<HR WIDTH=80%>\n";
+
+&show_keymap("Line-edit mode",
+ split(" ", "lineedit_forward lineedit_back lineedit_backspace
+ lineedit_delete lineedit_kill_after lineedit_kill_before
+ lineedit_top lineedit_bottom lineedit_prev lineedit_next
+ lineedit_editor lineedit_complete lineedit_accept"));
+
+print "<BR>\n<HR WIDTH=80%>\n";
+
+&show_keymap("Popup menu",
+ split(" ", "menu_select menu_close menu_cancel menu_down menu_up
+ menu_line_up menu_line_down menu_top menu_last menu_next
+ menu_prev menu_search_fore menu_search_back menu_search_next
+ menu_search_prev menu_suspend"));
+
+print <<PAGE;
+<HR>
+</BODY>
+</HTML>
+PAGE
+
+exit 0;
+
+sub load_keymap {
+ local(*FH) = shift;
+ local($func) = @_;
+
+ while (<FH>) {
+ /^#/ && next;
+ s/^\s*keymap\s+// || next;
+ s/^(\"(\\\"|[^\"])+\"|\'(\\\'|[^\'])+\'|\S+)\s+(\S+)\s*// || next;
+ ($key, $fname) = ($1, $4);
+ $data = $_;
+ $fname =~ tr/a-z/A-Z/;
+ defined($funcdesc{$fname}) || next;
+ $key =~ s/^["'](.*)["']$/$1/;
+ $key = &norm_key($key);
+ $keyfunc{$key} = $fname;
+ if ($data) {
+ $keydata{$key} = $data;
+ } else {
+ delete $keydata{$key};
+ }
+ }
+}
+
+sub norm_key {
+ local($_) = @_;
+
+ s/(ESC|SPC|TAB|DEL|UP|DOWN|RIGHT|LEFT)/\U$1/i;
+ s/\\(.)/$1/g;
+ s/(^|\s+|-)\^(.)/${1}C-$2/g;
+ s/(^|\s+|-)(C-\[|M-)/${1}ESC-/g;
+ if (/^ESC-\[/) {
+ /^ESC-\[A$/ && return "UP";
+ /^ESC-\[B$/ && return "DOWN";
+ /^ESC-\[C$/ && return "RIGHT";
+ /^ESC-\[D$/ && return "LEFT";
+ }
+ s/(^|\s+|-)ESC-\[/$1\^\[\[/g;
+ s/(^|\s+|-)ESC-\^(.)/${1}ESC-C-$2/g;
+ s/(^|\s+|-)(ESC-)?C-[iI]/$1${2}TAB/g;
+ s/(^|\s+|-)(ESC-)?C-\?/$1${2}DEL/g;
+ return $_;
+}
+
+sub show_keymap {
+ local($head, @list) = @_;
+ local($fid);
+ local($attr) = " WIDTH=140";
+
+ if (defined($title{$head})) {
+ $head = $title{$head};
+ $head =~ s/[<>&]/$htmlesc{$&}/ge;
+ }
+
+ print <<PAGE;
+<H2>$head</H2>
+<table cellpadding=0>
+PAGE
+ foreach $fid (@list) {
+ local ($name, $desc, $keys) = split("\n", $funckeydesc{$fid}, 3);
+ $keys =~ s/,$//;
+ $keys = '<NOT ASSIGNED>' if ($keys eq '');
+ $keys =~ s/[<>&]/$htmlesc{$&}/ge;
+ if ($name =~ /:/) {
+ $name = "";
+ } else {
+ $name =~ s/[<>&]/$htmlesc{$&}/ge;
+ $name = " (<b>$name</b>)";
+ }
+ $desc =~ s/[<>&]/$htmlesc{$&}/ge;
+ print <<PAGE;
+<TR><TD$attr>$keys<TD><NOBR>$desc$name</NOBR>
+PAGE
+ $attr = "";
+ }
+ print "</table>\n";
+}
+
+sub show_keymap_data {
+ local($head, @list) = @_;
+ local($fid);
+ local($attr) = " WIDTH=140";
+
+ if (defined($title{$head})) {
+ $head = $title{$head};
+ $head =~ s/[<>&]/$htmlesc{$&}/ge;
+ }
+
+ print <<PAGE;
+<H2>$head</H2>
+<table cellpadding=0>
+PAGE
+ foreach $keys (sort keys %keydata) {
+ $keys =~ s/[<>&]/$htmlesc{$&}/ge;
+ $name = $keyfunc{$keys};
+ $data = $keydata{$keys};
+ $name =~ s/[<>&]/$htmlesc{$&}/ge;
+ $data =~ s/[<>&]/$htmlesc{$&}/ge;
+ print <<PAGE;
+<TR><TD$attr>$keys<TD>$name<TD><NOBR>$data</NOBR>
+PAGE
+ $attr = "";
+ }
+ print "</table>\n";
+}
+
+
+sub cygwin_pathconv {
+ local($_) = @_;
+ local(*CYGPATH);
+
+ open(CYGPATH, '-|') || exec('cygpath', '-w', $_);
+ $_ = <CYGPATH>;
+ close(CYGPATH);
+ s/\r?\n$//;
+ s!\\!/!g;
+ s!/$!!;
+ return $_;
+}
diff --git a/scripts/w3mmail.cgi.in b/scripts/w3mmail.cgi.in
new file mode 100755
index 0000000..670f26c
--- /dev/null
+++ b/scripts/w3mmail.cgi.in
@@ -0,0 +1,403 @@
+#!@PERL@
+
+$rcsid = q$Id: w3mmail.cgi.in,v 1.13 2003/09/22 21:02:29 ukai Exp $;
+($id = $rcsid) =~ s/^.*,v ([\d\.]*).*/$1/;
+($prog=$0) =~ s/.*\///;
+
+$query = $ENV{'QUERY_STRING'};
+$cookie_file = $ENV{'LOCAL_COOKIE_FILE'};
+$local_cookie = '';
+$SENDMAIL = '/usr/lib/sendmail';
+$SENDMAIL = '/usr/sbin/sendmail' if -x '/usr/sbin/sendmail';
+$SENDMAIL_OPT = '-oi -t';
+
+if (-f $cookie_file) {
+ open(F, "< $cookie_file");
+ $local_cookie = <F>;
+ close(F);
+}
+if ($query =~ s/^\w+://) {
+ $url = $query;
+ $qurl = &html_quote($url);
+ $to = $query;
+ $opt = '';
+ if ($to =~ /^([^?]*)\?(.*)$/) {
+ $to = $1;
+ $opt = $2;
+ }
+ $to = &url_unquote($to);
+ %opt = &parse_opt($opt);
+
+ @to = ($to);
+ push(@to, $opt{'to'}) if ($opt{'to'});
+ $opt{'to'} = join(',', @to);
+ if ($ENV{'REQUEST_METHOD'} eq 'POST') {
+ sysread(STDIN, $body, $ENV{'CONTENT_LENGTH'});
+ $content_type = $ENV{'CONTENT_TYPE'};
+ if ($content_type =~ /^multipart\/form-data;\s+boundary=(.*)$/) {
+ $boundary = $1;
+ }
+ } else {
+ $body = $opt{'body'};
+ delete $opt{'body'};
+ }
+ &lang_setup;
+
+ print "Content-Type: text/html; charset=$charset\r\n";
+ print "w3m-control: END\r\n";
+ print "w3m-control: PREV_LINK\r\n";
+ print "\r\n";
+ print "<html><head><title>W3M Mailer: $qurl</title></head>\n";
+ print "<body><h1>W3M Mailer: $qurl</h1>\n";
+ print "<form action=\"file://$0\" method='POST'>\n";
+ $local_cookie = &html_quote($local_cookie);
+ print "<input type='hidden' name='cookie' value=\"$local_cookie\">\n";
+ print "<table>\n";
+ foreach $h ('from', 'to', 'cc', 'bcc', 'subject') {
+ $v = &lang_html_quote($opt{$h});
+ print "<tr><td>\u$h:<td><input type='text' name=\"$h\" value=\"$v\">\n";
+ delete $opt{$h};
+ }
+ if ($boundary) {
+ $boundary = &html_quote($boundary);
+ print "<tr><td>Content-Type:<td>multipart/form-data; boundary=\"$boundary\"\n";
+ print "<input type='hidden' name='boundary' value=\"$boundary\">\n";
+ }
+ foreach $h (keys %opt) {
+ $qh = &html_quote($h);
+ $v = &lang_html_quote($opt{$h});
+ print "<tr><td>\u$h:<td>$v\n";
+ print "<input type='hidden' name=\"$qh\" value=\"$v\">\n";
+ }
+ print "<tr><td colspan=2>\n";
+ print "<textarea cols=40 rows=10 name='body'>\n";
+ if ($body) {
+ print &lang_html_quote($body);
+ }
+ print "</textarea>\n";
+ print "</table>\n";
+ print "<input type='submit' name='action' value='Preview'>\n";
+ print "</form>\n";
+ print "</body></html>\n";
+ exit(0);
+} else {
+ sysread(STDIN, $req, $ENV{'CONTENT_LENGTH'});
+ %opt = &parse_opt($req);
+ if ($local_cookie ne $opt{'cookie'}) {
+ print "Content-Type: text/plain\r\n";
+ print "\r\n";
+ print "Local cookie doesn't match: It may be an illegal execution\n";
+ exit 1;
+ }
+ delete $opt{'cookie'};
+ $body = $opt{'body'};
+ delete $opt{'body'};
+ $act = $opt{'action'};
+ delete $opt{'action'};
+ $boundary = $opt{'boundary'};
+ delete $opt{'boundary'};
+ &lang_setup;
+
+ if ($act eq "Preview") {
+ print "Content-Type: text/html; charset=$charset\r\n";
+ print "w3m-control: DELETE_PREVBUF\r\n";
+ print "w3m-control: NEXT_LINK\r\n";
+ print "\r\n";
+ print "<html><head><title>W3M Mailer</title></head>\n";
+ print "<body>\n";
+ print "<h1>W3M Mailer: preview</h1>\n";
+ print "<form action=\"file://$0\" method='POST'>\n";
+ $local_cookie = &html_quote($local_cookie);
+ print "<input type='hidden' name='cookie' value=\"$local_cookie\">\n";
+ print "<hr>\n";
+ print "<pre>\n";
+ foreach $h (keys %opt) {
+ $qh = &html_quote($h);
+ $v{$h} = &lang_html_quote($opt{$h});
+ if ($v{$h}) {
+ print "\u$qh: $v{$h}\n";
+ }
+ }
+ ($cs,$cte,$body) = &lang_body(&lang_html_quote($body), 0);
+ print "Mime-Version: 1.0\n";
+ if ($boundary) {
+ $boundary = &html_quote($boundary);
+ print "Content-Type: multipart/form-data;\n";
+ print " boundary=\"$boundary\"\n";
+ } else {
+ print "Content-Type: text/plain; charset=$cs\n";
+ }
+# print "Content-Transfer-Encoding: $cte\n";
+ print "User-Agent: ", &html_quote("$ENV{'SERVER_SOFTWARE'} $prog/$id"),
+ "\n";
+ print "\n";
+ print $body;
+ print "\n" if ($body !~ /\n$/);
+ print "</pre>\n";
+ print "<input type='submit' name='action' value='Send'>\n";
+ print "<hr>\n";
+ print "<table>\n";
+ foreach $h ('from', 'to', 'cc', 'bcc', 'subject') {
+ print "<tr><td>\u$h:<td><input type='text' name=\"$h\" value=\"$v{$h}\">\n";
+ delete $opt{$h};
+ }
+ if ($boundary) {
+ print "<tr><td>Content-Type:<td>Content-Type: multipart/form-data; boundary=\"$boundary\"\n";
+ print "<input type='hidden' name=\"boundary\" value=\"$boundary\">\n";
+ }
+ foreach $h (keys %opt) {
+ $qh = &html_quote($h);
+ print "<tr><td>\u$qh:<td>$v{$h}\n";
+ print "<input type='hidden' name=\"$qh\" value=\"$v{$h}\">\n";
+ }
+ print "<tr><td colspan=2>\n";
+ print "<textarea cols=40 rows=10 name=body>\n";
+ if ($body) {
+ print $body;
+ }
+ print "</textarea>\n";
+ print "</table>\n";
+ print "<input type='submit' name='action' value='Preview'><br>\n";
+ print "</body></html>\n";
+ } else {
+# XXX: quote?
+# if ($opt{'from'}) {
+# $sendmail_fromopt = '-f' . $opt{'from'};
+# }
+ unless (open(MAIL, "|$SENDMAIL $SENDMAIL_OPT")) {
+ print "Content-Type: text/html\r\n";
+ print "\r\n";
+ print "<html><head><title>W3M Mailer</title></head>\n";
+ print "<body><h1>W3M Mailer: open sendmail failed</h1>\n";
+ print "<p>", &html_quote($@), "</p>\n";
+ print "</body></html>\n";
+ exit(0);
+ }
+ foreach $h (keys %opt) {
+ $v = &lang_header($opt{$h});
+ if ($v) {
+ print MAIL "\u$h: $v\n";
+ }
+ }
+ ($cs,$cte,$body) = &lang_body($body, 1);
+ print MAIL "Mime-Version: 1.0\n";
+ if ($boundary) {
+ print MAIL "Content-Type: multipart/form-data;\n";
+ print MAIL " boundary=\"$boundary\"\n";
+ } else {
+ print MAIL "Content-Type: text/plain; charset=$cs\n";
+ }
+ print MAIL "Content-Transfer-Encoding: $cte\n";
+ print MAIL "User-Agent: $ENV{'SERVER_SOFTWARE'} $prog/$id\n";
+ print MAIL "\n";
+ print MAIL $body;
+ if (close(MAIL)) {
+ print "w3m-control: DELETE_PREVBUF\r\n";
+ print "w3m-control: BACK\r\n";
+ print "\r\n";
+ } else {
+ print "Content-Type: text/html\r\n";
+ print "\r\n";
+ print "<html><head><title>W3M Mailer</title></head>\n";
+ print "<body><h1>W3M Mailer: close sendmail failed</h1>\n";
+ print "<p>", &html_quote($@), "</p>\n";
+ print "</body></html>\n";
+ }
+ }
+}
+
+sub lang_setup {
+ $lang = $ENV{'LC_ALL'} || $ENV{'LC_CTYPE'} || $ENV{'LANG'};
+ if ($lang =~ /^ja/i) {
+ eval "use NKF;";
+ if (! $@) {
+ $use_NKF = 1;
+ } else {
+ $use_NKF = 0;
+ }
+ $charset = "EUC-JP";
+ } else {
+ $charset = &guess_charset($lang);
+ }
+}
+
+sub lang_header {
+ if ($lang =~ /^ja/i) {
+ return &lang_header_ja(@_);
+ } else {
+ return &lang_header_default(@_);
+ }
+}
+
+sub lang_body {
+ if ($lang =~ /^ja/i) {
+ return &lang_body_ja(@_);
+ } else {
+ return &lang_body_default(@_);
+ }
+}
+
+sub lang_html_quote {
+ local($_) = @_;
+ if ($lang =~ /^ja/i) {
+ if (/[\x80-\xFF]/ || /\033[\$\(][BJ@]/) {
+ $_ = &conv_nkf("-e", $_);
+ }
+ }
+ return &html_quote($_);
+}
+
+sub lang_header_default {
+ local($h) = @_;
+ if ($h =~ s/([=_?\x80-\xFF])/sprintf("=%02x", ord($1))/ge) {
+ return "=?$charset?Q?$h?=";
+ } else {
+ return $h;
+ }
+}
+
+sub lang_body_default {
+ local($body, $_7bit) = @_;
+ if ($body =~ /[\x80-\xFF]/) {
+ if ($_7bit) {
+ $body =~ s/([=\x80-\xFF])/sprintf("=%02x", ord($1))/ge;
+ return ($charset, "quoted-printable", $body);
+ } else {
+ return ($charset, "8bit", $body);
+ }
+ } else {
+ return ("US-ASCII", "7bit", $body);
+ }
+}
+
+sub lang_header_ja {
+ local($h) = @_;
+ if ($h =~ /[\x80-\xFF]/ || $h =~ /\033[\$\(][BJ@]/) {
+ $h = &conv_nkf("-j", $h);
+ &conv_nkf("-M", $h);
+ } else {
+ return $h;
+ }
+}
+
+sub lang_body_ja {
+ local($body, $_7bit) = @_;
+ if ($body =~ /[\x80-\xFF]/ || $body =~ /\033[\$\(][BJ@]/) {
+ if ($_7bit) {
+ $body = &conv_nkf("-j", $body);
+ }
+ return ("ISO-2022-JP", "7bit", $body);
+ } else {
+ return ("US-ASCII", "7bit", $body);
+ }
+}
+
+sub conv_nkf {
+ local(@opt) = @_;
+ if ($use_NKF) {
+ return nkf(@opt);
+ }
+ local($body) = pop(@opt);
+ $body =~ s/\r+\n/\n/g;
+ $| = 1;
+ pipe(R, W2);
+ pipe(R2, W);
+ if (! fork()) {
+ close(F);
+ close(R);
+ close(W);
+ open(STDIN, "<&R2");
+ open(STDOUT, ">&W2");
+ exec "nkf", @opt;
+ die;
+ }
+ close(R2);
+ close(W2);
+ print W $body;
+ close(W);
+ $body = '';
+ while(<R>) {
+ $body .= $_;
+ }
+ close(R);
+ return $body;
+};
+
+
+
+sub parse_opt {
+ local($opt) = @_;
+ local(%opt) = ();
+ if ($opt) {
+ foreach $o (split('&', $opt)) {
+ if ($o =~ /(\w+)=(.*)/) {
+ $opt{"\L$1"} = &url_unquote($2);
+ }
+ }
+ }
+ return %opt;
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub url_unquote {
+ local($_) = @_;
+ s/\+|%([0-9A-Fa-f][0-9A-Fa-f])/$& eq '+' ? ' ' : pack('c', hex($1))/ge;
+ return $_;
+}
+
+sub guess_charset {
+ local(%lang_charset) = (
+ 'cs', 'iso-8859-2',
+ 'el', 'iso-8859-7',
+ 'iw', 'iso-8859-8',
+ 'ja', 'EUC-JP',
+ 'ko', 'EUC-KR',
+ 'hu', 'iso-8859-2',
+ 'pl', 'iso-8859-2',
+ 'ro', 'iso-8859-2',
+ 'ru', 'iso-8859-5',
+ 'sk', 'iso-8859-2',
+ 'sl', 'iso-8859-2',
+ 'tr', 'iso-8859-9',
+ 'zh', 'GB2312',
+ );
+ local($_) = @_;
+ local($lang);
+
+ if (! s/\.(.*)$//) {
+ if (/^zh_tw/i) {
+ return 'Big5';
+ }
+ /^(..)/;
+ return $lang_charset{$1} || 'iso-8859-1';
+ }
+ $lang = $_;
+ $_ = $1;
+ if (/^euc/i) {
+ if (/^euc$/i) {
+ $lang =~ /^zh_tw/ && return 'EUC-TW';
+ $lang =~ /^zh/ && return 'GB2312';
+ $lang =~ /^ko/ && return 'EUC-KR';
+ return 'EUC-JP';
+ }
+ /^euccn/i && return 'GB2312';
+ s/[\-_]//g;
+ s/^euc/EUC-/i;
+ tr/a-z/A-Z/;
+ } elsif (/^iso8859/i) {
+ s/[\-_]//g;
+ s/^iso8859/iso-8859-/i;
+ }
+ return $_;
+}
diff --git a/scripts/w3mman/.cvsignore b/scripts/w3mman/.cvsignore
new file mode 100644
index 0000000..e867c6e
--- /dev/null
+++ b/scripts/w3mman/.cvsignore
@@ -0,0 +1,5 @@
+w3mman
+w3mman2html.cgi
+w3mman.1
+
+Makefile
diff --git a/scripts/w3mman/Makefile.in b/scripts/w3mman/Makefile.in
new file mode 100644
index 0000000..ab941c5
--- /dev/null
+++ b/scripts/w3mman/Makefile.in
@@ -0,0 +1,96 @@
+@SET_MAKE@
+SHELL=@SHELL@
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+DOMAIN = $(PACKAGE)
+srcidr=@srcdir@
+top_srcdir=@top_srcdir@
+VPATH= $(srcdir):.
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+datadir = @datadir@
+libdir = @libdir@
+includedir = @includedir@
+infodir = @infodir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+top_srcdir = @top_srcdir@
+VPATH = $(top_srcdir):.
+DESTDIR =
+
+CGIBIN_DIR = $(libexecdir)/$(PACKAGE)/cgi-bin
+AUXBIN_DIR = $(libexecdir)/$(PACKAGE)
+HELP_DIR = @HELP_DIR@
+RC_DIR = @RC_DIR@
+ETC_DIR = $(sysconfdir)
+CONF_DIR = $(sysconfdir)/$(PACKAGE)
+BIN_DIR = $(bindir)
+MAN1_DIR = $(mandir)/man1
+
+TARGETS = w3mman
+CGIBIN_TARGETS = w3mman2html.cgi
+MAN1_TARGETS = w3mman.1
+MAN_TARGETS = $(MAN1_TARGETS)
+
+MKDIR = mkdir -p
+INSTALL = @INSTALL@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_MAN = @INSTALL_DATA@
+
+all: $(TARGETS) $(CGIBIN_TARGETS) $(MAN_TARGETS)
+
+# do nothing
+$(TARGETS) $(CGIBIN_TARGETS) $(MAN_TARGETS):
+
+install: $(TARGETS) $(CGIBIN_TARGETS) $(MAN_TARGETS)
+ -$(MKDIR) $(DESTDIR)$(BIN_DIR)
+ -$(MKDIR) $(DESTDIR)$(CGIBIN_DIR)
+ -$(MKDIR) $(DESTDIR)$(MAN1_DIR)
+ for file in $(TARGETS); \
+ do \
+ $(INSTALL_SCRIPT) $$file $(DESTDIR)$(BIN_DIR); \
+ done
+ for file in $(CGIBIN_TARGETS); \
+ do \
+ $(INSTALL_SCRIPT) $$file $(DESTDIR)$(CGIBIN_DIR); \
+ done
+ for file in $(MAN1_TARGETS); \
+ do \
+ $(INSTALL_MAN) $$file $(DESTDIR)$(MAN1_DIR); \
+ done
+
+uninstall:
+ -for file in $(TARGETS); \
+ do \
+ rm -f $(BIN_DIR)/$$file; \
+ done
+ -for file in $(CGIBIN_TARGETS); \
+ do \
+ rm -f $(CGIBIN_DIR)/$$file; \
+ done
+ -for file in $(MAN1_TARGETS); \
+ do \
+ rm -f $(MAN1_DIR)/$$file; \
+ done
+
+clean:
+
+distclean:
+ -rm -f $(TARGETS) $(CGIBIN_TARGETS) $(MAN_TARGETS)
+ -rm -f Makefile
+
+dist: all
+ @-rm -fr $(distdir)/w3mman
+ -$(MKDIR) $(distdir)/w3mman
+ cp Makefile README w3mman.in w3mman2html.cgi.in hlink.cgi w3mman.1.in $(distdir)/w3mman
+ ( cd $(distdir); tar -cf - w3mman | GZIP='' gzip ) \
+ > $(distdir)/w3mman.tar.gz
+ -rm -fr $(distdir)/w3mman
+
diff --git a/scripts/w3mman/README b/scripts/w3mman/README
new file mode 100644
index 0000000..3bcbb3b
--- /dev/null
+++ b/scripts/w3mman/README
@@ -0,0 +1,54 @@
+
+w3mman
+
+ ¾�Υޥ˥奢���إå��ե�����˥�󥯤�Ϥ뤳�Ȥ��Ǥ���
+ man ���ޥ�ɤ����إ��ޥ�ɤǤ���
+
+����ˡ
+
+ w3mman
+ w3mman <command>[(<section>)]
+ w3mman [<section>] <command>
+ w3mman -k <keyword>
+
+�Ķ��ѿ�
+
+ W3MMAN_W3M
+ ���Ѥ��� w3m ���ޥ�ɤ���ꤷ�ޤ�(�ǥե���Ȥ� w3m)
+ W3MMAN_MAN
+ ���Ѥ��� man ���ޥ�ɤ���ꤷ�ޤ�(�ǥե���Ȥ� man)
+
+���󥹥ȡ���
+
+ make install
+ ɬ�פʤ� PERL, MAN, LIBDIR �����ꤷ�Ƥ���������
+ w3mman2html.cgi �⥤�󥹥ȡ��뤵��ޤ���
+
+================
+
+w3mman2html.cgi
+
+����ˡ
+
+ w3m file:///$LIB/w3mman2html.cgi
+ w3m file:///$LIB/w3mman2html.cgi?<command>[(<section>)]
+ w3m file:///$LIB/w3mman2html.cgi?man=<command>[&section=<section>]
+ w3m file:///$LIB/w3mman2html.cgi?keyword=<keyword>
+
+���󥹥ȡ���
+
+ make install
+ ɬ�פʤ� PERL, MAN, LIBDIR �����ꤷ�Ƥ���������
+ w3mman �⥤�󥹥ȡ��뤵��ޤ���
+
+================
+
+hlink.cgi
+
+ �إå��ե�����ʤɤ˥�󥯤�ĥ��
+
+���󥹥ȡ���
+
+ /$LIB/ �˥��ԡ�
+ w3mman2html.cgi �ǻ��Ѥ���ʤ�� $CGI2 �����ꤷ�Ƥ���������
+
diff --git a/scripts/w3mman/hlink.cgi b/scripts/w3mman/hlink.cgi
new file mode 100644
index 0000000..a92ac1d
--- /dev/null
+++ b/scripts/w3mman/hlink.cgi
@@ -0,0 +1,97 @@
+#!/usr/local/bin/perl
+
+$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0;
+$CGI = "file://$SCRIPT_NAME?";
+
+if ($ENV{'QUERY_STRING'}) {
+ $file = $ENV{'QUERY_STRING'};
+} else {
+ $file = $ARGV[0];
+}
+$file = &cleanup($file);
+
+if (-d $file) {
+ print <<EOF;
+Location: file:$file
+EOF
+ exit;
+}
+if (! open(FILE, "< $file")) {
+ $file = &html_quote($file);
+ $_ = "$file: " . &html_quote($!);
+ print <<EOF;
+Content-Type: text/html
+
+<head><title>$file</title></head>
+<b>$_</b>
+EOF
+ exit 1;
+}
+
+$file = &html_quote($file);
+($dir = $file) =~ s@[^/]*$@@;
+
+print <<EOF;
+Content-Type: text/html
+
+<head><title>$file</title></head>
+<pre>
+EOF
+while (<FILE>) {
+ $_ = &html_quote($_);
+
+ s/^(\#\s*include\s+)(\&quot;.*\&quot;|\&lt\;.*\&gt\;)/$1 . &header_ref($2)/ge;
+
+ print;
+}
+close(FILE);
+print "</pre>\n";
+
+sub header_ref {
+ local($_) = @_;
+ local($d);
+
+ if (s/^\&quot;//) {
+ s/\&quot;$//;
+ return "&quot;<a href=\"$CGI$dir$_\">$_</a>&quot;";
+ }
+ s/^\&lt\;//;
+ s/\&gt\;$//;
+
+ for $d (
+ "/usr/include",
+ "/usr/local/include",
+ "/usr/X11R6/include",
+ "/usr/X11/include",
+ "/usr/X/include",
+ "/usr/include/X11"
+ ) {
+ -f "$d/$_" && return "&lt;<a href=\"$CGI$d/$_\">$_</a>&gt;";
+ }
+ return $_;
+}
+
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub cleanup {
+ local($_) = @_;
+
+ s@//+@/@g;
+ s@/\./@/@g;
+ while(m@/\.\./@) {
+ s@^/(\.\./)+@/@;
+ s@/[^/]+/\.\./@/@;
+ }
+ return $_;
+}
diff --git a/scripts/w3mman/w3mman.1.in b/scripts/w3mman/w3mman.1.in
new file mode 100644
index 0000000..eb30237
--- /dev/null
+++ b/scripts/w3mman/w3mman.1.in
@@ -0,0 +1,53 @@
+.TH W3MMAN 1 "Mar 14, 2002"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh disable hyphenation
+.\" .hy enable hyphenation
+.\" .ad l left justify
+.\" .ad b justify to both left and right margins
+.\" .nf disable filling
+.\" .fi enable filling
+.\" .br insert line break
+.\" .sp <n> insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+w3mman \- an interface to the on-line reference manuals by w3m(1)
+.SH SYNOPSIS
+.B w3mman
+.RI "[-M " path ] " " [ section ] " page"
+.br
+.B w3mman
+.RI "[-M " path "] -k " keyword
+.SH DESCRIPTION
+.B w3mman
+is the system's manual pager by
+.BR w3m (1).
+.SH OPTIONS
+A summary of options is included below.
+.TP
+.BI \-M " path"
+Specify
+.I path
+as MANPATH.
+.TP
+.B \-k " keyword"
+Specify
+.I keyword.
+.SH ENVIRONMENT
+.TP
+.B W3MMAN_W3M
+If W3MMAN_W3M is set, its value is used instead of @W3M@.
+.TP
+.B W3MMAN_MAN
+If W3MMAN_MAN is set, its value is used instead of @MAN@.
+.SH FILES
+.TP
+.I @libexecdir@/@PACKAGE@/cgi-bin/w3mman2html.cgi
+convert manual page to html.
+.SH SEE ALSO
+.BR man (1),
+.BR w3m (1).
+.SH AUTHOR
+This manual page was written by Fumitoshi UKAI <ukai@debian.or.jp>,
+for the Debian GNU/Linux system (but may be used by others).
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 $_;
+}
+
diff --git a/scripts/w3mman/w3mman2html.cgi.in b/scripts/w3mman/w3mman2html.cgi.in
new file mode 100644
index 0000000..f41d487
--- /dev/null
+++ b/scripts/w3mman/w3mman2html.cgi.in
@@ -0,0 +1,274 @@
+#!@PERL@
+
+$MAN = $ENV{'W3MMAN_MAN'} || '@MAN@';
+$QUERY = $ENV{'QUERY_STRING'} || $ARGV[0];
+$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0;
+$CGI = "file://$SCRIPT_NAME";
+$CGI2 = "file:";
+# $CGI2 = "file:///\$LIB/hlink.cgi?";
+$SQUEEZE = 1;
+$ENV{'PAGER'} = 'cat';
+
+if ($QUERY =~ /\=/) {
+ for (split('&', $QUERY)) {
+ ($v, $q) = split('=', $_, 2);
+ $query{$v} = &form_decode($q);
+ }
+} else {
+ $QUERY =~ s/^man=//;
+ $query{"man"} = &form_decode($QUERY);
+}
+
+if (! $query{"man"}) {
+ if ($query{"keyword"}) {
+ $keyword = $query{"keyword"};
+ $k = &html_quote($keyword);
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man -k $k</title></head>
+<body>
+<h2>man -k <b>$k</b></h2>
+<ul>
+EOF
+ $keyword =~ s:([^-\w\200-\377.,])::g;
+ open(F, "$MAN -k $keyword 2> /dev/null |");
+ @line = ();
+ while(<F>) {
+ chop;
+ $_ = &html_quote($_);
+ s/(\s+-.*)$//;
+ $title = $1;
+ s@(\w[\w.\-]*(\s*\,\s*\w[\w.\-]*)*)\s*(\([\dn]\w*\))@&keyword_ref($1, $3)@ge;
+ print "<li>$_$title\n";
+ }
+ close(F);
+ print <<EOF;
+</ul>
+</body>
+</html>
+EOF
+ exit;
+ }
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man</title></head>
+<body>
+<form action="$CGI">
+<table>
+<tr><td>Manual:<td><input name=man>
+<tr><td>Section:<td><input name=section>
+<tr><td>Keyword:<td><input name=keyword>
+<tr><td><td><input type=submit> <input type=reset>
+</table>
+</form>
+</body>
+</html>
+EOF
+ exit;
+}
+
+$man = $query{"man"};
+if ($man =~ s/\((\w+)\)$//) {
+ $section = $1;
+ $man_section = "$man($1)";
+} elsif ($query{"section"}) {
+ $section = $query{"section"};
+ $man_section = "$man($section)";
+} else {
+ $section = "";
+ $man_section = "$man";
+}
+
+$section =~ s:([^-\w\200-\377.,])::g;
+$man =~ s:([^-\w\200-\377.,])::g;
+open(F, "$MAN $section $man 2> /dev/null |");
+$ok = 0;
+undef $header;
+$blank = -1;
+$cmd = "";
+$prev = "";
+while(<F>) {
+ if (! defined($header)) {
+ /^\s*$/ && next;
+ $header = $_;
+ $space = $header;
+ chop $space;
+ $space =~ s/\S.*//;
+ } elsif ($_ eq $header) { # delete header
+ $blank = -1;
+ next;
+ } elsif (!/\010/ && /^$space[\w\200-\377].*\s\S/o) { # delete footer
+ $blank = -1;
+ next;
+ }
+ if ($SQUEEZE) {
+ if (/^\s*$/) {
+ $blank || $blank++;
+ next;
+ } elsif ($blank) {
+ $blank > 0 && print "\n";
+ $blank = 0;
+ }
+ }
+
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+
+ s@([\200-\377].)(\010{1,2}\1)+@<b>$1</b>@g;
+ s@(\&\w+;|.)(\010\1)+@<b>$1</b>@g;
+ s@__\010{1,2}((\<b\>)?[\200-\377].(\</b\>)?)@<u>$1</u>@g;
+ s@_\010((\<b\>)?(\&\w+\;|.)(\</b\>)?)@<u>$1</u>@g;
+ s@((\<b\>)?[\200-\377].(\</b\>)?)\010{1,2}__@<u>$1</u>@g;
+ s@((\<b\>)?(\&\w+\;|.)(\</b\>)?)\010_@<u>$1</u>@g;
+ s@.\010(.)@$1@g;
+
+ s@\</b\>\</u\>\<b\>_\</b\>\<u\>\<b\>@_@g;
+ s@\</u\>\<b\>_\</b\>\<u\>@_@g;
+ s@\</u\>\<u\>@@g;
+ s@\</b\>\<b\>@@g;
+
+ if (! $ok) {
+ /^No/ && last;
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man $man_section</title></head>
+<body>
+<pre>
+EOF
+ print;
+ $ok = 1;
+ next;
+ }
+
+ s@(http|ftp)://[\w.\-/~]+[\w/]@<a href="$&">$&</a>@g;
+ s@(\W)(mailto:)?(\w[\w.\-]*\@\w[\w.\-]*\.[\w.\-]*\w)@$1<a href="mailto:$3">$2$3</a>@g;
+ s@(\W)(\~?/[\w.][\w.\-/~]*)@$1 . &file_ref($2)@ge;
+ s@(include(<\/?[bu]\>|\s)*\&lt;)([\w.\-/]+)@$1 . &include_ref($3)@ge;
+ if ($prev && m@^\s*(\<[bu]\>)*(\w[\w.\-]*)(\</[bu]\>)*(\([\dm]\w*\))@) {
+ $cmd .= "$2$4";
+ $prev =~ s@(\w[\w.\-]*-)((\</[bu]\>)*\s*)$@<a href="$CGI?$cmd">$1</a>$2@;
+ print $prev;
+ $prev = '';
+ s@^(\s*(\<[bu]\>)*)(\w[\w.\-]*)@@;
+ print "$1<a href=\"$CGI?$cmd\">$3</a>";
+ } elsif ($prev) {
+ print $prev;
+ $prev = '';
+ }
+ s@(\w[\w.\-]*)((\</[bu]\>)*)(\([\dm]\w*\))@<a href="$CGI?$1$4">$1</a>$2$4@g;
+ if (m@(\w[\w.\-]*)-(\</[bu]\>)*\s*$@) {
+ $cmd = $1;
+ $prev = $_;
+ next;
+ }
+ print;
+}
+if ($prev) {
+ print $prev;
+}
+close(F);
+if (! $ok) {
+ if ($query{'quit'}) {
+ print STDERR "No manual entry for $man_section.\n";
+ print <<EOF;
+w3m-control: EXIT
+EOF
+ exit 1;
+ }
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man $man_section</title></head>
+<body>
+<pre>
+EOF
+ print "No manual entry for <B>$man_section</B>.\n";
+}
+print <<EOF;
+</pre>
+</body>
+</html>
+EOF
+
+sub is_command {
+ local($_) = @_;
+ local($p);
+
+ (! -d && -x) || return 0;
+ if (! defined(%PATH)) {
+ for $p (split(":", $ENV{'PATH'})) {
+ $p =~ s@/+$@@;
+ $PATH{$p} = 1;
+ }
+ }
+ s@/[^/]*$@@;
+ return defined($PATH{$_});
+}
+
+sub file_ref {
+ local($_) = @_;
+
+ if (&is_command($_)) {
+ ($man = $_) =~ s@.*/@@;
+ return "<a href=\"$CGI?$man\">$_</a>";
+ }
+ if (/^\~/ || -f || -d) {
+ return "<a href=\"$CGI2$_\">$_</a>";
+ }
+ return $_;
+}
+
+sub include_ref {
+ local($_) = @_;
+ local($d);
+
+ for $d (
+ "/usr/include",
+ "/usr/local/include",
+ "/usr/X11R6/include",
+ "/usr/X11/include",
+ "/usr/X/include",
+ "/usr/include/X11"
+ ) {
+ -f "$d/$_" && return "<a href=\"$CGI2$d/$_\">$_</a>";
+ }
+ return $_;
+}
+
+sub keyword_ref {
+ local($_, $s) = @_;
+ local(@a) = ();
+
+ for (split(/\s*,\s*/)) {
+ push(@a, "<a href=\"$CGI?$_$s\">$_</a>");
+ }
+ return join(", ", @a) . $s;
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub form_decode {
+ local($_) = @_;
+ s/\+/ /g;
+ s/%([\da-f][\da-f])/pack('c', hex($1))/egi;
+ return $_;
+}
+
diff --git a/scripts/xface2xbm.in b/scripts/xface2xbm.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/xface2xbm.in
diff --git a/scripts/xface2xpm.in b/scripts/xface2xpm.in
new file mode 100644
index 0000000..30253cb
--- /dev/null
+++ b/scripts/xface2xpm.in
@@ -0,0 +1,94 @@
+#!@PERL@
+
+$USAGE = "xface2xpm [-t] [-fg <color>] [-bg <color>] [<file>]";
+
+# compface/uncompface
+# ftp://metalab.unc.edu/pub/Linux/apps/graphics/convert/
+$UNCOMPFACE = "uncompface";
+
+$T = "c";
+$BG = "white";
+$FG = "black";
+while (@ARGV) {
+ $_ = shift @ARGV;
+ if (/^-h/) {
+ &usage(0);
+ } elsif (/^-t/) {
+ $T = "s";
+ $BG = "none";
+ } elsif (/^-bg/) {
+ @ARGV || &usage(1);
+ $BG = shift @ARGV;
+ } elsif (/^-fg/) {
+ @ARGV || &usage(1);
+ $FG = shift @ARGV;
+ } elsif (/^-./) {
+ &usage(1);
+ } else {
+ unshift(@ARGV, $_);
+ last;
+ }
+}
+
+$xf = "";
+while(<>) {
+# s/^X-Face://i if ($xf eq "");
+ $xf .= $_;
+}
+
+pipe(R, W2);
+pipe(R2, W);
+if (! fork()) {
+ close(R);
+ close(W);
+ open(STDIN, "<&R2");
+ open(STDOUT, ">&W2");
+ exec $UNCOMPFACE;
+ exit 1;
+}
+close(R2);
+close(W2);
+print W $xf;
+close(W);
+while(<R>) {
+ while(s/0x(..)(..)//) {
+ push(@bm, hex($1), hex($2));
+ }
+}
+close(R);
+@bm || exit 1;
+
+$W = 48;
+$H = @bm * 8 / $W; # must be 48
+print <<EOF;
+/* XPM */
+static char *xf[] = {
+/* columns rows colors chars-per-pixel */
+"$W $H 2 1",
+" $T $BG",
+". c $FG",
+/* pixels */
+EOF
+while (@bm) {
+ print "\"";
+ for (1..6) {
+ $x = shift @bm;
+ for $i (1 .. 8) {
+ print ((($x >> (8-$i)) & 1) ? "." : " ");
+ }
+ }
+ print (@bm ? "\",\n" : "\"\n");
+}
+print <<EOF;
+};
+EOF
+
+sub usage {
+ local($err) = @_;
+ if ($err) {
+ print STDERR "$USAGE\n";
+ } else {
+ print "$USAGE\n";
+ }
+ exit $err;
+}