| 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 | 1 | require 5.004; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Data::Dumper (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Safe (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Fcntl (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Symbol (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | package HTML::EP::Session::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my($proto, $ep, $id, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $session = { '_ep_data' => { 'fh' => $attr->{'fh'} } }; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | bless($session, (ref($proto) || $proto)); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub Open { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Open: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my($proto, $ep, $id, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sysopen($fh, $id, Fcntl::O_RDWR()|Fcntl::O_CREAT()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | or die "Failed to open $id for writing: $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | flock($fh, Fcntl::LOCK_EX()) or die "Failed to lock $id: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return $proto->new($ep, $id, {'fh' => $fh}) if eof($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $contents = <$fh>; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | die "Failed to read $id: $!" unless defined $contents; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $self = Safe->new()->reval($contents); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | die "Failed to eval $id: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | die "Empty or trashed $id: Returned a false value" unless $self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->{'_ep_data'} = { 'fh' => $fh }; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | bless($self, (ref($proto) || $proto)); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub Store { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Store: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my($self, $ep, $id, $locked) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $data = delete $self->{'_ep_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $fh = $data->{'fh'}; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | (seek($fh, 0, 0) and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
seek $fh, 0, 0 and print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump and truncate $fh, 0
seek $fh, 0, 0 and print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump
MC/DC0%0/3
seek $fh, 0, 0 and print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump and truncate $fh, 0
seek $fh, 0, 0
print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump
truncate $fh, 0
Truth table0%0/4
A and B and C
A= seek $fh, 0, 0B= print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->DumpC= truncate $fh, 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 | ▶ | if ($locked) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->{'_ep_data'} = $data; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub Delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Delete: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my($self, $ep, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if (-f $id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | unlink $id or die "Failed to delete $id: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||