File:  [LON-CAPA] / loncom / configuration / Configuration.pm
Revision 1.7: download - view: text, annotated - select for diffs
Mon Sep 9 13:57:37 2002 UTC (21 years, 7 months ago) by harris41
Branches: MAIN
CVS tags: version_0_6_2, version_0_6, HEAD
fixing documentation and general beautification

# The LearningOnline Network with CAPA
# Configuration file reader
#
# $Id: Configuration.pm,v 1.7 2002/09/09 13:57:37 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
#
###

# POD documentation is at the end of this short module.

package LONCAPA::Configuration;

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

use strict;

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

# ------------------- Subroutine read_conf: read LON-CAPA server configuration.
# This subroutine reads PerlSetVar values out of specified web server
# configuration files.
sub read_conf
  {
    my (@conf_files)=@_;
    my %perlvar;
    foreach my $filename (@conf_files,'loncapa_apache.conf')
      {
	open(CONFIG,'<'.$confdir.$filename) or
	    die("Can't read $confdir$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('loncapa.conf');

=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 B<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>