X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=onis;h=5c2bb2ef93d2b30cebe8bdbbe8fc122df99d9872;hb=e2c8b3376315af1f2daf02dee9db21190fe6b391;hp=7d794b0fcc181f0e1009cc2862a14e0074d072e0;hpb=2488a56f03344d1b55822ce026719f165c5023bf;p=onis.git diff --git a/onis b/onis index 7d794b0..5c2bb2e 100755 --- a/onis +++ b/onis @@ -1,12 +1,12 @@ #!/usr/bin/perl ########################################################################## -# onis 0.7.2 2005-01-21 # +# onis 0.8.0 2005-04-17 # #---=============--------------------------------------------------------# # Language: Perl # # Purpose: Generating statistics # # Input: IRC-Logfiles # # Output: One HTML file # -# Version: 0.7.2 (unstable) # +# Version: 0.8.0 (unstable) # # License: GPL # # Homepage: http://verplant.org/onis/ # # Authors: Florian octo Forster # @@ -48,13 +48,13 @@ if (!$VERSION) $VERSION =~ s/^\D*(\d+).*/r$1/; } -our $FILEINFO; -our $PURGE_LOGS = 0; +our $FileInfo; +our $PurgeLogs = 0; print STDERR $/, __FILE__, ': $Id$' if ($::DEBUG); parse_argv (@ARGV); -read_config (get_config ('config') ? get_config ('config') : 'config'); +read_config (get_config ('config') ? get_config ('config') : 'onis.conf'); read_config (scalar get_config ('theme')) if (get_config ('theme')); my $output = get_config ('output'); @@ -71,6 +71,7 @@ foreach ('Core', get_config ('plugin')) if (!get_config ('input')) { + # TODO: Make a complete (!) lsit.. print STDERR < [logfile logfile ..] @@ -126,23 +127,23 @@ if (get_config ('logtype')) require "Onis/Parser/$logtype.pm"; require Onis::Parser::Persistent; require Onis::Data::Persistent; -import Onis::Parser qw/parse last_date/; -import Onis::Parser::Persistent qw#newfile#; -import Onis::Data::Persistent qw#init#; +import Onis::Parser (qw(parse last_date)); +import Onis::Parser::Persistent (qw(newfile)); +import Onis::Data::Persistent (); -$FILEINFO = init ('$FILEINFO', 'hash'); +$FileInfo = Onis::Data::Persistent->new ('FileInfo', 'inode', qw(mtime)); if (get_config ('purge_logs')) { my $temp = lc (get_config ('purge_logs')); if (($temp eq 'truncate') or ($temp eq 'shorten')) { - $PURGE_LOGS = 1; + $PurgeLogs = 1; } elsif (($temp eq 'delete') or ($temp eq 'remove') or ($temp eq 'del')) { - $PURGE_LOGS = 2; + $PurgeLogs = 2; } } @@ -167,15 +168,18 @@ for (get_config ('input')) } else { + my ($old_mtime) = $FileInfo->get ($inode); + print STDERR $/, __FILE__, ": ``$file'': " if ($::DEBUG & 0x200); - if (defined ($FILEINFO->{$inode}{'mtime'})) + + if (defined ($old_mtime)) { - if ($FILEINFO->{$inode}{'mtime'} == $mtime) + if ($old_mtime == $mtime) { print STDERR "File did not change. Skipping." if ($::DEBUG & 0x200); next; } - elsif ($FILEINFO->{$inode}{'mtime'} < $mtime) + elsif ($old_mtime < $mtime) { print STDERR "File changed. Reading it again." if ($::DEBUG & 0x200); } @@ -188,11 +192,11 @@ for (get_config ('input')) { print STDERR "File appears to be new. Reading it." if ($::DEBUG & 0x200); } - $FILEINFO->{$inode}{'mtime'} = $mtime; + $FileInfo->put ($inode, $mtime); } # truncate - if ($PURGE_LOGS == 1) + if ($PurgeLogs == 1) { unless (open ($logfile, '+< ' . $file)) { @@ -209,7 +213,7 @@ for (get_config ('input')) } } - if ($PURGE_LOGS) + if ($PurgeLogs) { unless (flock ($logfile, LOCK_EX)) { @@ -228,7 +232,7 @@ for (get_config ('input')) } } - newfile ($FILEINFO->{$inode}); + newfile ($FileInfo->{$inode}); while (<$logfile>) { s/\n|\r//g; @@ -261,11 +265,11 @@ for (get_config ('input')) } } - if ($PURGE_LOGS and (($status == 1) + if ($PurgeLogs and (($status == 1) or ($status == 2) or ($status == 3))) { - if (($PURGE_LOGS > 1) + if (($PurgeLogs > 1) #and (($position + 1) >= $size) ) { @@ -279,7 +283,7 @@ for (get_config ('input')) { print STDERR $/, __FILE__, ": Unable to delete empty file ``$file'': $!"; } - delete ($FILEINFO->{$inode}); + delete ($FileInfo->{$inode}); } else {