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

1.1       harris41    1: # The LearningOnline Network with CAPA
                      2: # Configuration file reader
                      3: #
1.8     ! harris41    4: # $Id: Configuration.pm,v 1.7 2002/09/09 13:57:37 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: #
                     31: ###
                     32: 
1.7       harris41   33: # POD documentation is at the end of this short module.
                     34: 
1.1       harris41   35: package LONCAPA::Configuration;
                     36: 
1.8     ! harris41   37: $VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/);
1.1       harris41   38: 
                     39: use strict;
                     40: 
                     41: my $confdir='/etc/httpd/conf/';
                     42: 
1.7       harris41   43: # ------------------- Subroutine read_conf: read LON-CAPA server configuration.
                     44: # This subroutine reads PerlSetVar values out of specified web server
                     45: # configuration files.
                     46: sub read_conf
                     47:   {
1.1       harris41   48:     my (@conf_files)=@_;
                     49:     my %perlvar;
1.7       harris41   50:     foreach my $filename (@conf_files,'loncapa_apache.conf')
                     51:       {
                     52: 	open(CONFIG,'<'.$confdir.$filename) or
                     53: 	    die("Can't read $confdir$filename");
                     54: 	while (my $configline=<CONFIG>)
                     55: 	  {
                     56: 	    if ($configline =~ /^[^\#]*PerlSetVar/)
                     57: 	      {
1.1       harris41   58: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                     59: 		chomp($varvalue);
                     60: 		$perlvar{$varname}=$varvalue;
1.7       harris41   61: 	      }
                     62: 	  }
1.1       harris41   63: 	close(CONFIG);
1.7       harris41   64:       }
1.1       harris41   65:     my $perlvarref=\%perlvar;
                     66:     return ($perlvarref);
1.7       harris41   67:   }
1.1       harris41   68: 
                     69: __END__
                     70: 
                     71: =pod
                     72: 
                     73: =head1 NAME
                     74: 
                     75: B<LONCAPA::Configuration> - configuration file reader
                     76: 
                     77: =head1 SYNOPSIS
                     78: 
                     79:  use lib '/home/httpd/lib/perl/';
                     80:  use LONCAPA::Configuration;
                     81: 
1.7       harris41   82:  LONCAPA::Configuration::read_conf('loncapa.conf');
1.1       harris41   83: 
                     84: =head1 DESCRIPTION
                     85: 
1.4       harris41   86: Many different parts of the LON-CAPA software need to read in the
                     87: machine-specific configuration information.  These included scripts
                     88: controlling the TCP/IP layer (e.g. F<lonc> and F<lond>), testing scripts
                     89: (e.g. test_weblayer.pl and sqltest.pl), and utility scripts
                     90: (e.g. clusterstatus.pl and metadata_keywords.pl).
1.1       harris41   91: 
                     92: The following methods are available:
                     93: 
                     94: =over 4
                     95: 
                     96: =item $perlvarref = LONCAPA::Configuration::read_conf( @filename_list );
                     97: 
                     98: On a typical LON-CAPA server, the filename list argument will consist of
                     99: just one element, "loncapa.conf".
                    100: 
                    101: If there are multiple elements within the filename list, then these
                    102: filenames are processed consecutively.
                    103: 
                    104: A hash reference is returned and consists of those values which
                    105: have been initialized from the configuration filenames indicated
                    106: in the arguments.
                    107: 
                    108: If multiple file names define the same hash key, then priority is
1.4       harris41  109: given toward the B<last> file name processed.
1.1       harris41  110: 
                    111: =back
                    112: 
                    113: =head1 AUTHORS
                    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>