| 1 | # ABSTRACT: a fast and reliable mailq-like utility for postfix | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Postfix::Mailq; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | sub DEFAULT_SPOOL_DIR () { '/var/spool/postfix' } | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | sub get_fast_count { | ||||||||||||||||||||||||||
|
Subroutine
get_fast_count: called CC=11 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||
| 12 | 2 | my ($opt) = @_; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | $opt ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opt ||= {}
MC/DC0%0/1
$opt ||= {}
$opt
Truth table50%1/2
A
A= $opt
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | my $get_hold = $opt->{get_hold} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | my $spool_dir = defined $opt->{spool_dir} && $opt->{spool_dir} ne '' | ||||||||||||||||||||||||||||
| 18 | ? $opt->{spool_dir} | ||||||||||||||||||||||||||||
| 19 | 2 | ▶ | : DEFAULT_SPOOL_DIR; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $opt->{"spool_dir"} and $opt->{"spool_dir"} ne ""
MC/DC0%0/2
defined $opt->{"spool_dir"} and $opt->{"spool_dir"} ne ""
defined $opt->{"spool_dir"}
$opt->{"spool_dir"} ne ""
Truth table33%1/3
A and B
A= defined $opt->{"spool_dir"}B= $opt->{"spool_dir"} ne ""
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | my %count = ( | |||||||||||||||||||||||||||
| 22 | total => 0, | ||||||||||||||||||||||||||||
| 23 | active => 0, | ||||||||||||||||||||||||||||
| 24 | incoming => 0, | ||||||||||||||||||||||||||||
| 25 | deferred => 0, | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | my @dirs = ('active', 'incoming', map { "deferred/$_" } 0..9, 'A'..'F'); | |||||||||||||||||||||||||||
| 29 | 2 | ▶ | push @dirs, 'hold' if $get_hold; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | for my $dir (@dirs) { | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 37 | ▶ | opendir(my $dh, "$spool_dir/$dir") || next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 5 | my $n = 0; | |||||||||||||||||||||||||||
| 36 | 5 | ▶ | while (my $item = readdir($dh)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 21 | ▶ | ++$n unless $item =~ m{^\.}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 5 | $count{total} += $n; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 5 | ▶ | if ($dir =~ m{^deferred}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | $count{deferred} += $n; | |||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||
| 45 | 5 | $count{$dir} += $n; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 2 | return \%count; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 2 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||