Skip to content

Commit

Permalink
Adding upstream version 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tats committed May 4, 2011
1 parent adc0f0a commit 72f72d6
Show file tree
Hide file tree
Showing 403 changed files with 329,486 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .cvsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
XXMakefile
Makefile
config.cache
config.log
config.status
config.h
config.param
funcname.tab
funcname.c
funcname1.h
funcname2.h
functable.c
tagtable.c
inflate
mktable
w3m
w3mbookmark
w3mhelperpanel
w3mimgdisplay
version.c
w3mhelp-lynx_en.html
w3mhelp-lynx_ja.html
w3mhelp-w3m_en.html
w3mhelp-w3m_ja.html
posubst
625 changes: 625 additions & 0 deletions ABOUT-NLS

Large diffs are not rendered by default.

204 changes: 204 additions & 0 deletions Bonus/2ch.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
#!/usr/bin/perl

$WGET = "wget";
$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0;
$CGI = "file://$SCRIPT_NAME";
$_ = $QUERY_STRING = $ENV{"QUERY_STRING"};
$UserAgent = "Monazilla/1.00 (w3m/2ch.cgi)";

if (/subback.html$/) {
&subback();
exit;
}

s@/(\d+)(/([^/]*))?$@/$1@ || exit;
my $datnum = $1;
$label = $3;
$cgi = "$CGI?$_";

s@^http://([^/]+)/test/read.cgi/([^/]+)/@$1/$2/dat/@ || exit;
$subback = "$CGI?http://$1/$2/subback.html";
$bbs = $2;
if ($ENV{REQUEST_METHOD} eq "POST") {
&post();
exit;
}

$_ .= ".dat";
$dat = "http://$_";
$tmp = $ENV{"HOME"} . "/.w3m2ch/$_";
$dat =~ s/([^\w\/.\:\-])/\\$1/g;
$tmp =~ s/([^\w\/.\:\-])/\\$1/g;
($dir = $tmp) =~ s@/[^/]+$@@;
$cmd = "mkdir -p $dir; $WGET -c -U \"$UserAgent\" -O $tmp $dat >/dev/null 2>&1";
system $cmd;
$lines = (split(" ", `wc $tmp`))[0];
$lines || exit;

