line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Scalar.pm,v 1.11 2003/06/06 18:45:02 unimlo Exp $ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::ACL::Match::Scalar; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
8
|
1
|
|
|
1
|
|
4
|
use vars qw( $VERSION @ISA ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@ISA = qw( Net::ACL::Match ); |
13
|
|
|
|
|
|
|
$VERSION = '0.07'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
## Module Imports ## |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use Net::ACL::Match; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
18
|
1
|
|
|
1
|
|
5
|
use Net::ACL::Rule qw( :rc ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
115
|
|
19
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
345
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
## Public Class Methods ## |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new |
24
|
|
|
|
|
|
|
{ |
25
|
14
|
|
|
14
|
1
|
22
|
my $proto = shift; |
26
|
14
|
|
33
|
|
|
48
|
my $class = ref $proto || $proto; |
27
|
14
|
50
|
33
|
|
|
99
|
@_ = @{$_[0]} if (scalar @_ == 1) && (ref $_[0] eq 'ARRAY'); |
|
0
|
|
|
|
|
0
|
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
|
|
41
|
my $this = { |
30
|
|
|
|
|
|
|
_index => shift, |
31
|
|
|
|
|
|
|
_value => shift |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
14
|
50
|
33
|
|
|
97
|
croak "Index need to be a number\n" unless defined $this->{_index} && $this->{_index} =~ /^[0-9]+$/; |
35
|
|
|
|
|
|
|
|
36
|
14
|
|
|
|
|
30
|
bless($this,$class); |
37
|
14
|
|
|
|
|
90
|
return $this; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
## Public Object Methods ## |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub match |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
0
|
1
|
0
|
my $this = shift; |
45
|
0
|
0
|
|
|
|
0
|
return $_[$this->{_index}] eq $this->{_value} ? ACL_MATCH : ACL_NOMATCH; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub value |
49
|
|
|
|
|
|
|
{ |
50
|
14
|
|
|
14
|
0
|
17
|
my $this = shift; |
51
|
14
|
50
|
|
|
|
46
|
$this->{_value} = @_ ? shift : $this->{_value}; |
52
|
14
|
|
|
|
|
62
|
return $this->{_value}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
## POD ## |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Net::ACL::Match::Scalar - Class matching a scalar data element |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
use Net::ACL::Match::Scalar; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Construction |
68
|
|
|
|
|
|
|
my $match = new Net::ACL::Match::Scalar([42,1]); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Accessor Methods |
71
|
|
|
|
|
|
|
$rc = $match->match(@data); # same as: $data[1] eq 42 ? ACL_MATCH : ACL_NOMATCH; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This module is a very simple array element testing utility to allow |
76
|
|
|
|
|
|
|
simple value matching with L. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item new() - create a new Net::ACL::Match::Scalar object |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $match = new Net::ACL::Match::Scalar(42,1); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This is the constructor for Net::ACL::Match::Scalar objects. |
87
|
|
|
|
|
|
|
It returns a reference to the newly created object. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
It takes one argument. If the argument is a array reference with one element, |
90
|
|
|
|
|
|
|
the element will be matched with the first argument to the match method. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
If an array reference has more then one element, the second element should be |
93
|
|
|
|
|
|
|
the argument number to be matched in the match method. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Otherwise, the value it self will be matched with the first argument of |
96
|
|
|
|
|
|
|
the match method. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 ACCESSOR METHODS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item match() |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This function matches the arguments according to the arguments of the |
107
|
|
|
|
|
|
|
constructor and returns either C or C as exported by |
108
|
|
|
|
|
|
|
Net::ACL::Rule with C<:rc>. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SEE ALSO |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Net::ACL::Match, Net::ACL::Rule, Net::ACL, Net::ACL::Set::Scalar |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Martin Lorensen |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
## End Package Net::ACL::Match::Scalar ## |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |