Markdown
[simpleserver-moved-to-github.git] / SimpleServer.pm
index e0cfda4..5a5475e 100644 (file)
@@ -1,5 +1,5 @@
 ## This file is part of simpleserver
-## Copyright (C) 2000-2011 Index Data.
+## Copyright (C) 2000-2015 Index Data.
 ## All rights reserved.
 ## Redistribution and use in source and binary forms, with or without
 ## modification, are permitted provided that the following conditions are met:
@@ -36,7 +36,7 @@ require AutoLoader;
 
 @ISA = qw(Exporter AutoLoader DynaLoader);
 @EXPORT = qw( );
-$VERSION = '1.15';
+$VERSION = '1.20';
 
 bootstrap Net::Z3950::SimpleServer $VERSION;
 
@@ -96,7 +96,9 @@ sub launch_server {
        if (defined($self->{DELETE})) {
                set_delete_handler($self->{DELETE});
        }
-
+       if (defined($self->{START})) {
+               set_start_handler($self->{START});
+       }
        start_server(@args);
 }
 
@@ -112,12 +114,15 @@ package Net::Z3950::RPN::Or;
 our @ISA = qw(Net::Z3950::RPN::Node);
 package Net::Z3950::RPN::AndNot;
 our @ISA = qw(Net::Z3950::RPN::Node);
+package Net::Z3950::RPN::Prox;
+our @ISA = qw(Net::Z3950::RPN::Node);
 package Net::Z3950::RPN::Term;
 our @ISA = qw(Net::Z3950::RPN::Node);
 package Net::Z3950::RPN::RSID;
 our @ISA = qw(Net::Z3950::RPN::Node);
 package Net::Z3950::RPN::Attributes;
 package Net::Z3950::RPN::Attribute;
+package Net::Z3950::RPN::Prox::Attributes;
 package Net::Z3950::FacetList;
 package Net::Z3950::FacetField;
 package Net::Z3950::FacetTerms;
@@ -142,6 +147,9 @@ sub toPQF {
        return '@and ' . $this->[0]->toPQF() . ' ' . $this->[1]->toPQF();
     } elsif ($class eq "Net::Z3950::RPN::AndNot") {
        return '@not ' . $this->[0]->toPQF() . ' ' . $this->[1]->toPQF();
+    } elsif ($class eq "Net::Z3950::RPN::Prox") {
+    my $pattrs = $this->[3];
+       return '@prox ' . $pattrs->{exclusion} . ' ' . $pattrs->{distance} . ' ' . $pattrs->{ordered} . ' ' . $pattrs->{relationType} . (defined $pattrs->{known} ? ' k ' . $pattrs->{known} : ' p ' . $pattrs->{zprivate}) . ' ' . $this->[0]->toPQF() . ' ' . $this->[1]->toPQF();
     } elsif ($class eq "Net::Z3950::RPN::RSID") {
        return '@set ' . $this->{id};
     } elsif ($class ne "Net::Z3950::RPN::Term") {
@@ -242,6 +250,7 @@ environments) whenever a new connection is received.
 The programmer can specify subroutines to take care of the following type
 of events:
 
+  - Start service (called once).
   - Initialize request
   - Search request
   - Present request
@@ -264,6 +273,7 @@ The Perl programmer specifies the event handlers for the server by
 means of the SimpleServer object constructor
 
   my $z = new Net::Z3950::SimpleServer(
+                        START   =>      \&my_start_handler,
                        INIT    =>      \&my_init_handler,
                        CLOSE   =>      \&my_close_handler,
                        SEARCH  =>      \&my_search_handler,
@@ -307,6 +317,23 @@ application invocation: <http://indexdata.com/yaz/doc/server.invocation.tkl>
 In particular, you need to use the -T switch to start your SimpleServer
 in threaded mode.
 
+=head2 Start handler
+
+The start handler is called when service is started. The argument hash
+passed to the start handler has the form
+
+  $args = {
+            CONFIG =>  "default-config" ## GFS config (as given by -c)
+         };
+
+
+The purpose of the start handler is to read the configuration file
+for the Generic Frontend Server . This is specified by option -c.
+If -c is omitted, the configuration file is set to "default-config".
+
+The start handler is optional. It is supported in Simpleserver 1.16 and
+later.
+
 =head2 Init handler
 
 The init handler is called whenever a Z39.50 client is attempting
@@ -883,13 +910,13 @@ http://search.cpan.org/~esummers/CQL-Parser/
 
 =head1 AUTHORS
 
-Anders Sønderberg (sondberg@indexdata.dk),
+Anders Sønderberg (sondberg@indexdata.dk),
 Sebastian Hammer (quinn@indexdata.dk),
 Mike Taylor (indexdata.com).
 
 =head1 COPYRIGHT AND LICENCE
 
-Copyright (C) 2000-2011 by Index Data.
+Copyright (C) 2000-2015 by Index Data.
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.8.4 or,