line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# HTML::EP - A Perl based HTML extension. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright (C) 1998 Jochen Wiedmann |
7
|
|
|
|
|
|
|
# Am Eisteich 9 |
8
|
|
|
|
|
|
|
# 72555 Metzingen |
9
|
|
|
|
|
|
|
# Germany |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Phone: +49 7123 14887 |
12
|
|
|
|
|
|
|
# Email: joe@ispsoft.de |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# All rights reserved. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# You may distribute this module under the terms of either |
17
|
|
|
|
|
|
|
# the GNU General Public License or the Artistic License, as |
18
|
|
|
|
|
|
|
# specified in the Perl README file. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require 5.004; |
23
|
1
|
|
|
1
|
|
1263
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
24
|
1
|
|
|
1
|
|
21235
|
use Data::Dumper (); |
|
1
|
|
|
|
|
12818
|
|
|
1
|
|
|
|
|
32
|
|
25
|
1
|
|
|
1
|
|
1074
|
use Safe (); |
|
1
|
|
|
|
|
46773
|
|
|
1
|
|
|
|
|
70
|
|
26
|
1
|
|
|
1
|
|
12
|
use Fcntl (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
27
|
1
|
|
|
1
|
|
5
|
use Symbol (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
597
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package HTML::EP::Session::Dumper; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
0
|
|
|
0
|
0
|
|
my($proto, $ep, $id, $attr) = @_; |
34
|
0
|
|
|
|
|
|
my $session = { '_ep_data' => { 'fh' => $attr->{'fh'} } }; |
35
|
0
|
|
0
|
|
|
|
bless($session, (ref($proto) || $proto)); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub Open { |
39
|
0
|
|
|
0
|
0
|
|
my($proto, $ep, $id, $attr) = @_; |
40
|
0
|
|
|
|
|
|
my $fh = Symbol::gensym(); |
41
|
0
|
0
|
|
|
|
|
sysopen($fh, $id, Fcntl::O_RDWR()|Fcntl::O_CREAT()) |
42
|
|
|
|
|
|
|
or die "Failed to open $id for writing: $!"; |
43
|
0
|
0
|
|
|
|
|
flock($fh, Fcntl::LOCK_EX()) or die "Failed to lock $id: $!"; |
44
|
0
|
0
|
|
|
|
|
return $proto->new($ep, $id, {'fh' => $fh}) if eof($fh); |
45
|
0
|
|
|
|
|
|
local $/ = undef; |
46
|
0
|
|
|
|
|
|
my $contents = <$fh>; |
47
|
0
|
0
|
|
|
|
|
die "Failed to read $id: $!" unless defined $contents; |
48
|
0
|
|
|
|
|
|
my $self = Safe->new()->reval($contents); |
49
|
0
|
0
|
|
|
|
|
die "Failed to eval $id: $@" if $@; |
50
|
0
|
0
|
|
|
|
|
die "Empty or trashed $id: Returned a false value" unless $self; |
51
|
0
|
|
|
|
|
|
$self->{'_ep_data'} = { 'fh' => $fh }; |
52
|
0
|
|
0
|
|
|
|
bless($self, (ref($proto) || $proto)); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub Store { |
56
|
0
|
|
|
0
|
0
|
|
my($self, $ep, $id, $locked) = @_; |
57
|
0
|
|
|
|
|
|
my $data = delete $self->{'_ep_data'}; |
58
|
0
|
|
|
|
|
|
my $fh = $data->{'fh'}; |
59
|
0
|
0
|
0
|
|
|
|
(seek($fh, 0, 0) and |
|
|
|
0
|
|
|
|
|
60
|
|
|
|
|
|
|
(print $fh (Data::Dumper->new([$self])->Indent(1)->Terse(1)->Dump())) and |
61
|
|
|
|
|
|
|
truncate($fh, 0)) |
62
|
|
|
|
|
|
|
or die "Failed to update $id: $!"; |
63
|
0
|
0
|
|
|
|
|
if ($locked) { |
64
|
0
|
|
|
|
|
|
$self->{'_ep_data'} = $data; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub Delete { |
70
|
0
|
|
|
0
|
0
|
|
my($self, $ep, $id) = @_; |
71
|
0
|
0
|
|
|
|
|
if (-f $id) { |
72
|
0
|
0
|
|
|
|
|
unlink $id or die "Failed to delete $id: $!"; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|