wok-next view magicpoint/stuff/patches/01_mgpnet_in.diff @ rev 19903
lynx: update bdeps
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Oct 12 18:00:53 2017 +0200 (2017-10-12) |
parents | |
children |
line source
1 Index: magicpoint-1.13a/contrib/mgpnet.in
2 ===================================================================
3 --- magicpoint-1.13a.orig/contrib/mgpnet.in 2008-12-24 10:52:03.000000000 -0500
4 +++ magicpoint-1.13a/contrib/mgpnet.in 2008-12-24 11:00:47.000000000 -0500
5 @@ -32,7 +32,7 @@
7 # configurations
8 $tmpdir = '/tmp';
9 -$httpdatestr = "date '+\%a, \%d \%b \%Y \%H:\%M:\%S \%Z'";
10 +$httpdatestr = "env LC_ALL=C date '+\%a, \%d \%b \%Y \%H:\%M:\%S \%Z'";
11 $seltimeout = 1;
12 $refreshtimeout = 10;
13 $debug = 0;
14 @@ -53,6 +53,7 @@
15 } while ($hostname =~ /^127\./);
16 close(IN);
17 };
18 + $hostname =~ s/^addr://; # for GNU/Linux, by ukai
19 print "http://$hostname:$port/\n";
20 exit 0;
21 }
22 @@ -214,7 +215,7 @@
23 $imgtmp = &tmpname;
24 $errout = ($debug ? '' : '2>&-');
25 system "xwintoppm -silent -name MagicPoint | ".
26 - "ppmquant 256 $errout | ppmtogif $errout > $imgtmp";
27 + "ppmquant 256 $errout | ppmtopng $errout > $imgtmp";
28 if (-z $imgtmp) {
29 unlink $imgtmp;
30 $checkcontent = '';
31 @@ -245,10 +246,10 @@
32 local($httpreq, $httpmethod, $httppath, $httpver, $httphost);
33 local($httpagent);
34 local($imgplace, $imgwidth, $imgheight, $buf, $imglen);
35 - local($cthtml, $ctgif);
36 + local($cthtml, $ctpng);
38 $cthtml = ($usecharset ? 'text/html; charset=us-ascii' : 'text/html');
39 - $ctgif = 'image/gif';
40 + $ctgif = 'image/png';
42 $httpreq = <NS>;
43 print STDERR 'HTTP in> ' . $httpreq if ($debug);
44 @@ -256,7 +257,7 @@
45 $httpmethod = $httppath = $httpver = '';
46 ($httpmethod, $httppath, $httpver) = split(/\s+/, $httpreq);
47 $httppath =~ s/http:\/\/[^:\/]+(:\d+)\//\//;
48 - if ($httpver eq '' || $httpver eq 'HTTP/1.0') {
49 + if ($httpver eq '' || $httpver =~ m'HTTP/1.0') {
50 ; # ok
51 } else {
52 &httpheader(501, $cthtml) if ($httpver);
53 @@ -318,7 +319,7 @@
54 print <<EOF;
55 <HEAD><TITLE>MagicPoint Netserver</TITLE></HEAD>
56 <BODY>
57 -<IMG SRC=\"/presentation.gif\" ALT=\"presentation image\"
58 +<IMG SRC=\"/presentation.png\" ALT=\"presentation image\"
59 $imgplace ALIGN=left><BR>
60 <TABLE border=0>
61 <TR><TD NOWRAP><A HREF=/index.html>normal</A>
62 @@ -340,7 +341,7 @@
63 </TABLE>
64 </BODY></HTML>
65 EOF
66 - } elsif ($httppath eq '/presentation.gif') {
67 + } elsif ($httppath eq '/presentation.png') {
68 open(IMG, "< $imagefile") || do {
69 $checkcontent = ''; # invalidate
70 &httpheader(404, $cthtml) if ($httpver);
71 @@ -350,13 +351,13 @@
72 <HEAD><TITLE>File Not found</TITLE></HEAD>
73 <BODY><H1>File Not found</H1>
74 The requested URL $httppath was not found on this server.<P>
75 -Looks like a mitake in configuration.
76 +Looks like a mistake in configuration.
77 Contact the administrator.<P>
78 </BODY>
79 EOF
80 return;
81 };
82 - &httpheader(200, $ctgif) if ($httpver);
83 + &httpheader(200, $ctpng) if ($httpver);
84 return if ($httpmethod ne 'GET');
86 while (0 < ($imglen = sysread(IMG, $buf, 4096))) {
87 @@ -415,7 +416,7 @@
88 'XXX4', 'SO_REUSEPORT', 'XXX5', 'SOCK_STREAM', 'XXX6', 'WNOHANG',
89 );
90 $tmpnam = &tmpname;
91 - open(CPP, "| @CPP@ >$tmpnam") || return;
92 + open(CPP, "| @CPP@ - >$tmpnam") || return;
93 print CPP "#include <sys/socket.h>\n";
94 print CPP "#include <sys/wait.h>\n";
95 foreach $tmp (keys %varnames) {
96 @@ -439,12 +440,19 @@
97 $havesinlen = 0; $sockaddr = 'S n a4 x8';
98 }
100 + use Socket;
101 foreach $i (keys %varnames) {
102 if (@tmp2 = grep($_ =~ /^$i/, @tmp1)) {
103 $tmp = (split(/\s+/, @tmp2[0]))[1];
104 $tmp = oct($tmp) if ($tmp =~ /^0/);
105 - next if ($tmp !~ /^[0-9]+$/);
106 - eval "\$$varnames{$i} = \$tmp;";
107 + if ($tmp =~ /^[0-9]+$/) {
108 + eval "\$$varnames{$i} = \$tmp;";
109 + } else {
110 + # some constant defined by enum, so we can not
111 + # always use cpp as above. I believe use Socket
112 + # is more reliable in these days.
113 + eval "\$$varnames{$i} = &$varnames{$i};";
114 + }
115 }
116 }
117 }