| 1 | package GoXML::XQI; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # (c)1999 XML Global Technologies, Inc. | ||||||||||||||||||||||||||||
| 4 | # All Rights Reserved. | ||||||||||||||||||||||||||||
| 5 | # Author: Matthew MacKenzie <matt@xmlglobal.com> | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Socket; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | @ISA = qw(Exporter AutoLoader); | |||||||||||||||||||||||||||
| 16 | 1 | $VERSION = '1.1.4'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | my($class) = shift; | |||||||||||||||||||||||||||
| 20 | 0 | my($self) = {}; | |||||||||||||||||||||||||||
| 21 | 0 | bless($self,$class); | |||||||||||||||||||||||||||
| 22 | 0 | $self->_init(@_); | |||||||||||||||||||||||||||
| 23 | 0 | return($self); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub _init { | ||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 27 | 0 | my($self) = shift; | |||||||||||||||||||||||||||
| 28 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | my(%extra) = @_; | |||||||||||||||||||||||||||
| 30 | 0 | @$self{keys %extra} = values %extra; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub Query { | ||||||||||||||||||||||||||
|
Subroutine
Query: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my($self) = shift; | |||||||||||||||||||||||||||
| 37 | 0 | my(%info) = @_; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my($sock) = _socket($self); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my($q) = "<?xml version=\"1.0\"?>\n<GOXML>\n <QUERY>\n"; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | croak "You must supply a keyword\n" unless $info{KEYWORD}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | $q .= " <KEYWORD>$info{KEYWORD}</KEYWORD>\n" . | |||||||||||||||||||||||||||
| 46 | " <TAG>$info{TAG}</TAG>\n" . | ||||||||||||||||||||||||||||
| 47 | " <CATEGORY>$info{CATEGORY}</CATEGORY>\n" . | ||||||||||||||||||||||||||||
| 48 | " </QUERY>\n</GOXML>\n"; | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ($self->{VERBOSE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | $self->verbose("Now making Query to $self->{HOST}:$self->{PORT}..\n***$q***"); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 0 | print $sock $q; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ($self->{VERBOSE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | $self->verbose("Request sent, returning filehandle."); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 0 | return($sock); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub Submit { | ||||||||||||||||||||||||||
|
Subroutine
Submit: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | 0 | my %info = @_; | |||||||||||||||||||||||||||
| 64 | 0 | my $sock = _socket($self); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | my $q = "<?xml version=\"1.0\"?>\n<GOXML>\n <RESOURCE>\n"; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if (!($info{HREF} && $info{DESCRIPTION})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info{"HREF"} and $info{"DESCRIPTION"}
MC/DC0%0/2
$info{"HREF"} and $info{"DESCRIPTION"}
$info{"HREF"}
$info{"DESCRIPTION"}
Truth table0%0/3
A and B
A= $info{"HREF"}B= $info{"DESCRIPTION"}
| |||||||||||||||||||||||||||||
| 69 | 0 | croak "You need to supply the HREF or DESCRIPTION.\n"; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if (!$info{CATEGORY}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | $info{CATEGORY} = 8; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | $q .= " <HREF>$info{HREF}</HREF>\n" . | |||||||||||||||||||||||||||
| 76 | " <DESCRIPTION>$info{DESCRIPTION}</DESCRIPTION>\n" . | ||||||||||||||||||||||||||||
| 77 | " <CATEGORY>$info{CATEGORY}</CATEGORY>\n" . | ||||||||||||||||||||||||||||
| 78 | " </RESOURCE>\n</GOXML>\n"; | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($self->{VERBOSE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $self->verbose("Sending Resource..\nDetails:\n$q"); | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | print $sock $q; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ($self->{VERBOSE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | $self->verbose("Resource sent, processing answer.."); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | 0 | my ($resp) = ''; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | while (<$sock>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | $resp .= $_; | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | last if $_ =~ m!</GOXML>!i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($resp =~ /QUEUED/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($self->{VERBOSE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | $self->verbose("Resource addition suceeded.\nDetails:\n$resp"); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | 0 | return(1); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ($self->{VERBOSE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 0 | $self->verbose("Resource addition failed."); | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ($resp =~ m!DUPLICATE!) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | $self->verbose("\t-The resource submitted has already been indexed or queued."); | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | return(0); | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub _socket { | ||||||||||||||||||||||||||
|
Subroutine
_socket: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 115 | 0 | my($self) = shift; | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | my($remote) = $self->{HOST} || 'www.goxml.com'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'HOST'} || 'www.goxml.com'
MC/DC0%0/1
$self->{'HOST'} || 'www.goxml.com'
$self->{'HOST'}
Truth table0%0/2
A
A= $self->{'HOST'}
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my($port) = $self->{PORT} || '5910'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'PORT'} || '5910'
MC/DC0%0/1
$self->{'PORT'} || '5910'
$self->{'PORT'}
Truth table0%0/2
A
A= $self->{'PORT'}
| |||||||||||||||||||||||||||||
| 118 | 0 | my($iaddr,$paddr,$proto,$line); | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | $iaddr = inet_aton($remote) or croak ($!); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $paddr = sockaddr_in($port, $iaddr) or croak ($!); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $proto = getprotobyname('tcp') or croak ("$!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | socket(SOCK, PF_INET, SOCK_STREAM, $proto) or croak ($!); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | connect(SOCK, $paddr) or croak ($!); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | autoflush SOCK 1; | |||||||||||||||||||||||||||
| 125 | 0 | return(\*SOCK); | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub verbose { | ||||||||||||||||||||||||||
|
Subroutine
verbose: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 129 | 0 | my($self) = shift; | |||||||||||||||||||||||||||
| 130 | 0 | my($msg) = shift; | |||||||||||||||||||||||||||
| 131 | 0 | print STDERR $msg,"\n"; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 1 | 1; | |||||||||||||||||||||||||||
| 135 | __END__ | ||||||||||||||||||||||||||||