* NEWS: w3m-img merge
* .cvsignore: add w3mimgdisplay, w3mimgsize
* XMakefile: add image.c to SRCS
add image.o to OBJS
add IMGDISPLAY, IMGSIZE
* config.h.dist: USE_IMAGE, IMGSIZE, IMGDISPLAY
* configure: add find_imlib
ask use_image
(config.h) add $imgtarget to EXT_TARGETS
$def_use_image
IMGSIZE, IMGDISPLAY
* fm.h (MAX_IMAGE): added
* fm.h (DEFAULT_PIXEL_PER_CHAR): fix for USE_IMAGE
* fm.h (DEFAULT_PIXEL_PER_LINE): added
* fm.h (B_REDRAW_IMAGE): added
* fm.h (IMG_FLAG_SKIP): added
* fm.h (IMG_FLAG_AUTO): added
* fm.h (IMG_FLAG_START): added
* fm.h (IMG_FLAG_STOP): added
* fm.h (IMG_FLAG_NEXT): added
* fm.h (IMG_FLAG_UNLOADED): added
* fm.h (IMG_FLAG_LOADED): added
* fm.h (IMG_FLAG_ERROR): added
* fm.h (MapArea): added
* fm.h (MapList): s/urls/alts/, add area
* fm.h (ImageCache): added
* fm.h (Image): added
* fm.h (Anchor): add image
* fm.h (Buffer): add imarklist, image_flag, need_reshape
* fm.h (RG_FRAME_SRC): added
* fm.h (ALIGN_MIDDLE): added
* fm.h (ALIGN_TOP): added
* fm.h (ALIGN_BOTTOM): added
* fm.h (QuietMessage): added
* fm.h (Imgdisplay): added
* fm.h (Imgsize): added
* fm.h (activeImage): added
* fm.h (displayImage): added
* fm.h (autoImage): added
* fm.h (useExtImageViewer): added
* fm.h (image_source): added
* fm.h (view_unseenobject): change default if USE_IMAGE
* fm.h (set_pixel_per_char): added
* fm.h (pixel_per_line): added
* fm.h (set_pixel_per_line): added
* fm.h (image_scale): added
* proto.h (dispI): added
* proto.h (stopI): added
* proto.h (deleteImage): added
* proto.h (getAllImage): added
* proto.h (loadImage): added
* proto.h (getImage): added
* proto.h (getImageSize): added
* proto.h (process_img): add width arg
* proto.h (loadImageBuffer): added
* proto.h (follow_map_menu): add a_img arg
* proto.h (getMapXY): added
* proto.h (newMapArea): added
* proto.h (touch_cursor): added
* proto.h (cURLcode): added
* proto.h (initImage): added
* proto.h (termImage): added
* proto.h (addImage): added
* proto.h (drawImage): added
* proto.h (clearImage): added
* anchor.c (addMultirowsImg): added
* buffer.c (discardBuffer): deleteImage if USE_IMAGE
* buffer.c (reshapeBuffer): buf->need_reshape check
* display.c (fmTerm): if activeImage, stop load image
* display.c (fmInit): if displayImage, initImage
* display.c (image_touch): added
* display.c (draw_image_flag): added
* display.c (redrawLineImage): added
* display.c (displayBuffer): buf->need_reshape = TRUE
mode == B_REDRAW_IMAGE
image flag checks
force redraw image in mode == B_REDRAW_IMAGE
displayBuffer if need reshape
drawImage
* display.c (redrawNLine): redrawLineImage
* display.c (redrawLineImage): added
* display.c (disp_message_nsec): return immediately if QuietMessage
* etc.c (reset_signals): ignore SIGUSR1
* file.c (frame_source): added
* file.c (_MoveFile): added
* file.c (cur_baseURL): added
* file.c (cur_document_code): added
* file.c (cur_iseq): added
* file.c (loadGeneralFile): fix fmInitialized and prevtrap checks
save cur_baseURL
image_source load
loadImageBuffer for "image/*"
frame_source flag
fix b->type when proc is loadImageBuffer
* file.c (process_img): add width arg
parse height and width attr, align
fix for inline-image
* file.c (process_input): fix for form <input type="image">
* file.c (HTMLtagproc1): pass h_env->limit to process_img()
fix <img_alt> for inline-image
save cur_baseURL
* file.c (HTMLlineproc2body): fix <img_alt> for inline-image
* file.c (loadHTMLstream): fix for inline-image
fix fmInitialized and prevtrap checks
save cur_document_code
save image_flag
* file.c (loadGopherDir): save cur_document_code
fix fmInitialized and prevtrap checks
* file.c (loadImageBuffer): added for inline-image
* file.c (save2tmp): fix fmInitialized and prevtrap checks
* frame.c (frame_download_source): set RG_FRAME_SRC flag
image check
* funcname.tab (DISPLAY_IMAGE): added
* funcname.tab (STOP_IMAGE): added
* html.c (ALST_IMG): add align, ismap
* html.c (ALST_AREA): add shape, coords
* html.c (ALST_IMG_ALT): add width, height, usemap, ismap, hseq,
xoffset, yoffset, top_margin, bottom_margin
* html.c (AttrMap): add shape, coords, ismap, xoffset, yoffset
* html.h (ATTR_SHAPE): added
* html.h (ATTR_COORDS): added
* html.h (ATTR_ISMAP): added
* html.h (ATTR_XOFFSET): added
* html.h (ATTR_YOFFSET): added
* html.h (ATTR_TOP_MARGIN): added
* html.h (ATTR_BOTTOM_MARGIN): added
* html.h (SHAPE_UNKNOWN): added
* html.h (SHAPE_DEFAULT): added
* html.h (SHAPE_RECT): added
* html.h (SHAPE_CIRCLE): added
* html.h (SHAPE_POLY): added
* image.c: added
* main.c (fversion): add USE_IMAGE
* main.c (fusage): -ppl option
* main.c (MAIN): set_pixel_per_char if ppc specified
-ppl option
loadImage
* main.c (pushBuffer): deleteImage
* main.c (quitfm): termImage
* main.c (selBuf): deleteImage
* main.c (followA): fix for inline-image and map area
* main.c (query_from_followform): getMapXY()
* main.c (setOpt): displayBuffer B_REDRAW_IMAGE
* main.c (follow_map): fix calculate x, y
* main.c (dispI): added
* main.c (stopI): added
* map.c: include <math.h>
* map.c (inMapArea): added
* map.c (follow_map_menu): add a_img arg to handle inline-image
* map.c (follow_map_panel): use MapArea
* map.c (getMapXY): added
* map.c (newMapArea): added
* menu.c (smChBuf): deleteImage
* parsetagx.c (toAlign): align top, bottom, middle
* rc.c (P_SCALE): added
* rc.c (CMT_PIXEL_PER_LINE): added
* rc.c (CMT_DISP_IMAGE): added
* rc.c (CMT_AUTO_IMAGE): added
* rc.c (CMT_EXT_IMAGE_VIEWER): added
* rc.c (CMT_IMAGE_SCALE): added
* rc.c (CMT_IMGDISPLAY): added
* rc.c (CMT_IMGSIZE): added
* rc.c (show_param): P_PIXELS
* rc.c (set_param): P_PIXELS
* rc.c (sync_with_option): initImage
* rc.c (to_str): P_PIXELS
* table.c (feed_table_tag): fix <img> for inline-image
* tagtable.tab (image): added
* terms.c (wgetch): retry read when EINTR or EAGAIN
* terms.c (touch_cursor): added
* w3mimgdisplay.c: added
* w3mimgsize.c: added
* doc/README.func (DISPLAY_IMAGE): added
* doc/README.func (STOP_IMAGE): added
* doc/README.img: added
* doc-jp/README.func (DISPLAY_IMAGE): added
* doc-jp/README.func (STOP_IMAGE): added
* doc-jp/README.img: added
* scripts/w3mhelp.cgi.in: show dispI, stopI
* scripts/multipart/multipart.cgi.in: inline image support
From: Fumitoshi UKAI <ukai@debian.or.jp>
300 lines
5.2 KiB
Plaintext
300 lines
5.2 KiB
Plaintext
#!@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 (defined($ENV{'QUERY_STRING'})) {
|
|
$query = $ENV{'QUERY_STRING'};
|
|
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
|
|
sysread(STDIN, $query, $ENV{'CONTENT_LENGTH'});
|
|
}
|
|
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];
|
|
}
|
|
}
|
|
|
|
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";
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
$qcgi = &html_quote($CGI);
|
|
$qfile = &html_quote($file);
|
|
$qboundary = &html_quote($boundary);
|
|
|
|
if ($mbody =~ /\S/) {
|
|
$_ = $mbody;
|
|
s/\&/\&/g;
|
|
s/\</\</g;
|
|
s/\>/\>/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/\&/\&/g;
|
|
s/\</\</g;
|
|
s/\>/\>/g;
|
|
print "<pre>\n";
|
|
print $_;
|
|
print "\n</pre>\n";
|
|
if ($type =~ /name=\"?([^\"]+)\"?/ ||
|
|
$dispos =~ /filename=\"?([^\"]+)\"?/) {
|
|
$name = $1;
|
|
} else {
|
|
$name = "Content";
|
|
}
|
|
print "<form method=POST 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=\"$CGI?file=$qfile&boundary=$qboundary&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/\&/\&/g;
|
|
s/\</\</g;
|
|
s/\>/\>/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) = (
|
|
'<', '<',
|
|
'>', '>',
|
|
'&', '&',
|
|
'"', '"',
|
|
);
|
|
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+)$/ || 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;
|
|
}
|