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>.
22 use File::Basename qw( fileparse );
23 use Getopt::Long qw( GetOptions :config no_ignore_case );
24 use Pod::Usage qw( pod2usage );
27 use Koha::Z3950Responder;
31 z3950_responder.pl [-h|--help] [--man] [-a <pdufile>] [-v <loglevel>] [-l <logfile>] [-u <user>]
32 [-c <config>] [-t <minutes>] [-k <kilobytes>] [-d <daemon>] [-p <pidfile>]
33 [-C certfile] [-zKiDST1] [-m <time-format>] [-w <directory>] [--debug]
34 [--add-item-status=SUBFIELD] [--prefetch=NUM_RECORDS] [--config-dir=<directory>]
39 See https://software.indexdata.com/yaz/doc/server.invocation.html for more information about YAZ options
46 Prints a brief usage message and exits.
50 Displays manual page and exits.
54 Turns on debug logging to the screen and the single-process mode.
56 =item B<--add-item-status=SUBFIELD>
58 If given, adds item status information to the given subfield.
60 =item B<--add-status-multi-subfield>
62 With the above, instead of putting multiple item statuses in one subfield, adds a subfield for each
65 =item B<--prefetch=NUM_RECORDS>
67 Number of records to prefetch. Defaults to 20.
69 =item B<--config-dir=directory>
71 Directory where to find configuration files required for proper operation. Defaults to z3950 under
72 the Koha config directory.
78 The item status strings added by B<--add-item-status> can be configured with the B<Z3950_STATUS>
79 authorized value, using the following keys:
103 my $add_item_status_subfield;
104 my $add_status_multi_subfield;
114 my ( $opt_name, $opt_value ) = @_;
116 push @yaz_options, "-$opt_name", "$opt_value";
119 sub pass_yaz_option {
120 my ( $opt_name ) = @_;
122 push @yaz_options, "-$opt_name";
128 '--debug' => \$debug,
129 '--add-item-status=s' => \$add_item_status_subfield,
130 '--add-status-multi-subfield' => \$add_status_multi_subfield,
131 '--prefetch=i' => \$prefetch,
132 '--config-dir=s' => \$config_dir,
133 # Pass through YAZ options.
134 'a=s' => \&add_yaz_option,
135 'v=s' => \&add_yaz_option,
136 'l=s' => \&add_yaz_option,
137 'u=s' => \&add_yaz_option,
138 'c=s' => \&add_yaz_option,
139 't=s' => \&add_yaz_option,
140 'k=s' => \&add_yaz_option,
141 'd=s' => \&add_yaz_option,
142 'p=s' => \&add_yaz_option,
143 'C=s' => \&add_yaz_option,
144 'm=s' => \&add_yaz_option,
145 'w=s' => \&add_yaz_option,
146 'z' => \&pass_yaz_option,
147 'K' => \&pass_yaz_option,
148 'i' => \&pass_yaz_option,
149 'D' => \&pass_yaz_option,
150 'S' => \&pass_yaz_option,
151 'T' => \&pass_yaz_option,
152 '1' => \&pass_yaz_option
155 pod2usage(1) if $help;
156 pod2usage( -verbose => 2 ) if $man;
158 # If config_dir is not defined, default to z3950 under the Koha config directory
160 (undef, $config_dir) = fileparse(Koha::Config->guess_koha_conf);
161 $config_dir .= 'z3950/';
163 $config_dir .= '/' if ($config_dir !~ /\/$/);
166 # Create and start the server.
168 my $z = Koha::Z3950Responder->new( {
169 add_item_status_subfield => $add_item_status_subfield,
170 add_status_multi_subfield => $add_status_multi_subfield,
172 num_to_prefetch => $prefetch,
173 config_dir => $config_dir,
174 yaz_options => [ @yaz_options, @ARGV ],