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

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

make it take a array as param

  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
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
43#globaloptions contains any options that should be passed to all plugouts
44my ($verbosity, $outhandle, $failhandle, $globaloptions);
45
46sub 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 = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "custom", $ENV{'GSDLCOLLECTION'},
56 'perllib', 'plugouts', "${plugoutname}.pm");
57 my $colplugname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, 'perllib', 'plugouts',
58 "${plugoutname}.pm");
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; }
63 elsif (-e $mainplugname) { require $mainplugname; }
64 else {
65 gsprintf($outhandle, "{plugout.could_not_find_plugout}\n",
66 $plugoutname);
67 die "\n";
68 }
69
70 # create a plugout object
71 my ($plugobj);
72
73 eval ("\$plugobj = new \$plugoutname([],\$plugout)");
74 die "$@" if $@;
75
76 return $plugobj;
77}
78
791;
Note: See TracBrowser for help on using the repository browser.