1 | ###########################################################################
|
---|
2 | #
|
---|
3 | # plugout.pm -- functions to handle using plugouts
|
---|
4 | # A component of the Greenstone digital library software
|
---|
5 | # from the New Zealand Digital Library Project at the
|
---|
6 | # University of Waikato, New Zealand.
|
---|
7 | #
|
---|
8 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
9 | #
|
---|
10 | # This program is free software; you can redistribute it and/or modify
|
---|
11 | # it under the terms of the GNU General Public License as published by
|
---|
12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
13 | # (at your option) any later version.
|
---|
14 | #
|
---|
15 | # This program is distributed in the hope that it will be useful,
|
---|
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | # GNU General Public License for more details.
|
---|
19 | #
|
---|
20 | # You should have received a copy of the GNU General Public License
|
---|
21 | # along with this program; if not, write to the Free Software
|
---|
22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | #
|
---|
24 | ###########################################################################
|
---|
25 |
|
---|
26 | package plugout;
|
---|
27 |
|
---|
28 | use strict; # to pick up typos and undeclared variables...
|
---|
29 | no strict 'refs'; # ...but allow filehandles to be variables and vice versa
|
---|
30 | no strict 'subs';
|
---|
31 |
|
---|
32 | require util;
|
---|
33 | use gsprintf 'gsprintf';
|
---|
34 |
|
---|
35 | # global variables
|
---|
36 | my $stats = {'num_processed' => 0,
|
---|
37 | 'num_blocked' => 0,
|
---|
38 | 'num_not_processed' => 0,
|
---|
39 | 'num_not_recognised' => 0,
|
---|
40 | 'num_archives' => 0
|
---|
41 | };
|
---|
42 |
|
---|
43 | #globaloptions contains any options that should be passed to all plugouts
|
---|
44 | my ($verbosity, $outhandle, $failhandle, $globaloptions);
|
---|
45 |
|
---|
46 | sub load_plugout{
|
---|
47 | my ($plugout) = shift @_;
|
---|
48 |
|
---|
49 | my $colplugdir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugouts");
|
---|
50 | unshift (@INC, $colplugdir);
|
---|
51 |
|
---|
52 | my $plugoutname = shift @$plugout;
|
---|
53 |
|
---|
54 | # find the plugout
|
---|
55 | my $customplugname;
|
---|
56 | if (defined($ENV{'GSDLCOLLECTION'}))
|
---|
57 | {
|
---|
58 | $customplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
|
---|
59 | 'perllib', 'plugouts', "${plugoutname}.pm");
|
---|
60 | }
|
---|
61 |
|
---|
62 | my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'perllib', 'plugouts',
|
---|
63 | "${plugoutname}.pm");
|
---|
64 | my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'}, 'perllib', 'plugouts',
|
---|
65 | "${plugoutname}.pm");
|
---|
66 | if (defined($customplugname) && -e $customplugname) { require $customplugname; }
|
---|
67 | elsif (-e $colplugname) { require $colplugname; }
|
---|
68 | elsif (-e $mainplugname) { require $mainplugname; }
|
---|
69 | else {
|
---|
70 | gsprintf($outhandle, "{plugout.could_not_find_plugout}\n",
|
---|
71 | $plugoutname);
|
---|
72 | die "\n";
|
---|
73 | }
|
---|
74 |
|
---|
75 | # create a plugout object
|
---|
76 | my ($plugobj);
|
---|
77 |
|
---|
78 | eval ("\$plugobj = new \$plugoutname([],\$plugout)");
|
---|
79 | die "$@" if $@;
|
---|
80 |
|
---|
81 | return $plugobj;
|
---|
82 | }
|
---|
83 |
|
---|
84 | 1;
|
---|