Update to w3m-0.2.1-inu-1.6.

This commit is contained in:
Akinori Ito
2001-11-15 00:32:13 +00:00
parent 6c63633545
commit 85da7ee692
82 changed files with 10900 additions and 217 deletions

View File

@@ -0,0 +1,35 @@
prefix = /usr/local
bindir = $(prefix)/bin
libdir = $(prefix)/lib
distdir = ./distfiles
W3M_LIBDIR = $(libdir)/w3m
INSTALL = install -c
INSTALL_SCRIPT = $(INSTALL) -m 755
PERL = /usr/local/bin/perl
NKF = /usr/local/bin/nkf
all: multipart.cgi
multipart.cgi: multipart.cgi.in Makefile
sed -e 's%@PERL@%$(PERL)%g' \
-e 's%@NKF@%$(NKF)%g' \
multipart.cgi.in > multipart.cgi
chmod +x multipart.cgi
install: multipart.cgi
$(INSTALL_SCRIPT) multipart.cgi $(W3M_LIBDIR)
dist: all
@-rm -fr $(distdir)/multipart
mkdir -p $(distdir)/multipart
cp Makefile README multipart.cgi multipart.cgi.in \
$(distdir)/multipart
( cd $(distdir); \
tar -cf - multipart | GZIP='' gzip ) \
> $(distdir)/multipart.tar.gz
-rm -fr $(distdir)/multipart

24
scripts/multipart/README Normal file
View File

@@ -0,0 +1,24 @@
Content-Type: multipart/* <20>򰷤<EFBFBD> local-CGI
Content-Type: multipart/* <20>ʥե<CAA5><D5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򰷤<EFBFBD><F2B0B7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> local-CGI <20>Ǥ<EFBFBD><C7A4><EFBFBD>
<20><><EFBFBD><EFBFBD> mailx <20>ʤɤǥ᡼<C7A5><E1A1BC><EFBFBD><EFBFBD> PAGER="w3m -m" <20><><EFBFBD>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>󥹥ȡ<EFBFBD><EFBFBD><EFBFBD>
* make install
ɬ<>פʤ<D7A4> PERL, NKF, W3M_LIBDIR <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* mailcap <20><> ~/.w3m/mailcap <20>˥ޡ<CBA5><DEA1><EFBFBD>
multipart.cgi <20>Υѥ<CEA5><D1A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* w3m <20><> Option Setting Panel <20>ǡ<EFBFBD>
<20><><EFBFBD><EFBFBD>¸<EFBFBD><C2B8><EFBFBD><EFBFBD> Content-Transfer-Encoding <20><><EFBFBD>ǥ<EFBFBD><C7A5><EFBFBD><EFBFBD>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD>٤<EFBFBD> ON
ź<>եե<D5A5><D5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><C2B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>
ɬ<EFBFBD>פʤ<EFBFBD><EFBFBD><EFBFBD>
* NKF <20><EFBFBD><EFBFBD><E5A1BC><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD> nkf
ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD> MIME <20>إå<D8A5><C3A5>Υǥ<CEA5><C7A5><EFBFBD><EFBFBD>ɤˤ<C9A4><CBA4>ȤäƤޤ<C6A4><DEA4><EFBFBD>
<20><><EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѥ<EFBFBD><D1A4>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@@ -0,0 +1 @@
multipart/*; /usr/local/lib/w3m/multipart.cgi %s %{boundary}; htmloutput

View File

@@ -0,0 +1,272 @@
#!/usr/local/bin/perl
if ($use_NKF = eval "use NKF;") {
$CONV = "-e";
$MIME_DECODE = "-m -e";
} else {
# $CONV = "w3m -dump -e";
$CONV = "/usr/local/bin/nkf -e";
$MIME_DECODE = "/usr/local/bin/nkf -m -e";
}
$MIME_TYPE = "$ENV{'HOME'}/.mime.types";
if (defined($ENV{'QUERY_STRING'})) {
for (split('&', $ENV{'QUERY_STRING'})) {
s/^([^=]*)=//;
$v{$1} = $_;
}
$file = &form_decode($v{'file'});
$boundary = &form_decode($v{'boundary'});
} else {
$file = $ARGV[0];
if (@ARGV >= 2) {
$boundary = $ARGV[1];
}
$CGI = "file:///\$LIB/multipart.cgi?file=" . &html_quote($file);
}
open(F, $file);
$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";
}
}
$CGI .= "&boundary=" . &html_quote($boundary);
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*//) {
$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"};
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;
}
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"};
if ((! $type || $type =~ /^text\/plain/i) &&
(! $dispos || $dispos =~ /^inline/i)) {
$plain = 1;
} else {
$plain = 0;
}
$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 $_;
if ($type =~ /name=\"?([^\"]+)\"?/ ||
$dispos =~ /filename=\"?([^\"]+)\"?/) {
$name = $1;
} else {
$name = "[Content]";
}
print "\n<a href=\"$CGI&count=$count\">", &html_quote($name), "</a>";
print "\n\n</pre>\n";
}
if ($plain) {
$body = &decode($body, $CONV);
$_ = $body;
s/\&/\&amp;/g;
s/\</\&lt;/g;
s/\>/\&gt;/g;
print "<pre>\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 guess_type {
local($_) = @_;
/\.(\w+)$/ || next;
$_ = $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;
}

View File

@@ -0,0 +1,272 @@
#!@PERL@
if ($use_NKF = eval "use NKF;") {
$CONV = "-e";
$MIME_DECODE = "-m -e";
} else {
# $CONV = "w3m -dump -e";
$CONV = "@NKF@ -e";
$MIME_DECODE = "@NKF@ -m -e";
}
$MIME_TYPE = "$ENV{'HOME'}/.mime.types";
if (defined($ENV{'QUERY_STRING'})) {
for (split('&', $ENV{'QUERY_STRING'})) {
s/^([^=]*)=//;
$v{$1} = $_;
}
$file = &form_decode($v{'file'});
$boundary = &form_decode($v{'boundary'});
} else {
$file = $ARGV[0];
if (@ARGV >= 2) {
$boundary = $ARGV[1];
}
$CGI = "file:///\$LIB/multipart.cgi?file=" . &html_quote($file);
}
open(F, $file);
$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";
}
}
$CGI .= "&boundary=" . &html_quote($boundary);
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*//) {
$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"};
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;
}
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"};
if ((! $type || $type =~ /^text\/plain/i) &&
(! $dispos || $dispos =~ /^inline/i)) {
$plain = 1;
} else {
$plain = 0;
}
$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 $_;
if ($type =~ /name=\"?([^\"]+)\"?/ ||
$dispos =~ /filename=\"?([^\"]+)\"?/) {
$name = $1;
} else {
$name = "[Content]";
}
print "\n<a href=\"$CGI&count=$count\">", &html_quote($name), "</a>";
print "\n\n</pre>\n";
}
if ($plain) {
$body = &decode($body, $CONV);
$_ = $body;
s/\&/\&amp;/g;
s/\</\&lt;/g;
s/\>/\&gt;/g;
print "<pre>\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 guess_type {
local($_) = @_;
/\.(\w+)$/ || next;
$_ = $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;
}