| 1 | # | ||||||||||||||||||||||||||||
| 2 | # this is a generic module, used by note database | ||||||||||||||||||||||||||||
| 3 | # backend modules. | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2000-2015 T.v.Dein <tlinden@cpan.org> | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package NOTEDB; | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Exporter (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use vars qw(@ISA @EXPORT $crypt_supported); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | $NOTEDB::VERSION = "1.41"; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | BEGIN { | ||||||||||||||||||||||||||||
| 16 | # make sure, it works, otherwise encryption | ||||||||||||||||||||||||||||
| 17 | # is not supported on this system! | ||||||||||||||||||||||||||||
| 18 | 1 | ▶ | eval { require Crypt::CBC; }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | if($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 1 | $NOTEDB::crypt_supported = 0; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | else { | ||||||||||||||||||||||||||||
| 23 | 0 | $NOTEDB::crypt_supported = 1; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub no_crypt { | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $NOTEDB::crypt_supported = 0; | ||||||||||||||||||||||||||
|
Subroutine
no_crypt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub use_crypt { | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my($this,$key,$method) = @_; | ||||||||||||||||||||||||||
|
Subroutine
use_crypt: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 0 | my($cipher); | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | if($NOTEDB::crypt_supported == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | eval { | |||||||||||||||||||||||||||
| 38 | 0 | $cipher = new Crypt::CBC($key, $method); | |||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | print "warning: Crypt::$method not supported by system!\n"; | |||||||||||||||||||||||||||
| 42 | 0 | $NOTEDB::crypt_supported = 0; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||||
| 45 | 0 | $this->{cipher} = $cipher; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | else{ | ||||||||||||||||||||||||||||
| 49 | 0 | print "warning: Crypt::CBC not supported by system!\n"; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub use_cache { | ||||||||||||||||||||||||||||
| 55 | # | ||||||||||||||||||||||||||||
| 56 | # this sub turns on cache support | ||||||||||||||||||||||||||||
| 57 | # | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
use_cache: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | 0 | $this->{use_cache} = 1; | |||||||||||||||||||||||||||
| 60 | 0 | $this->{changed} = 1; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub cache { | ||||||||||||||||||||||||||||
| 64 | # | ||||||||||||||||||||||||||||
| 65 | # store the whole db as hash | ||||||||||||||||||||||||||||
| 66 | # if use_cache is turned on | ||||||||||||||||||||||||||||
| 67 | # | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
cache: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($this->{use_cache}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | my %res = @_; | |||||||||||||||||||||||||||
| 71 | 0 | %{$this->{cache}} = %res; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub unchanged { | ||||||||||||||||||||||||||||
| 76 | # | ||||||||||||||||||||||||||||
| 77 | # return true if $this->{changed} is true, this will | ||||||||||||||||||||||||||||
| 78 | # be set to true by writing subs using $this->changed(). | ||||||||||||||||||||||||||||
| 79 | # | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
unchanged: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return 0 if(!$this->{use_cache}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($this->{changed}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | $this->{changed} = 0; | |||||||||||||||||||||||||||
| 84 | 0 | return 0; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||
| 87 | 0 | print "%\n"; | |||||||||||||||||||||||||||
| 88 | 0 | return 1; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | sub changed { | ||||||||||||||||||||||||||||
| 93 | # | ||||||||||||||||||||||||||||
| 94 | # turn on $this->{changed} | ||||||||||||||||||||||||||||
| 95 | # this will be used by update or create subs. | ||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
changed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 98 | 0 | $this->{changed} = 1; | |||||||||||||||||||||||||||
| 99 | 0 | return 1; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | sub generate_search { | ||||||||||||||||||||||||||||
| 104 | # | ||||||||||||||||||||||||||||
| 105 | # get user input and create perlcode ready for eval | ||||||||||||||||||||||||||||
| 106 | # sample input: | ||||||||||||||||||||||||||||
| 107 | # "ann.a OR eg???on AND u*do$" | ||||||||||||||||||||||||||||
| 108 | # resulting output: | ||||||||||||||||||||||||||||
| 109 | # "$match = 1 if(/ann\.a/i or /eg...on/i and /u.*do\$/i ); | ||||||||||||||||||||||||||||
| 110 | # | ||||||||||||||||||||||||||||
| 111 | 0 | ▶ | my($this, $string) = @_; | ||||||||||||||||||||||||||
|
Subroutine
generate_search: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | my $case = "i"; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($string =~ /^\/.+?\/$/) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 116 | 0 | return $string; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | elsif (!$string) { | ||||||||||||||||||||||||||||
| 119 | 0 | return "/^/"; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | # we will get a / in front of the first word too! | ||||||||||||||||||||||||||||
| 123 | 0 | $string = " " . $string . " "; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | # check for apostrophs | ||||||||||||||||||||||||||||
| 126 | 0 | $string =~ s/(?<=\s)(\(??)("[^"]+"|\S+)(\)??)(?=\s)/$1 . $this->check_exact($2) . $3/ge; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # remove odd spaces infront of and after »and« and »or« | ||||||||||||||||||||||||||||
| 129 | 0 | $string =~ s/\s\s*(AND|OR)\s\s*/ $1 /g; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | # remove odd spaces infront of »(« and after »)« | ||||||||||||||||||||||||||||
| 132 | 0 | $string =~ s/(\s*\()/\(/g; | |||||||||||||||||||||||||||
| 133 | 0 | $string =~ s/(\)\s*)/\)/g; | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # remove first and last space so it will not masked! | ||||||||||||||||||||||||||||
| 136 | 0 | $string =~ s/^\s//; | |||||||||||||||||||||||||||
| 137 | 0 | $string =~ s/\s$//; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | # mask spaces if not infront of or after »and« and »or« | ||||||||||||||||||||||||||||
| 140 | 0 | $string =~ s/(?<!AND)(?<!OR)(\s+?)(?!AND|OR)/'\s' x length($1)/ge; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | # add first space again | ||||||||||||||||||||||||||||
| 143 | 0 | $string = " " . $string; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | # lowercase AND and OR | ||||||||||||||||||||||||||||
| 146 | 0 | $string =~ s/(\s??OR\s??|\s??AND\s??)/\L$1\E/g; | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | # surround brackets with at least one space | ||||||||||||||||||||||||||||
| 149 | 0 | $string =~ s/(?<!\\)(\)|\()/ $1 /g; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | # surround strings with slashes | ||||||||||||||||||||||||||||
| 152 | 0 | $string =~ s/(?<=\s)(\S+)/ $this->check_or($1, $case) /ge; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | # remove slashes on »and« and »or« | ||||||||||||||||||||||||||||
| 155 | 0 | $string =~ s/\/(and|or)\/$case/$1/g; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | # remove spaces inside /string/ constructs | ||||||||||||||||||||||||||||
| 158 | 0 | $string =~ s/(?<!and)(?<!or)\s*\//\//g; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | $string =~ s/\/\s*(?!and|or)/\//g; | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | #my $res = qq(\$match = 1 if($string);); | ||||||||||||||||||||||||||||
| 163 | 0 | return qq(\$match = 1 if($string);); | |||||||||||||||||||||||||||
| 164 | #print $res . "\n"; | ||||||||||||||||||||||||||||
| 165 | #return $res; | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | sub check_or { | ||||||||||||||||||||||||||||
| 169 | # | ||||||||||||||||||||||||||||
| 170 | # surrounds string with slashes if it is not | ||||||||||||||||||||||||||||
| 171 | # »and« or »or« | ||||||||||||||||||||||||||||
| 172 | # | ||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my($this, $str, $case) = @_; | ||||||||||||||||||||||||||
|
Subroutine
check_or: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($str =~ /^\s*(or|and)\s*$/) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 175 | 0 | return " $str "; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | elsif ($str =~ /(?<!\\)[)(]/) { | ||||||||||||||||||||||||||||
| 178 | 0 | return $str; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||
| 181 | 0 | return " \/$str\/$case "; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | sub check_exact { | ||||||||||||||||||||||||||||
| 187 | # | ||||||||||||||||||||||||||||
| 188 | # helper for generate_search() | ||||||||||||||||||||||||||||
| 189 | # masks special chars if string | ||||||||||||||||||||||||||||
| 190 | # not inside "" | ||||||||||||||||||||||||||||
| 191 | # | ||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my($this, $str) = @_; | ||||||||||||||||||||||||||
|
Subroutine
check_exact: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | my %wildcards = ( | |||||||||||||||||||||||||||
| 195 | '*' => '.*', | ||||||||||||||||||||||||||||
| 196 | '?' => '.', | ||||||||||||||||||||||||||||
| 197 | '[' => '[', | ||||||||||||||||||||||||||||
| 198 | ']' => ']', | ||||||||||||||||||||||||||||
| 199 | '+' => '\+', | ||||||||||||||||||||||||||||
| 200 | '.' => '\.', | ||||||||||||||||||||||||||||
| 201 | '$' => '\$', | ||||||||||||||||||||||||||||
| 202 | '@' => '\@', | ||||||||||||||||||||||||||||
| 203 | '/' => '\/', | ||||||||||||||||||||||||||||
| 204 | '|' => '\|', | ||||||||||||||||||||||||||||
| 205 | '}' => '\}', | ||||||||||||||||||||||||||||
| 206 | '{' => '\{', | ||||||||||||||||||||||||||||
| 207 | ); | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 0 | my %escapes = ( | |||||||||||||||||||||||||||
| 210 | '*' => '\*', | ||||||||||||||||||||||||||||
| 211 | '?' => '\?', | ||||||||||||||||||||||||||||
| 212 | '[' => '[', | ||||||||||||||||||||||||||||
| 213 | ']' => ']', | ||||||||||||||||||||||||||||
| 214 | '+' => '\+', | ||||||||||||||||||||||||||||
| 215 | '.' => '\.', | ||||||||||||||||||||||||||||
| 216 | '$' => '\$', | ||||||||||||||||||||||||||||
| 217 | '@' => '\@', | ||||||||||||||||||||||||||||
| 218 | '(' => '\(', | ||||||||||||||||||||||||||||
| 219 | ')' => '\)', | ||||||||||||||||||||||||||||
| 220 | '/' => '\/', | ||||||||||||||||||||||||||||
| 221 | '|' => '\|', | ||||||||||||||||||||||||||||
| 222 | '}' => '\}', | ||||||||||||||||||||||||||||
| 223 | '{' => '\{', | ||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | # mask backslash | ||||||||||||||||||||||||||||
| 227 | 0 | $str =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if ($str =~ /^"/ && $str =~ /"$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$str =~ /^"/ and $str =~ /"$/
MC/DC0%0/2
$str =~ /^"/ and $str =~ /"$/
$str =~ /^"/
$str =~ /"$/
Truth table0%0/3
A and B
A= $str =~ /^"/B= $str =~ /"$/
| |||||||||||||||||||||||||||||
| 231 | # mask bracket-constructs | ||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $str =~ s/(.)/$escapes{$1} || "$1"/ge; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | else { | ||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $str =~ s/(.)/$wildcards{$1} || "$1"/ge; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | $str =~ s/^"//; | |||||||||||||||||||||||||||
| 239 | 0 | $str =~ s/"$//; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | # mask spaces | ||||||||||||||||||||||||||||
| 242 | 0 | $str =~ s/\s/\\s/g; | |||||||||||||||||||||||||||
| 243 | 0 | return $str; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | sub lock { | ||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my ($this) = @_; | ||||||||||||||||||||||||||
|
Subroutine
lock: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (-e $this->{LOCKFILE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | ▶ | open LOCK, "<$this->{LOCKFILE}" or die "could not open $this->{LOCKFILE}: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | my $data = <LOCK>; | |||||||||||||||||||||||||||
| 255 | 0 | close LOCK; | |||||||||||||||||||||||||||
| 256 | 0 | chomp $data; | |||||||||||||||||||||||||||
| 257 | 0 | print "-- waiting for lock by $data --\n"; | |||||||||||||||||||||||||||
| 258 | 0 | print "-- remove the lockfile if you are sure: \"$this->{LOCKFILE}\" --\n"; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | my $timeout = 60; | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | eval { | |||||||||||||||||||||||||||
| 264 | 0 | ▶ | local $SIG{ALRM} = sub { die "timeout" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 265 | 0 | ▶ | local $SIG{INT} = sub { die "interrupted" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 266 | 0 | alarm $timeout - 2; | |||||||||||||||||||||||||||
| 267 | 0 | while (1) { | |||||||||||||||||||||||||||
| 268 | 0 | ▶ | if (! -e $this->{LOCKFILE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 0 | umask 022; | |||||||||||||||||||||||||||
| 270 | 0 | ▶ | open LOCK, ">$this->{LOCKFILE}" or die "could not open $this->{LOCKFILE}: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 0 | flock LOCK, LOCK_EX; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | my $now = scalar localtime(); | |||||||||||||||||||||||||||
| 274 | 0 | print LOCK "$ENV{USER} since $now (PID: $$)\n"; | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | flock LOCK, LOCK_UN; | |||||||||||||||||||||||||||
| 277 | 0 | close LOCK; | |||||||||||||||||||||||||||
| 278 | 0 | alarm 0; | |||||||||||||||||||||||||||
| 279 | 0 | return 0; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | 0 | printf " %0d\r", $timeout; | |||||||||||||||||||||||||||
| 282 | 0 | $timeout--; | |||||||||||||||||||||||||||
| 283 | 0 | sleep 1; | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | }; | ||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ($@ =~ /^inter/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 0 | print " interrupted\n"; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | else { | ||||||||||||||||||||||||||||
| 291 | 0 | print $@; | |||||||||||||||||||||||||||
| 292 | 0 | print " timeout\n"; | |||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | 0 | return 1; | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | 0 | return 0; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | sub unlock { | ||||||||||||||||||||||||||||
| 300 | 0 | ▶ | my ($this) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unlock: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 301 | 0 | unlink $this->{LOCKFILE}; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 1 | 1; | |||||||||||||||||||||||||||