File:  [LON-CAPA] / loncom / configuration / Configuration.pm
Revision 1.2: download - view: text, annotated - select for diffs
Sat May 4 00:03:29 2002 UTC (22 years ago) by harris41
Branches: MAIN
CVS tags: HEAD
refining the error message with the specific filename
being processed

# The LearningOnline Network with CAPA
# Configuration file reader
#
# $Id: Configuration.pm,v 1.2 2002/05/04 00:03:29 harris41 Exp $
#
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
# YEAR=2002
# 05/03 Scott Harrison
#
###

package LONCAPA::Configuration;

$VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);

use strict;

my $confdir='/etc/httpd/conf/';

# ------------------------------------ read_conf: read LON-CAPA server configuration, especially PerlSetVar values
sub read_conf {
    my (@conf_files)=@_;
    my %perlvar;
    foreach my $filename (@conf_files) {
	open(CONFIG,'<'.$confdir.$filename) or die("Can't read $filename");
	while (my $configline=<CONFIG>) {
	    if ($configline =~ /^[^\#]*PerlSetVar/) {
		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
		chomp($varvalue);
		$perlvar{$varname}=$varvalue;
	    }
	}
	close(CONFIG);
    }
    my $perlvarref=\%perlvar;
    return ($perlvarref);
}

__END__

=pod

=head1 NAME

B<LONCAPA::Configuration> - configuration file reader

=head1 SYNOPSIS

 use lib '/home/httpd/lib/perl/';
 use LONCAPA::Configuration;

 LONCAPA::Configuration::read_conf('access.conf','loncapa.conf');

In the future, standard invocation of the command will be:

 LONCAPA::Configuration::read_conf('loncapa.conf');

F<access.conf> is slowly becoming deprecated.  (We are currently
trying to support backwards compatibility.)

=head1 DESCRIPTION

Many different parts of the LON-CAPA software need to read in the machine-specific
configuration information.  These included scripts controlling the TCP/IP layer
(e.g. F<lonc> and F<lond>), testing scripts (e.g. test_weblayer.pl and sqltest.pl),
and utility scripts (e.g. clusterstatus.pl and metadata_keywords.pl).

The following methods are available:

=over 4

=item $perlvarref = LONCAPA::Configuration::read_conf( @filename_list );

On a typical LON-CAPA server, the filename list argument will consist of
just one element, "loncapa.conf".

If there are multiple elements within the filename list, then these
filenames are processed consecutively.

A hash reference is returned and consists of those values which
have been initialized from the configuration filenames indicated
in the arguments.

If multiple file names define the same hash key, then priority is
given toward the last file name processed.

=back

=head1 AUTHORS

Scott Harrison

This library is free software; you can redistribute it and/or
modify it under the same terms as LON-CAPA itself.

=cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>