Revision 2361679c
Added by Hamish Coleman over 17 years ago
- ID 2361679c7d7bb7c962df81cf1a2d93b0829d5da8
mrtg.cgi | ||
---|---|---|
my $warnings;
|
||
|
||
sub init_tests() {
|
||
my $xsize_default = 400;
|
||
my $xsize_default = 500;
|
||
my $testmax=0;
|
||
my @list;
|
||
my %tests;
|
||
... | ... | |
}
|
||
|
||
while(<In>){
|
||
my $testnr;
|
||
my $testname;
|
||
my $var;
|
||
my $val;
|
||
|
||
#TODO - parse WorkDir: directives
|
||
#TODO - instantiate new tests from "_"
|
||
#TODO - instantiate new tests from the "_" defaults
|
||
|
||
if ( $_ =~ /^([^#[][^[]+)\[(.*)\]:\s*(.+)$/ ) {
|
||
$var=$1;
|
||
$val=$3;
|
||
$testname=lc $2;
|
||
my $testnr;
|
||
my $var=lc $1;
|
||
my $testname=lc $2;
|
||
my $val=$3;
|
||
|
||
my $this_ysize;
|
||
my $this_xsize;
|
||
my $this_title;
|
||
|
||
if ( $var eq 'ysize' ) {
|
||
$this_ysize = $val +35;
|
||
} elsif ( $var eq 'xsize' ) {
|
||
$this_xsize = $val +100;
|
||
# FIXME - quick-hack
|
||
if ( $testname eq '_' ) {
|
||
$xsize_default = $this_xsize;
|
||
}
|
||
} elsif ( $var eq 'title' ) {
|
||
$this_title = $val;
|
||
}
|
||
|
||
# Skip any default initializers
|
||
if ($testname eq '_') {
|
||
next;
|
||
}
|
||
if ($testname eq '^') {
|
||
next;
|
||
}
|
||
|
||
if (! exists $tests{$testname}) {
|
||
$tests{$testname}=$testmax;
|
||
$list[$testmax]->{name} = $testname;
|
||
$list[$testmax]->{xsize} = $xsize_default +100;
|
||
$list[$testmax]->{xsize} = $xsize_default;
|
||
$testnr = $testmax;
|
||
# TODO - replace testmax with (scalar @list)
|
||
$testmax++;
|
||
} else {
|
||
$testnr=$tests{$testname};
|
||
}
|
||
|
||
if ( $var eq 'YSize' ) {
|
||
$list[$testnr]->{ysize} = $val +35;
|
||
} elsif ( $var =~ /xsize/i ) {
|
||
$list[$testnr]->{xsize} = $val +100;
|
||
# FIXME - quick-hack
|
||
if ( $testname eq '_' ) {
|
||
$xsize_default = $val;
|
||
}
|
||
} elsif ( $var eq 'Title' ) {
|
||
$list[$testnr]->{title} = $val;
|
||
}
|
||
$list[$testnr]->{ysize} = $this_ysize;
|
||
$list[$testnr]->{xsize} = $this_xsize;
|
||
$list[$testnr]->{title} = $this_title;
|
||
}
|
||
}
|
||
close In;
|
||
}
|
||
|
||
# check and update details for all known tests;
|
||
for my $i (@list) {
|
||
my $testname = $i->{name};
|
||
if (!exists($i->{title})) {
|
||
... | ... | |
$i->{imagetype} = "png";
|
||
}
|
||
|
||
# TODO - change the filename based on the displayed period
|
||
my $filename = $testname . "-day." . $i->{imagetype};
|
||
|
||
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
|
||
$atime,$mtime,$ctime,$blksize,$blocks)
|
||
= stat($filename);
|
||
if (!defined $mtime) {
|
||
# if we cannot stat the file, skip it
|
||
next;
|
||
}
|
||
|
||
... | ... | |
for my $i (0..$#tests) {
|
||
my $testname = $tests[$i]->{name};
|
||
|
||
# Skip the defaults initializers
|
||
if ($testname eq '_') {
|
||
next;
|
||
}
|
||
if ($testname eq '^') {
|
||
next;
|
||
}
|
||
|
||
# Skip things with no separator in them
|
||
if ($testname =~ /,/) {
|
||
1;
|
Also available in: Unified diff
revamp list creation.