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;
30 my $term = $args->{TERM};
50 { TERM => 'Number 10',
54 $args->{ENTRIES} = $entries;
55 $args->{STATUS} = Net::Z3950::SimpleServer::ScanPartial;
56 print "Welcome to scan....\n";
57 print "You scanned for term '$term'\n";
61 sub my_search_handler {
64 name => "Peter Dornan",
66 collaboration => "ATLAS"
68 name => "Jorn Dines Hansen",
70 collaboration => "HERA-B"
72 name => "Alain Blondel",
73 title => "Head of coll.",
74 collaboration => "ALEPH"
77 my $session = $args->{HANDLE};
78 my $set_id = $args->{SETNAME};
79 my @database_list = @{ $args->{DATABASES} };
80 my $query = $args->{QUERY};
83 print "------------------------------------------------------------\n";
84 print "Processing query : $query\n";
85 printf("Database set : %s\n", join(" ", @database_list));
86 print "Setname : $set_id\n";
87 print "------------------------------------------------------------\n";
89 $args->{HITS} = $hits;
90 $session->{$set_id} = $data;
91 $session->{__HITS} = $hits;
95 sub my_fetch_handler {
97 my $session = $args->{HANDLE};
98 my $set_id = $args->{SETNAME};
99 my $data = $session->{$set_id};
100 my $offset = $args->{OFFSET};
101 my $record = "<xml>";
103 my $hits = $session->{__HITS};
104 my $href = $data->[$offset - 1];
106 $args->{REP_FORM} = Net::Z3950::OID::xml;
107 foreach $field (keys %$href) {
108 $record .= "<" . $field . ">" . $href->{$field} . "</" . $field . ">";
112 $args->{RECORD} = $record;
113 if ($offset == $session->{__HITS}) {
119 my $handler = new Net::Z3950::SimpleServer(
120 INIT => \&my_init_handler,
121 SEARCH => \&my_search_handler,
122 SCAN => \&my_scan_handler,
123 FETCH => \&my_fetch_handler );
125 $handler->launch_server("ztest.pl", @ARGV);
128 ## $Log: ztest.pl,v $
129 ## Revision 1.10 2001-08-30 13:15:11 sondberg
130 ## Corrected a memory leak, one more to go.
132 ## Revision 1.9 2001/08/29 11:48:36 sondberg
135 ## Net::Z3950::SimpleServer::ScanSuccess
136 ## Net::Z3950::SimpleServer::ScanPartial
138 ## and a bit of documentation.
140 ## Revision 1.8 2001/08/24 14:00:20 sondberg
141 ## Added support for scan.
143 ## Revision 1.7 2001/03/13 14:20:21 sondberg