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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 use Getopt::Long qw(:config no_ignore_case);
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]
43 Prints a brief usage message and exits.
47 Displays manual page and exits.
51 Turns on debug logging to the screen, and turns on single-process mode.
53 =item B<--add-item-status=SUBFIELD>
55 If given, adds item status information to the given subfield.
57 =item B<--add-status-multi-subfield>
59 With the above, instead of putting multiple item statuses in one subfield, adds a subfield for each
62 =item B<--prefetch=NUM_RECORDS>
64 Number of records to prefetch from Zebra. Defaults to 20.
70 The item status strings added by B<--add-item-status> can be configured with the B<Z3950_STATUS>
71 authorized value, using the following keys:
95 my $add_item_status_subfield;
96 my $add_status_multi_subfield;
104 my ( $opt_name, $opt_value ) = @_;
105 warn "name: $opt_name and value: $opt_value";
107 push @yaz_options, "-$opt_name", "$opt_value";
110 sub pass_yaz_option {
111 my ( $opt_name ) = @_;
113 push @yaz_options, "-$opt_name";
119 '--debug' => \$debug,
120 '--add-item-status=s' => \$add_item_status_subfield,
121 '--add-status-multi-subfield' => \$add_status_multi_subfield,
122 '--prefetch=i' => \$prefetch,
123 # Pass through YAZ options.
124 'a=s' => \&add_yaz_option,
125 'v=s' => \&add_yaz_option,
126 'l=s' => \&add_yaz_option,
127 'u=s' => \&add_yaz_option,
128 'c=s' => \&add_yaz_option,
129 't=s' => \&add_yaz_option,
130 'k=s' => \&add_yaz_option,
131 'd=s' => \&add_yaz_option,
132 'p=s' => \&add_yaz_option,
133 'C=s' => \&add_yaz_option,
134 'm=s' => \&add_yaz_option,
135 'w=s' => \&add_yaz_option,
136 'z' => \&pass_yaz_option,
137 'K' => \&pass_yaz_option,
138 'i' => \&pass_yaz_option,
139 'D' => \&pass_yaz_option,
140 'S' => \&pass_yaz_option,
141 'T' => \&pass_yaz_option,
142 '1' => \&pass_yaz_option
145 pod2usage(1) if $help;
146 pod2usage( -verbose => 2 ) if $man;
148 # Create and start the server.
150 die "This tool only works with Zebra" if C4::Context->preference('SearchEngine') ne 'Zebra';
152 my $z = Koha::Z3950Responder->new( {
153 add_item_status_subfield => $add_item_status_subfield,
154 add_status_multi_subfield => $add_status_multi_subfield,
156 num_to_prefetch => $prefetch,
157 yaz_options => [ @yaz_options, @ARGV ],