source: gsdl/trunk/perllib/plugout.pm@ 14557

Last change on this file since 14557 was 14557, checked in by shaoqun, 17 years ago

make it take a array as param

  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
RevLine 
[12329]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
26package plugout;
27
28use strict; # to pick up typos and undeclared variables...
29no strict 'refs'; # ...but allow filehandles to be variables and vice versa
30no strict 'subs';
31
32require util;
33use gsprintf 'gsprintf';
34
35# global variables
36my $stats = {'num_processed' => 0,
37 'num_blocked' => 0,
38 'num_not_processed' => 0,
39 'num_not_recognised' => 0,
40 'num_archives' => 0
41 };
42
[14557]43#globaloptions contains any options that should be passed to all plugouts
[12329]44my ($verbosity, $outhandle, $failhandle, $globaloptions);
45
46sub load_plugout{
[14557]47 my ($plugout) = shift @_;
[12329]48
[13933]49 my $colplugdir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugouts");
[14557]50 unshift (@INC, $colplugdir);
51
52 my $plugoutname = shift @$plugout;
53
[12329]54 # find the plugout
[14557]55 my $customplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
56 'perllib', 'plugouts', "${plugoutname}.pm");
57 my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'perllib', 'plugouts',
[12329]58 "${plugoutname}.pm");
[14557]59 my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'}, 'perllib', 'plugouts',
60 "${plugoutname}.pm");
61 if (-e $customplugname) { require $customplugname; }
62 elsif (-e $colplugname) { require $colplugname; }
[12329]63 elsif (-e $mainplugname) { require $mainplugname; }
64 else {
[14557]65 gsprintf($outhandle, "{plugout.could_not_find_plugout}\n",
[12329]66 $plugoutname);
[14557]67 die "\n";
[12329]68 }
69
70 # create a plugout object
71 my ($plugobj);
72
[14557]73 eval ("\$plugobj = new \$plugoutname([],\$plugout)");
[12329]74 die "$@" if $@;
75
76 return $plugobj;
77}
78
791;
Note: See TracBrowser for help on using the repository browser.