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

1.1       harris41    1: # The LearningOnline Network with CAPA
                      2: # Configuration file reader
                      3: #
1.5     ! harris41    4: # $Id: Configuration.pm,v 1.4 2002/05/16 00:00:16 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.5     ! harris41   36: $VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\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: 
                     74:  LONCAPA::Configuration::read_conf('access.conf','loncapa.conf');
                     75: 
                     76: In the future, standard invocation of the command will be:
                     77: 
                     78:  LONCAPA::Configuration::read_conf('loncapa.conf');
                     79: 
                     80: F<access.conf> is slowly becoming deprecated.  (We are currently
                     81: trying to support backwards compatibility.)
                     82: 
                     83: =head1 DESCRIPTION
                     84: 
1.4       harris41   85: Many different parts of the LON-CAPA software need to read in the
                     86: machine-specific configuration information.  These included scripts
                     87: controlling the TCP/IP layer (e.g. F<lonc> and F<lond>), testing scripts
                     88: (e.g. test_weblayer.pl and sqltest.pl), and utility scripts
                     89: (e.g. clusterstatus.pl and metadata_keywords.pl).
1.1       harris41   90: 
                     91: The following methods are available:
                     92: 
                     93: =over 4
                     94: 
                     95: =item $perlvarref = LONCAPA::Configuration::read_conf( @filename_list );
                     96: 
                     97: On a typical LON-CAPA server, the filename list argument will consist of
                     98: just one element, "loncapa.conf".
                     99: 
                    100: If there are multiple elements within the filename list, then these
                    101: filenames are processed consecutively.
                    102: 
                    103: A hash reference is returned and consists of those values which
                    104: have been initialized from the configuration filenames indicated
                    105: in the arguments.
                    106: 
                    107: If multiple file names define the same hash key, then priority is
1.4       harris41  108: given toward the B<last> file name processed.
1.1       harris41  109: 
                    110: =back
                    111: 
                    112: =head1 AUTHORS
                    113: 
                    114: Scott Harrison
                    115: 
                    116: This library is free software; you can redistribute it and/or
                    117: modify it under the same terms as LON-CAPA itself.
                    118: 
                    119: =cut

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