[Y2K] inn-2.2.2/samples/innreport.in is old version ??
Fabien Tassin
fta at oleane.net
Tue Jan 4 02:07:00 UTC 2000
According to Fabien Tassin:
>
> -- Binary/unsupported file stripped by Listar --
> -- Type: application/x-perl
Damn Listar :(
Here it is, unattached :
----------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
# - first date of your news.notice
# - last date of your news.notice
# - estimation of the time when innreport has been invoked (localtime format)
# - year expected for the first date
print "1..4\n";
&test("Dec 30 00:02:01", # Dec 30 00:02:01 1999
"Dec 31 00:01:30", # Dec 31 00:01:30 1999
[11, 2, 11, 31, 11, 99], # Dec 31 00:02:11 1999
1999);
&test("Dec 30 00:02:01", # Dec 30 00:02:01 1999
"Dec 31 00:01:30", # Dec 31 00:01:30 1999
[11, 2, 0, 1, 0, 100], # Jan 1 00:02:11 2000
1999);
&test("Dec 31 00:02:01", # Dec 31 00:02:01 1999
"Jan 1 00:01:30", # Jan 1 00:01:30 2000
[11, 2, 0, 1, 0, 100], # Jan 1 00:02:11 2000
1999);
&test("Jan 1 00:02:01", # Jan 1 00:02:01 2000
"Jan 2 00:01:30", # Jan 2 00:01:30 2000
[11, 2, 0, 2, 0, 100], # Jan 2 00:02:11 2000
2000);
my $i = 0;
sub test {
my $first_date = shift;
my $last_date = shift;
my $localtime = shift;
my $good = shift;
my $suffix = "";
my $SEPARATOR = ".";
###########################################################################
# +INNREPORT
# The filename will contain the first date of the log or the current time.
my ($ts, $tm, $th, $dd, $dm, $dy) = @$localtime;
my ($m, $d, $h, $mn, $s) =
$first_date =~ /^(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)$/;
if ($m) {
my $ddm = (index "JanFebMarAprMayJunJulAugSepOctNovDec", $m) / 3;
# Adjust the year because syslog doesn't record it. We assume that
# it's the current year unless the last date is in the future.
my $ld = &ConvDate($last_date);
$dy-- if $ld > $ts + 60 * ($tm + 60 * ($th + 24 * ($dd - 1 +
substr("000031059090120151181212243273304334", $dm * 3, 3)))) ||
$ld < &ConvDate($first_date);
($dm, $dd, $th, $tm, $ts) = ($ddm, $d, $h, $mn, $s);
}
$dm++; # because January = 0 and we prefer 1
$dy += 100 if $dy < 90; # Try to pacify the year 2000 !
$dy += 1900;
$suffix = sprintf ".%02d.%02d.%02d-%02d$SEPARATOR%02d$SEPARATOR%02d",
$dy, $dm, $dd, $th, $tm, $ts;
# -INNREPORT
###########################################################################
print $dy == $good ? "" : "not ", "ok ", ++$i, "\n";
$dy == $good;
}
sub ConvDate {
# usage: $num = &ConvDate ($date);
# date format is Aug 22 01:49:40
my $T = shift;
my ($m, $d, $h, $mn, $s) = $T =~ /^(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)$/;
my $out = $s + 60 * $mn + 3600 * $h + 86400 * ($d - 1);
$m = substr("000031059090120151181212243273304334",
index ("JanFebMarAprMayJunJulAugSepOctNovDec", $m), 3);
$out += $m * 86400;
return $out;
}
----------------------------------------------------------------------------
--
Fabien Tassin -+- fta at oleane.net
More information about the inn-workers
mailing list