@ARGV = ($tmp);
if ($label =~ /^l(\d+)/) {
$start = $lines - $1 + 1;
if ($start < 1) {
$start = 1;
}
$end = $lines;
} elsif ($label =~ /^(\d+)-(\d+)/) {
$start = $1;
$end = $2;
} elsif ($label =~ /^(\d+)-/) {
$start = $1;
$end = $start + 100 - 1;
} elsif ($label =~ /^(\d+)/) {
$start = $1;
$end = $1;
} else {
$start = 1;
$end = $lines;
}
$head = "<a href=\"$subback\">■掲示板に戻る■</a>\n";
$head .= "<a href=\"$cgi/\">全部</a>\n";
for (0 .. ($lines - 1) / 100) {
$n = $_ * 100 + 1;
$head .= "<a href=\"$cgi/$n-\">$n-</a>\n";
}
$head .= "<a href=\"$cgi/l50\">最新50</a>\n";
print <<EOF;
Content-Type: text/html
EOF
$i = 1;
while (<>) {
s/\r?\n$//;
($name, $mail, $date, $_, $title) = split(/\<\>/);
if ($i == 1) {
if (!$title) {
print <<EOF;
このスレッドは過去ログ倉庫に格納されています。
<p>
<a href="$QUERY_STRING">$QUERY_STRING</a>
EOF
unlink($tmp);
exit
}
print <<EOF;
<title>$title</title>
$head
<p>$title</p>
<dl>
EOF
}
if ($mail) {
$name = "<a href=\"mailto:$mail\">$name</a>";
}
s@http://ime.nu/@http://@g;
s@(h?ttp:)([#-~]+)@"<a href=\"" . &link("http:$2") . "\">$1$2</a>"@ge;
s@(ftp:[#-~]+)@<a href="$1">$1</a>@g;
s@<a href="../test/read.cgi/\w+/\d+/@<a href="$cgi/@g;
if ($i == 1 || ($i >= $start && $i <= $end)) {
print <<EOF;
<dt><a name="$i">$i</a> :$name$date
<dd>
$_
<p>
EOF
}
$i++;
}
print <<EOF;
</dl>
<hr>
<form method=POST action="$cgi"><input type=submit value="書き込む" name=submit> 名前: <input name=FROM size=19> E-mail<font size=1> (省略可) </font>: <input name=mail size=19><br><textarea rows=5 cols=70 wrap=off name=MESSAGE></textarea><input type=hidden name=bbs value=$bbs><input type=hidden name=key value=$datnum><input type=hidden name=time value=@{[time]}></form></body></html>
EOF

sub link {
local($_) = @_;
if (m@/test/read.cgi/@) {
return "$CGI?$_";
}
return $_;
}

sub subback {
$dat = $_;
s@http://@@ || exit;
$tmp = $ENV{"HOME"} . "/.w3m2ch/$_";
$dat =~ s/([^\w\/.\:\-])/\\$1/g;
$tmp =~ s/([^\w\/.\:\-])/\\$1/g;
($dir = $tmp) =~ s@/[^/]+$@@;
$cmd = "mkdir -p $dir; $WGET -O $tmp $dat >/dev/null 2>&1";
system $cmd;
print <<EOF;
Content-Type: text/html
EOF
@ARGV = ($tmp);
while (<>) {
if (/<base href="([^"]+)"/) {
$base = $1;
} elsif ($base) {
s@^<a href="@<a href="$CGI?$base@;
}
print;
}
unlink($tmp);
}

sub post {
my $debug = 0;

$| = 1;
use IO::Socket;
my @POST = <>;
$QUERY_STRING =~ m@^http://([^/]+)@;
my $host = $1;
my $sock = IO::Socket::INET->new("$host:80") or die;
# retrieve posting cookie; this may not work
print "Content-Type: text/html\n\n";
print $sock
"HEAD /test/bbs.cgi HTTP/1.1\n",
"Host: $host\n",
"Connection: keep-alive\n",
"\n";
my $posting_cookie = undef;
while (<$sock>) {
print if ($debug);
s/[\n\r]+$//;
last if (/^$/);
if (/^set-cookie:.*(PON=[^;]+)/i) {
$posting_cookie = $1;
}
}
#$sock = IO::Socket::INET->new("$host:80") or die;
my $submit =
"POST /test/bbs.cgi HTTP/1.1\n" .
"Host: $host\n" .
"Accept-Language: ja\n" .
"User-Agent: $UserAgent\n" .
"Referer: $QUERY_STRING\n" .
"Cookie: $posting_cookie; NAME=nobody; MAIL=sage\n" .
"Content-Length: " . length(join("", @POST)) . "\n" .
"\n@POST";
print $sock $submit or die;
print "\n-- POSTed contents --\n${submit}\n-- POSTed contents --\n"
if ($debug);
my $chunked = 0;
while (<$sock>) {
s/[\n\r]*$//;
last if (/^$/);
$chunked = 1 if (/^transfer-encoding:\s*chunked/i);
}
my $post_response = "";
while (<$sock>) {
if ($chunked) {
s/[ \r\n]*$//;
my $len = hex($_);
$len > 0 or last;
read($sock, $_, $len);
<$sock>; #skip empty line at the end of chunk.
}
$post_response .= $_;
}
$post_response =~ s/<META content=(\d+);URL=(\S+) http-equiv=refresh>/<META content=$1;URL=$cgi http-equiv=refresh>/im;
print $post_response;
exit;
}
80 changes: 80 additions & 0 deletions Bonus/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
2ch.cgi

[w3m-dev 03635] 2ch.cgi
2ch �� dat ��ľ�ɤߤ��� local CGI �Ǥ���

w3m file:/cgi-bin/2ch.cgi?http://pc.2ch.net/test/read.cgi/unix/1035755937/

wget �κ�ʬž��(-c)��Ȥ��ޤ���
�ɤ�� dat �� ~/.w3m2ch/ �ʲ�����¸���ޤ���
�񤭹��ߤϤǤ��ޤ���

smb.cgi

[w3m-dev 03634] smb.cgi
SMB �˥����������� local CGI �Ǥ���
nmblookup,smbclient ��Ȥ��Τ� sabma �����󥹥ȡ��뤵��Ƥ���
ɬ�פ�����ޤ���
�ѥ���ɤϡ�
1) ~/.w3m/smb �˥ѥ���ɤ����ꤵ��Ƥ��ꡢ
smbclient �� -A ���ץ�����Ȥ���ʤ�
smbclient -A ~/.w3m/smb �Ȥ����Ϥ��ޤ���
2) �Ķ��ѿ� PASSWD_FILE (�ѥ���ɤΤߤΥե�����)������
����Ƥ�����ϡ��Ķ��ѿ� PASSWD_FILE ��Ȥ��ޤ���
3) ~/.w3m/smb �˥ѥ���ɤ����ꤵ��Ƥ���С�
�Ķ��ѿ� PASSWD_FD ��Ȥä�ɸ�����Ϸ�ͳ���Ϥ��ޤ���
�ɤ���ˤ��衢���ޤ��ɤ����ǤϤʤ��Τ� SMB(CIFS)�ץ��ȥ����
�����Ǥ��˾��

