4 use Net::Z3950::SimpleServer;
12 foreach $key (keys %$href) {
13 printf("%10s => %s\n", $key, $href->{$key});
22 $args->{IMP_NAME} = "DemoServer";
23 $args->{IMP_ID} = "81";
24 $args->{IMP_VER} = "3.14159";
25 $args->{ERR_CODE} = 0;
26 $args->{HANDLE} = $session;
27 if (defined($args->{PASS}) && defined($args->{USER})) {
28 printf("Received USER/PASS=%s/%s\n", $args->{USER},$args->{PASS});
35 my $term = $args->{TERM};
55 { TERM => 'Number 10',
59 $args->{ENTRIES} = $entries;
60 $args->{STATUS} = Net::Z3950::SimpleServer::ScanPartial;
61 print "Welcome to scan....\n";
62 print "You scanned for term '$term'\n";
66 sub my_search_handler {
69 name => "Peter Dornan",
71 collaboration => "ATLAS"
73 name => "Jorn Dines Hansen",
75 collaboration => "HERA-B"
77 name => "Alain Blondel",
78 title => "Head of coll.",
79 collaboration => "ALEPH"
82 my $session = $args->{HANDLE};
83 my $set_id = $args->{SETNAME};
84 my @database_list = @{ $args->{DATABASES} };
85 my $query = $args->{QUERY};
88 print "------------------------------------------------------------\n";
89 print "Processing query : $query\n";
90 printf("Database set : %s\n", join(" ", @database_list));
91 print "Setname : $set_id\n";
92 print "------------------------------------------------------------\n";
94 $args->{HITS} = $hits;
95 $session->{$set_id} = $data;
96 $session->{__HITS} = $hits;
100 sub my_fetch_handler {
102 my $session = $args->{HANDLE};
103 my $set_id = $args->{SETNAME};
104 my $data = $session->{$set_id};
105 my $offset = $args->{OFFSET};
106 my $record = "<xml>";
108 my $hits = $session->{__HITS};
109 my $href = $data->[$offset - 1];
111 $args->{REP_FORM} = Net::Z3950::OID::xml;
112 foreach $field (keys %$href) {
113 $record .= "<" . $field . ">" . $href->{$field} . "</" . $field . ">";
117 $args->{RECORD} = $record;
118 if ($offset == $session->{__HITS}) {
124 my $handler = new Net::Z3950::SimpleServer(
125 INIT => "main::my_init_handler",
126 SEARCH => "main::my_search_handler",
127 SCAN => "main::my_scan_handler",
128 FETCH => "main::my_fetch_handler" );
130 $handler->launch_server("ztest.pl", @ARGV);
133 ## $Log: ztest.pl,v $
134 ## Revision 1.12 2004-05-11 12:15:16 sondberg
135 ## Simpleserver is now thread proof.
137 ## Revision 1.11 2002/09/16 13:55:53 sondberg
138 ## Added support for authentication into SimpleServer.
140 ## Revision 1.10 2001/08/30 13:15:11 sondberg
141 ## Corrected a memory leak, one more to go.
143 ## Revision 1.9 2001/08/29 11:48:36 sondberg
146 ## Net::Z3950::SimpleServer::ScanSuccess
147 ## Net::Z3950::SimpleServer::ScanPartial
149 ## and a bit of documentation.
151 ## Revision 1.8 2001/08/24 14:00:20 sondberg
152 ## Added support for scan.
154 ## Revision 1.7 2001/03/13 14:20:21 sondberg