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

1.1       harris41    1: # The LearningOnline Network with CAPA
                      2: # Configuration file reader
                      3: #
1.7     ! harris41    4: # $Id: Configuration.pm,v 1.6 2002/05/17 14:03:04 matthew 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: 
1.7     ! harris41   34: # POD documentation is at the end of this short module.
        !            35: 
1.1       harris41   36: package LONCAPA::Configuration;
                     37: 
1.7     ! harris41   38: $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/);
1.1       harris41   39: 
                     40: use strict;
                     41: 
                     42: my $confdir='/etc/httpd/conf/';
                     43: 
1.7     ! harris41   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:   {
1.1       harris41   49:     my (@conf_files)=@_;
                     50:     my %perlvar;
1.7     ! harris41   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: 	      {
1.1       harris41   59: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                     60: 		chomp($varvalue);
                     61: 		$perlvar{$varname}=$varvalue;
1.7     ! harris41   62: 	      }
        !            63: 	  }
1.1       harris41   64: 	close(CONFIG);
1.7     ! harris41   65:       }
1.1       harris41   66:     my $perlvarref=\%perlvar;
                     67:     return ($perlvarref);
1.7     ! harris41   68:   }
1.1       harris41   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: 
1.7     ! harris41   83:  LONCAPA::Configuration::read_conf('loncapa.conf');
1.1       harris41   84: 
                     85: =head1 DESCRIPTION
                     86: 
1.4       harris41   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).
1.1       harris41   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
1.4       harris41  110: given toward the B<last> file name processed.
1.1       harris41  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>