| 1 | package Net::SPOCP; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | require Exporter; | |||||||||||||||||||
| 8 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||
| 13 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||
| 14 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # This allows declaration use Net::SPOCP ':all'; | ||||||||||||||||||||
| 17 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||
| 18 | # will save memory. | ||||||||||||||||||||
| 19 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||
| 20 | spocp_split_parts | ||||||||||||||||||||
| 21 | spocp_map | ||||||||||||||||||||
| 22 | SPOCP_PORT; | ||||||||||||||||||||
| 23 | ) ] ); | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 1 | our @EXPORT = qw( | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||
| 30 | 1 | our $VERSION = '0.14'; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 1 | ▶ | use Net::SPOCP::SExpr; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | 1 | ▶ | use Net::SPOCP::Protocol; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 1 | my $SPOCP_PORT = 4751; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | # Preloaded methods go here. | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | sub new | ||||||||||||||||||||
| 41 | 1 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||
| 42 | 1 | my $self = shift; | |||||||||||||||||||
| 43 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 1 | my %args = @_; | |||||||||||||||||||
| 46 | 1 | my $me = bless \%args,$class; | |||||||||||||||||||
| 47 | 1 | $me->init(); | |||||||||||||||||||
| 48 | 0 | $me; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | sub rule | ||||||||||||||||||||
| 52 | 1 | ▶ | { | ||||||||||||||||||
|
Subroutine
rule: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 53 | 1 | my $self = shift; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | my %args = @_; | |||||||||||||||||||
| 56 | 1 | foreach my $tag (qw(resource action subject)) | |||||||||||||||||||
| 57 | { | ||||||||||||||||||||
| 58 | 3 | unshift(@{$args{$tag}},$tag); | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 1 | Net::SPOCP::SExpr->create([spocp=>$args{resource},$args{action},$args{subject}]); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | # rule-utilities | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | sub spocp_split_parts | ||||||||||||||||||||
| 67 | 1 | ▶ | { | ||||||||||||||||||
|
Subroutine
spocp_split_parts: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 68 | 1 | my $split = shift; | |||||||||||||||||||
| 69 | 1 | my @out; | |||||||||||||||||||
| 70 | 1 | foreach my $x (@_) | |||||||||||||||||||
| 71 | { | ||||||||||||||||||||
| 72 | 3 | push(@out,split($split,$x)); | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | 1 | \@out; | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | sub spocp_map | ||||||||||||||||||||
| 78 | 1 | ▶ | { | ||||||||||||||||||
|
Subroutine
spocp_map: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 79 | 1 | my @out; | |||||||||||||||||||
| 80 | 1 | ▶ | while (@_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | { | ||||||||||||||||||||
| 82 | 6 | my $k = shift; | |||||||||||||||||||
| 83 | 6 | my $v = shift; | |||||||||||||||||||
| 84 | 6 | push(@out,[$k,$v]); | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | 1 | \@out; | |||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | sub l_encode | ||||||||||||||||||||
| 90 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
l_encode: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 91 | 0 | ▶ | return "" unless $_[1]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | 0 | sprintf("%d:%s",length($_[1]),$_[1]); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 1 | 1; | |||||||||||||||||||
| 99 | __END__ | ||||||||||||||||||||