line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TipJar::MTA::queue; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5829
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
9
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use vars qw/$VERSION $basedir $tally/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
612
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.02'; |
11
|
|
|
|
|
|
|
$tally = 'a'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# use TipJar::fields qw/RA targetlist body/; |
14
|
|
|
|
|
|
|
sub RA(){0}; |
15
|
|
|
|
|
|
|
sub targetlist(){1}; |
16
|
|
|
|
|
|
|
sub body(){2}; |
17
|
|
|
|
|
|
|
# humbug |
18
|
|
|
|
|
|
|
# use Fcntl ':flock'; |
19
|
|
|
|
|
|
|
sub FLOCK_EX(){2}; |
20
|
|
|
|
|
|
|
sub FLOCK_UN(){8}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new{ |
23
|
0
|
|
|
0
|
1
|
0
|
bless [undef,[],'']; |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub import{ |
27
|
1
|
|
|
1
|
|
7
|
shift; |
28
|
1
|
|
|
|
|
1
|
$basedir = shift; |
29
|
1
|
50
|
|
|
|
1372
|
-d $basedir or croak "[$basedir] is no directory"; |
30
|
0
|
0
|
|
|
|
|
-w $basedir or croak "[$basedir] is not writable"; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub return_address{ |
34
|
|
|
|
|
|
|
# set the RA field |
35
|
0
|
|
|
0
|
1
|
|
$_[0][RA] = $_[1]; |
36
|
0
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub recipient{ |
40
|
|
|
|
|
|
|
# add to the targetlist array |
41
|
0
|
|
|
0
|
1
|
|
my $obj=shift; |
42
|
0
|
|
|
|
|
|
push @{$obj->[targetlist]},@_; |
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub data{ |
47
|
0
|
|
|
0
|
1
|
|
my $obj = shift; |
48
|
0
|
|
|
|
|
|
$obj->[body] = join '',$obj->[body],@_; |
49
|
0
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub printlist($); |
54
|
|
|
|
|
|
|
sub printlist($){ |
55
|
|
|
|
|
|
|
# print STDERR "Debug: printlist called with $_[0]\n"; |
56
|
0
|
|
|
0
|
0
|
|
my $x = shift; |
57
|
0
|
0
|
|
|
|
|
if (ref($x)){ |
58
|
0
|
|
|
|
|
|
my $y; |
59
|
0
|
|
|
|
|
|
for $y (@{$x}){ |
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
printlist $y; |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
}else{ |
63
|
0
|
|
|
|
|
|
print MESSAGE "$x\n"; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub enqueue{ |
68
|
0
|
|
|
0
|
1
|
|
my $obj = shift; |
69
|
0
|
|
|
|
|
|
my $name = join '.',time,$$,$tally++,rand(36294626999); |
70
|
0
|
0
|
|
|
|
|
open MESSAGE, ">$basedir/$name" |
71
|
|
|
|
|
|
|
or croak "could not open [$basedir/$name]: $!"; |
72
|
0
|
|
|
|
|
|
flock MESSAGE, FLOCK_EX; |
73
|
0
|
|
|
|
|
|
print MESSAGE $obj->[RA],"\n"; |
74
|
0
|
|
|
|
|
|
printlist $obj->[targetlist]; |
75
|
0
|
|
|
|
|
|
print MESSAGE "\n",$obj->[body],"\n"; |
76
|
0
|
|
|
|
|
|
flock MESSAGE, FLOCK_UN; |
77
|
0
|
|
|
|
|
|
close MESSAGE; |
78
|
0
|
|
|
|
|
|
@{$obj} = (undef,[],''); |
|
0
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
__END__ |