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, 9 months ago) by harris41
Branches: MAIN
CVS tags: version_0_6_2, version_0_6, HEAD
fixing documentation and general beautification

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

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