4 use Net::Z3950::SimpleServer;
13 foreach $key (keys %$href) {
14 printf("%10s => %s\n", $key, $href->{$key});
23 $args->{IMP_NAME} = "DemoServer";
24 $args->{IMP_VER} = "3.14159";
25 $args->{ERR_CODE} = 0;
26 $args->{HANDLE} = $session;
31 my $term = $args->{TERM};
51 { TERM => 'Number 10',
57 $args->{ENTRIES} = $entries;
58 $args->{STATUS} = Net::Z3950::SimpleServer::ScanPartial;
59 print "Welcome to scan....\n";
60 print "You scanned for term '$term'\n";
64 sub my_search_handler {
67 name => "Peter Dornan",
69 collaboration => "ATLAS"
71 name => "Jorn Dines Hansen",
73 collaboration => "HERA-B"
75 name => "Alain Blondel",
76 title => "Head of coll.",
77 collaboration => "ALEPH"
80 my $session = $args->{HANDLE};
81 my $set_id = $args->{SETNAME};
82 my @database_list = @{ $args->{DATABASES} };
83 my $query = $args->{QUERY};
86 print "------------------------------------------------------------\n";
87 print "Processing query : $query\n";
88 printf("Database set : %s\n", join(" ", @database_list));
89 print "Setname : $set_id\n";
90 print "------------------------------------------------------------\n";
92 $args->{HITS} = $hits;
93 $session->{$set_id} = $data;
94 $session->{__HITS} = $hits;
98 sub my_fetch_handler {
100 my $session = $args->{HANDLE};
101 my $set_id = $args->{SETNAME};
102 my $data = $session->{$set_id};
103 my $offset = $args->{OFFSET};
104 my $record = "<xml>";
106 my $hits = $session->{__HITS};
107 my $href = $data->[$offset - 1];
109 $args->{REP_FORM} = Net::Z3950::OID::xml;
110 foreach $field (keys %$href) {
111 $record .= "<" . $field . ">" . $href->{$field} . "</" . $field . ">";
115 $args->{RECORD} = $record;
116 if ($offset == $session->{__HITS}) {
122 my $handler = new Net::Z3950::SimpleServer(
123 INIT => \&my_init_handler,
124 SEARCH => \&my_search_handler,
125 SCAN => \&my_scan_handler,
126 FETCH => \&my_fetch_handler );
128 $handler->launch_server("ztest.pl", @ARGV);
131 ## $Log: ztest.pl,v $
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