line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GoXML::XQI; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# (c)1999 XML Global Technologies, Inc. |
4
|
|
|
|
|
|
|
# All Rights Reserved. |
5
|
|
|
|
|
|
|
# Author: Matthew MacKenzie |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
853
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
8
|
1
|
|
|
1
|
|
1663
|
use IO::Handle; |
|
1
|
|
|
|
|
10849
|
|
|
1
|
|
|
|
|
49
|
|
9
|
1
|
|
|
1
|
|
1608
|
use Socket; |
|
1
|
|
|
|
|
6413
|
|
|
1
|
|
|
|
|
1042
|
|
10
|
1
|
|
|
1
|
|
9
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
11
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1394
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader); |
16
|
|
|
|
|
|
|
$VERSION = '1.1.4'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
0
|
|
|
0
|
0
|
|
my($class) = shift; |
20
|
0
|
|
|
|
|
|
my($self) = {}; |
21
|
0
|
|
|
|
|
|
bless($self,$class); |
22
|
0
|
|
|
|
|
|
$self->_init(@_); |
23
|
0
|
|
|
|
|
|
return($self); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _init { |
27
|
0
|
|
|
0
|
|
|
my($self) = shift; |
28
|
0
|
0
|
|
|
|
|
if (@_) { |
29
|
0
|
|
|
|
|
|
my(%extra) = @_; |
30
|
0
|
|
|
|
|
|
@$self{keys %extra} = values %extra; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub Query { |
36
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
37
|
0
|
|
|
|
|
|
my(%info) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my($sock) = _socket($self); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my($q) = "\n\n \n"; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
croak "You must supply a keyword\n" unless $info{KEYWORD}; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$q .= " $info{KEYWORD}\n" . |
46
|
|
|
|
|
|
|
" $info{TAG}\n" . |
47
|
|
|
|
|
|
|
" $info{CATEGORY}\n" . |
48
|
|
|
|
|
|
|
" \n\n"; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ($self->{VERBOSE}) { |
51
|
0
|
|
|
|
|
|
$self->verbose("Now making Query to $self->{HOST}:$self->{PORT}..\n***$q***"); |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
print $sock $q; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if ($self->{VERBOSE}) { |
56
|
0
|
|
|
|
|
|
$self->verbose("Request sent, returning filehandle."); |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
return($sock); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub Submit { |
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
my %info = @_; |
64
|
0
|
|
|
|
|
|
my $sock = _socket($self); |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $q = "\n\n \n"; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
0
|
|
|
|
if (!($info{HREF} && $info{DESCRIPTION})) { |
69
|
0
|
|
|
|
|
|
croak "You need to supply the HREF or DESCRIPTION.\n"; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
|
|
|
|
if (!$info{CATEGORY}) { |
72
|
0
|
|
|
|
|
|
$info{CATEGORY} = 8; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$q .= " $info{HREF}\n" . |
76
|
|
|
|
|
|
|
" $info{DESCRIPTION}\n" . |
77
|
|
|
|
|
|
|
" $info{CATEGORY}\n" . |
78
|
|
|
|
|
|
|
" \n\n"; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if ($self->{VERBOSE}) { |
81
|
0
|
|
|
|
|
|
$self->verbose("Sending Resource..\nDetails:\n$q"); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
print $sock $q; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
if ($self->{VERBOSE}) { |
87
|
0
|
|
|
|
|
|
$self->verbose("Resource sent, processing answer.."); |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
|
|
|
my ($resp) = ''; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
while (<$sock>) { |
92
|
0
|
|
|
|
|
|
$resp .= $_; |
93
|
0
|
0
|
|
|
|
|
last if $_ =~ m!!i; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
if ($resp =~ /QUEUED/) { |
97
|
0
|
0
|
|
|
|
|
if ($self->{VERBOSE}) { |
98
|
0
|
|
|
|
|
|
$self->verbose("Resource addition suceeded.\nDetails:\n$resp"); |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
return(1); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else { |
103
|
0
|
0
|
|
|
|
|
if ($self->{VERBOSE}) { |
104
|
0
|
|
|
|
|
|
$self->verbose("Resource addition failed."); |
105
|
0
|
0
|
|
|
|
|
if ($resp =~ m!DUPLICATE!) { |
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
|
|
|
|
|
|
|
sub _socket { |
115
|
0
|
|
|
0
|
|
|
my($self) = shift; |
116
|
0
|
|
0
|
|
|
|
my($remote) = $self->{HOST} || 'www.goxml.com'; |
117
|
0
|
|
0
|
|
|
|
my($port) = $self->{PORT} || '5910'; |
118
|
0
|
|
|
|
|
|
my($iaddr,$paddr,$proto,$line); |
119
|
0
|
0
|
|
|
|
|
$iaddr = inet_aton($remote) or croak ($!); |
120
|
0
|
0
|
|
|
|
|
$paddr = sockaddr_in($port, $iaddr) or croak ($!); |
121
|
0
|
0
|
|
|
|
|
$proto = getprotobyname('tcp') or croak ("$!"); |
122
|
0
|
0
|
|
|
|
|
socket(SOCK, PF_INET, SOCK_STREAM, $proto) or croak ($!); |
123
|
0
|
0
|
|
|
|
|
connect(SOCK, $paddr) or croak ($!); |
124
|
0
|
|
|
|
|
|
autoflush SOCK 1; |
125
|
0
|
|
|
|
|
|
return(\*SOCK); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub verbose { |
129
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
130
|
0
|
|
|
|
|
|
my($msg) = shift; |
131
|
0
|
|
|
|
|
|
print STDERR $msg,"\n"; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
135
|
|
|
|
|
|
|
__END__ |