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

1.1     ! harris41    1: # The LearningOnline Network with CAPA
        !             2: # Configuration file reader
        !             3: #
        !             4: # $Id$
        !             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: 
        !            36: $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
        !            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;
        !            46:     foreach my $filename (@conf_files) {
        !            47: 	open(CONFIG,'<'.$confdir.$filename) or die("Can't read access.conf");
        !            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: 
        !            85: Many different parts of the LON-CAPA software need to read in the machine-specific
        !            86: configuration information.  These included scripts controlling the TCP/IP layer
        !            87: (e.g. F<lonc> and F<lond>), testing scripts (e.g. test_weblayer.pl and sqltest.pl),
        !            88: and utility scripts (e.g. clusterstatus.pl and metadata_keywords.pl).
        !            89: 
        !            90: The following methods are available:
        !            91: 
        !            92: =over 4
        !            93: 
        !            94: =item $perlvarref = LONCAPA::Configuration::read_conf( @filename_list );
        !            95: 
        !            96: On a typical LON-CAPA server, the filename list argument will consist of
        !            97: just one element, "loncapa.conf".
        !            98: 
        !            99: If there are multiple elements within the filename list, then these
        !           100: filenames are processed consecutively.
        !           101: 
        !           102: A hash reference is returned and consists of those values which
        !           103: have been initialized from the configuration filenames indicated
        !           104: in the arguments.
        !           105: 
        !           106: If multiple file names define the same hash key, then priority is
        !           107: given toward the last file name processed.
        !           108: 
        !           109: =back
        !           110: 
        !           111: =head1 AUTHORS
        !           112: 
        !           113: Scott Harrison
        !           114: 
        !           115: This library is free software; you can redistribute it and/or
        !           116: modify it under the same terms as LON-CAPA itself.
        !           117: 
        !           118: =cut

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