line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::Voodoo::Validate::signed_int; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = "3.0200"; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4654
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
115
|
|
6
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
100
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use base("Apache::Voodoo::Validate::Plugin"); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1135
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub config { |
11
|
0
|
|
|
0
|
0
|
|
my ($self,$c) = @_; |
12
|
0
|
|
|
|
|
|
my @e; |
13
|
0
|
0
|
0
|
|
|
|
if (defined($c->{bytes})) { |
|
|
0
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
if ($c->{bytes} =~ /^\d+$/) { |
15
|
0
|
|
|
|
|
|
$self->{'max'} = ( 2 ** ($c->{bytes} * 8))/2; |
16
|
0
|
|
|
|
|
|
$self->{'min'} = (0 - (2 ** ($c->{bytes} * 8))/2 - 1); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else { |
19
|
0
|
|
|
|
|
|
push(@e,"'bytes' must be a positive integer"); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif (defined($c->{max}) && defined($c->{min})) { |
23
|
0
|
0
|
|
|
|
|
if ($c->{max} =~ /^\d+$/) { |
24
|
0
|
|
|
|
|
|
$self->{max} = $c->{max}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
0
|
|
|
|
|
|
push(@e,"'max' must be zero or a positive integer"); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if ($c->{min} =~ /^(0+|-\d+)$/) { |
31
|
0
|
|
|
|
|
|
$self->{min} = $c->{min}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
0
|
|
|
|
|
|
push(@e,"'min' must be zero or a negative integer"); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
0
|
|
|
|
|
|
push(@e,"either 'max' and 'min' or 'bytes' is a required parameter"); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return @e; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub valid { |
45
|
0
|
|
|
0
|
0
|
|
my ($self,$v) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
return undef,'BAD' unless ($v =~ /^(\+|-)?\d*$/); |
48
|
0
|
0
|
|
|
|
|
return undef,'MAX' unless ($v <= $self->{'max'}); |
49
|
0
|
0
|
|
|
|
|
return undef,'MIN' unless ($v >= $self->{'min'}); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $v; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
################################################################################ |
57
|
|
|
|
|
|
|
# Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org). |
58
|
|
|
|
|
|
|
# All rights reserved. |
59
|
|
|
|
|
|
|
# |
60
|
|
|
|
|
|
|
# You may use and distribute Apache::Voodoo under the terms described in the |
61
|
|
|
|
|
|
|
# LICENSE file include in this package. The summary is it's a legalese version |
62
|
|
|
|
|
|
|
# of the Artistic License :) |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
################################################################################ |