Annotation of loncom/configuration/Configuration.pm, revision 1.6

1.1       harris41    1: # The LearningOnline Network with CAPA
                      2: # Configuration file reader
                      3: #
1.6     ! matthew     4: # $Id: Configuration.pm,v 1.5 2002/05/16 17:24:06 harris41 Exp $
1.1       harris41    5: #
                      6: #
                      7: # Copyright Michigan State University Board of Trustees
                      8: #
                      9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                     10: #
                     11: # LON-CAPA is free software; you can redistribute it and/or modify
                     12: # it under the terms of the GNU General Public License as published by
                     13: # the Free Software Foundation; either version 2 of the License, or
                     14: # (at your option) any later version.
                     15: #
                     16: # LON-CAPA is distributed in the hope that it will be useful,
                     17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     19: # GNU General Public License for more details.
                     20: #
                     21: # You should have received a copy of the GNU General Public License
                     22: # along with LON-CAPA; if not, write to the Free Software
                     23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     24: #
                     25: # /home/httpd/html/adm/gpl.txt
                     26: #
                     27: # http://www.lon-capa.org/
                     28: #
                     29: # YEAR=2002
                     30: # 05/03 Scott Harrison
                     31: #
                     32: ###
                     33: 
                     34: package LONCAPA::Configuration;
                     35: 
1.6     ! matthew    36: $VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
1.1       harris41   37: 
                     38: use strict;
                     39: 
                     40: my $confdir='/etc/httpd/conf/';
                     41: 
                     42: # ------------------------------------ read_conf: read LON-CAPA server configuration, especially PerlSetVar values
                     43: sub read_conf {
                     44:     my (@conf_files)=@_;
                     45:     my %perlvar;
1.5       harris41   46:     foreach my $filename (@conf_files,'loncapa_apache.conf') {
1.3       harris41   47: 	open(CONFIG,'<'.$confdir.$filename) or die("Can't read $confdir$filename");
1.1       harris41   48: 	while (my $configline=<CONFIG>) {
                     49: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                     50: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                     51: 		chomp($varvalue);
                     52: 		$perlvar{$varname}=$varvalue;
                     53: 	    }
                     54: 	}
                     55: 	close(CONFIG);
                     56:     }
                     57:     my $perlvarref=\%perlvar;
                     58:     return ($perlvarref);
                     59: }
                     60: 
                     61: __END__
                     62: 
                     63: =pod
                     64: 
                     65: =head1 NAME
                     66: 
                     67: B<LONCAPA::Configuration> - configuration file reader
                     68: 
                     69: =head1 SYNOPSIS
                     70: 
                     71:  use lib '/home/httpd/lib/perl/';
                     72:  use LONCAPA::Configuration;
                     73: 
1.6     ! matthew    74:  LONCAPA::Configuration::read_conf('loncapa_apache.conf','loncapa.conf');
1.1       harris41   75: 
                     76: =head1 DESCRIPTION
                     77: 
1.4       harris41   78: Many different parts of the LON-CAPA software need to read in the
                     79: machine-specific configuration information.  These included scripts
                     80: controlling the TCP/IP layer (e.g. F<lonc> and F<lond>), testing scripts
                     81: (e.g. test_weblayer.pl and sqltest.pl), and utility scripts
                     82: (e.g. clusterstatus.pl and metadata_keywords.pl).
1.1       harris41   83: 
                     84: The following methods are available:
                     85: 
                     86: =over 4
                     87: 
                     88: =item $perlvarref = LONCAPA::Configuration::read_conf( @filename_list );
                     89: 
                     90: On a typical LON-CAPA server, the filename list argument will consist of
                     91: just one element, "loncapa.conf".
                     92: 
                     93: If there are multiple elements within the filename list, then these
                     94: filenames are processed consecutively.
                     95: 
                     96: A hash reference is returned and consists of those values which
                     97: have been initialized from the configuration filenames indicated
                     98: in the arguments.
                     99: 
                    100: If multiple file names define the same hash key, then priority is
1.4       harris41  101: given toward the B<last> file name processed.
1.1       harris41  102: 
                    103: =back
                    104: 
                    105: =head1 AUTHORS
                    106: 
                    107: Scott Harrison
                    108: 
                    109: This library is free software; you can redistribute it and/or
                    110: modify it under the same terms as LON-CAPA itself.
                    111: 
                    112: =cut

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