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_VER} = "3.14159";
24 $args->{ERR_CODE} = 0;
25 $args->{HANDLE} = $session;
26 if (defined($args->{PASS}) && defined($args->{USER})) {
27 printf("Received USER/PASS=%s/%s\n", $args->{USER},$args->{PASS});
34 my $term = $args->{TERM};
54 { TERM => 'Number 10',
58 $args->{ENTRIES} = $entries;
59 $args->{STATUS} = Net::Z3950::SimpleServer::ScanPartial;
60 print "Welcome to scan....\n";
61 print "You scanned for term '$term'\n";
65 sub my_search_handler {
68 name => "Peter Dornan",
70 collaboration => "ATLAS"
72 name => "Jorn Dines Hansen",
74 collaboration => "HERA-B"
76 name => "Alain Blondel",
77 title => "Head of coll.",
78 collaboration => "ALEPH"
81 my $session = $args->{HANDLE};
82 my $set_id = $args->{SETNAME};
83 my @database_list = @{ $args->{DATABASES} };
84 my $query = $args->{QUERY};
87 print "------------------------------------------------------------\n";
88 print "Processing query : $query\n";
89 printf("Database set : %s\n", join(" ", @database_list));
90 print "Setname : $set_id\n";
91 print "------------------------------------------------------------\n";
93 $args->{HITS} = $hits;
94 $session->{$set_id} = $data;
95 $session->{__HITS} = $hits;
99 sub my_fetch_handler {
101 my $session = $args->{HANDLE};
102 my $set_id = $args->{SETNAME};
103 my $data = $session->{$set_id};
104 my $offset = $args->{OFFSET};
105 my $record = "<xml>";
107 my $hits = $session->{__HITS};
108 my $href = $data->[$offset - 1];
110 $args->{REP_FORM} = Net::Z3950::OID::xml;
111 foreach $field (keys %$href) {
112 $record .= "<" . $field . ">" . $href->{$field} . "</" . $field . ">";
116 $args->{RECORD} = $record;
117 if ($offset == $session->{__HITS}) {
123 my $handler = new Net::Z3950::SimpleServer(
124 INIT => \&my_init_handler,
125 SEARCH => \&my_search_handler,
126 SCAN => \&my_scan_handler,
127 FETCH => \&my_fetch_handler );
129 $handler->launch_server("ztest.pl", @ARGV);
132 ## $Log: ztest.pl,v $
133 ## Revision 1.11 2002-09-16 13:55:53 sondberg
134 ## Added support for authentication into SimpleServer.
136 ## Revision 1.10 2001/08/30 13:15:11 sondberg
137 ## Corrected a memory leak, one more to go.
139 ## Revision 1.9 2001/08/29 11:48:36 sondberg
142 ## Net::Z3950::SimpleServer::ScanSuccess
143 ## Net::Z3950::SimpleServer::ScanPartial
145 ## and a bit of documentation.
147 ## Revision 1.8 2001/08/24 14:00:20 sondberg
148 ## Added support for scan.
150 ## Revision 1.7 2001/03/13 14:20:21 sondberg