aboutsummaryrefslogtreecommitdiffstats
path: root/nph-png
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-04-27 19:24:15 +0200
committerReinhard Tartler <siretart@tauware.de>2011-04-27 19:24:15 +0200
commit181cec4348da40331b3e8ab365732c025ec149b2 (patch)
treee2e749be67c8253a8096aaf92aab9c51f1a17f7f /nph-png
downloadlcd4linux-181cec4348da40331b3e8ab365732c025ec149b2.tar.gz
Import upstream version 0.11.0~svn1143
Diffstat (limited to '')
-rwxr-xr-xnph-png41
1 files changed, 41 insertions, 0 deletions
diff --git a/nph-png b/nph-png
new file mode 100755
index 0000000..0240b64
--- /dev/null
+++ b/nph-png
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+use strict;
+use vars qw ($file $DELAY);
+########## CONFIG
+ $file = "lcd4linux"; # .png is appended
+ $DELAY = 0; # delay in seconds
+ # if delay is zero, file is sent when modified.
+#################
+
+use CGI qw/:push -nph/;
+$| = 1;
+my ($mtime, $nmtime, $size, $nsize);
+(undef, undef, undef, undef, undef, undef, undef, $size, undef,
+ $mtime) = stat "$file.png";
+print multipart_init(-boundary=>'----------------here we go!');
+while (1) {
+ print multipart_start(-type=>'image/png');
+ undef $/;
+ open(IN, "$file.png") or die("Can't read '$file.png'");
+ $_ = <IN>;
+ print $_;
+ close(IN);
+ print multipart_end;
+ if ($DELAY) {
+ sleep $DELAY;
+ }
+ else {
+ W: while (1) {
+ # sleep(1);
+ (undef, undef, undef, undef, undef, undef, undef, $nsize, undef,
+ $nmtime) = stat "$file.png";
+ if($mtime != $nmtime || $size != $nsize) {
+ $mtime = $nmtime;
+ $size = $nsize;
+ last W;
+ }
+ }
+ }
+}
+