3 # Copyright ByWater Solutions 2015
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use Getopt
::Long
qw(:config no_ignore_case);
28 use Koha
::Z3950Responder
;
32 z3950_responder.pl [-h|--help] [--man] [-a <pdufile>] [-v <loglevel>] [-l <logfile>] [-u <user>]
33 [-c <config>] [-t <minutes>] [-k <kilobytes>] [-d <daemon>] [-p <pidfile>]
34 [-C certfile] [-zKiDST1] [-m <time-format>] [-w <directory>] [--debug]
35 [--add-item-status=SUBFIELD] [--prefetch=NUM_RECORDS] [--config-dir=<directory>]
40 See https://software.indexdata.com/yaz/doc/server.invocation.html for more information about YAZ options
47 Prints a brief usage message and exits.
51 Displays manual page and exits.
55 Turns on debug logging to the screen and the single-process mode.
57 =item B<--add-item-status=SUBFIELD>
59 If given, adds item status information to the given subfield.
61 =item B<--add-status-multi-subfield>
63 With the above, instead of putting multiple item statuses in one subfield, adds a subfield for each
66 =item B<--prefetch=NUM_RECORDS>
68 Number of records to prefetch. Defaults to 20.
70 =item B<--config-dir=directory>
72 Directory where to find configuration files required for proper operation. Defaults to z3950 under
73 the Koha config directory.
79 The item status strings added by B<--add-item-status> can be configured with the B<Z3950_STATUS>
80 authorized value, using the following keys:
104 my $add_item_status_subfield;
105 my $add_status_multi_subfield;
115 my ( $opt_name, $opt_value ) = @_;
117 push @yaz_options, "-$opt_name", "$opt_value";
120 sub pass_yaz_option
{
121 my ( $opt_name ) = @_;
123 push @yaz_options, "-$opt_name";
129 '--debug' => \
$debug,
130 '--add-item-status=s' => \
$add_item_status_subfield,
131 '--add-status-multi-subfield' => \
$add_status_multi_subfield,
132 '--prefetch=i' => \
$prefetch,
133 '--config-dir=s' => \
$config_dir,
134 # Pass through YAZ options.
135 'a=s' => \
&add_yaz_option
,
136 'v=s' => \
&add_yaz_option
,
137 'l=s' => \
&add_yaz_option
,
138 'u=s' => \
&add_yaz_option
,
139 'c=s' => \
&add_yaz_option
,
140 't=s' => \
&add_yaz_option
,
141 'k=s' => \
&add_yaz_option
,
142 'd=s' => \
&add_yaz_option
,
143 'p=s' => \
&add_yaz_option
,
144 'C=s' => \
&add_yaz_option
,
145 'm=s' => \
&add_yaz_option
,
146 'w=s' => \
&add_yaz_option
,
147 'z' => \
&pass_yaz_option
,
148 'K' => \
&pass_yaz_option
,
149 'i' => \
&pass_yaz_option
,
150 'D' => \
&pass_yaz_option
,
151 'S' => \
&pass_yaz_option
,
152 'T' => \
&pass_yaz_option
,
153 '1' => \
&pass_yaz_option
156 pod2usage
(1) if $help;
157 pod2usage
( -verbose
=> 2 ) if $man;
159 # If config_dir is not defined, default to z3950 under the Koha config directory
161 (undef, $config_dir) = fileparse
(Koha
::Config
->guess_koha_conf);
162 $config_dir .= 'z3950/';
164 $config_dir .= '/' if ($config_dir !~ /\
/$/);
167 # Create and start the server.
169 my $z = Koha
::Z3950Responder
->new( {
170 add_item_status_subfield
=> $add_item_status_subfield,
171 add_status_multi_subfield
=> $add_status_multi_subfield,
173 num_to_prefetch
=> $prefetch,
174 config_dir
=> $config_dir,
175 yaz_options
=> [ @yaz_options, @ARGV ],