| 1 | package Net::FreeDB2::Response::Hello; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright 2002, Vincenzo Zocca. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # See LICENSE section for usage and distribution rights. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | require 5.005_62; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Error qw (:try); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use base qw (Net::FreeDB2::Response Exporter); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | #our @ISA = qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # This allows declaration use Net::FreeDB2::Response::Hello ':all'; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||
| 24 | # will save memory. | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | ) ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | our ( $VERSION ) = '$Revision: 0.8.2.3 $ ' =~ /\$Revision:\s+([^\s]+)/; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | bless ($self, (ref($class) || $class)); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | return ($self->_initialize (@_)); | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | defined ($opt->{content_ref}) and $self->read ($opt); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return ($self); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # Check if content_ref is specified | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | exists ($opt->{content_ref}) || throw Error::Simple ('ERROR: Net::FreeDB2::Response::Hello::read, option \'content_ref\' not defined.'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | # Convert $opt->{content_ref} to @content_ref | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my @content_ref = split (/[\n\r]+/, ${$opt->{content_ref}}); | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | # Parse first line | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $line = shift (@content_ref); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my ($code) = $line =~ /^\s*(\d{3})\s+/; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | defined ($code) || throw Error::Simple ('ERROR: Net::FreeDB2::Response::Hello::read, first line of specified \'content_ref\' does not contain a code.'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $code == 200 || $code == 431 || $code == 431 || throw Error::Simple ('ERROR: Net::FreeDB2::Response::Hello::read, first line of specified \'content_ref\' does not contain a code.'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$code == 200 or $code == 431 or $code == 431
$code == 200 or $code == 431
MC/DC0%0/3
$code == 200 or $code == 431 or $code == 431
$code == 200
$code == 431
$code == 431
Truth table0%0/4
A or B or C
A= $code == 200B= $code == 431C= $code == 431
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ($code == 200) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $self->setError (0); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->setResult ('Handshake successful'); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } elsif ($code == 402) { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->setError (0); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->setResult ('Already shook hands'); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } elsif ($code == 431) { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->setError (1); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->setResult ('Handshake not successful, closing connection'); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | throw Error::Simple ("ERROR: Net::FreeDB2::Response::Hello::read, unknown code '$code' returned."); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||||||||||||||||