google.cgi

[w3m-dev 03625] keymap key SEARCH string

html2latex

HTML��ʸ���LaTeX ���Ѵ����ޤ���Ruby������ץȤǤ����Դ����Ǥ���
�������٤���ˤ�Ω�Ĥ��⤷��ޤ���

����ˡ

html2latex file.html > file.tex

�������֤��Ƥ�����ͳ

makeref �Τ�������ʼ��Ǥ� :-)

makeref

HTML��ʸ����ɤߡ����󥫡����ֹ�򿶤�ޤ����ֹ�򿶤ä�ʸ���
ɸ����Ϥ˽񤭽Ф����Ǹ�ˤ��ΰ�������Ϥ��ޤ���Ruby ������ץȤǤ���

����ˡ

makeref [-url base_url] [file]

-url: ʸ���URL����ꤷ�ޤ�����󥯤ΰ�����Ф��Ȥ��ˡ�����URL��
�䴰���뤿��˻Ȥ��ޤ���

�Х�

HTML�ε��ҥߥ�( &lt; �ǤϤʤ� < ��Ȥ���&... �κǸ�� ; ���դ��ʤ�
��)������ȡ��Ỵ�ʷ�̤ˤʤ뤳�Ȥ�����ޤ���

Ⱦ�ѥ���(JIS X-0201����)���б����Ƥ��ޤ���

htmldump

URL ����HTMLʸ����ɤߡ����󥫡����ֹ�򿶤ä���������ɸ����Ϥ�
�񤭽Ф��ޤ���

����ˡ

dumphtml [URL]

URL ���ά����ȡ�$WWW_HOME �����Ƥ��ɤߤޤ���

�Х�

URL �λؤ�ʸ��HTML�Ǥʤ��ä���硤���襤�����ʤ��Ȥˤʤ�ޤ���
makeref ��ȤäƤ���Τǡ�makeref �����ޤ������Ǥ��ʤ�ʸ���ɽ��
���Ѥˤʤ�ޤ���
77 changes: 77 additions & 0 deletions Bonus/README.eng
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
2ch.cgi

[w3m-dev 03635] 2ch.cgi
localcgi to read 2ch dat directly

w3m file:/cgi-bin/2ch.cgi?http://pc.2ch.net/test/read.cgi/unix/1035755937/

It uses wget -c.
`dat' files are recorded under ~/w3m2ch/.
You can not post.

smb.cgi

[w3m-dev 03634] smb.cgi
localcgi to access SMB.
Since it uses nmblookup, smbclient, you should install samba.
Password can be passed to smbclient:
1) When the password is set by contents of ~/.w3m/smb and
-A option available, `smbclient -A ~/.w3m/smb' is used.
2) When the environment variable PASSWD_FILE, it is used.
3) When the password is set by contents of ~/.w3m/smb,
the password is passed via standrad I/O using
the environment variable PASSWD_FD.

google.cgi

[w3m-dev 03625] keymap key SEARCH string

html2latex

Convert HTML document into LaTeX. Ruby script. incomplete.

Usage:

html2latex file.html > file.tex

Why this script is here?

To exploit code for makeref. :-)

makeref

Read HTML document and number the anchors. Print numbered document
into standard output and append reference index. Ruby script.

Usage:

makeref [-u] [-url base_url] [file]

-url: Specify URL of the document. It is used to complete link
in the document.

-u: Append URL after each anchor, instead of reference number.

Bugs

If there are any error in HTML (unbalanced < , character entity
without ; , etc.), output will be miserable.

htmldump

Read HTML document from URL, number the anchors and format it,
and output it on standard output.

Usage

htmldump [-u] [URL]

-u: Append URL after each anchor, instead of reference number.

If URL is omitted, $WWW_HOME is used instead.

Bugs

It assumes that the document on URL is HTML.
As it uses makeref to number the anchor, it can't handle any document
makeref can't handle.
9 changes: 9 additions & 0 deletions Bonus/backslash_to_slash.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/perl
# keymap "x \\" GOTO file:/$LIB/backslash_to_slash.cgi

$_ = $ENV{W3M_CURRENT_LINK} || exit;
s@\\@/@g;
print <<EOF;
Location: $_
EOF
Loading

0 comments on commit 72f72d6

Please sign in to comment.