Changeset 2659 in MondoRescue for devel/mr/lib/MondoRescue/Base.pm


Ignore:
Timestamp:
Jun 23, 2010, 4:26:59 PM (14 years ago)
Author:
Bruno Cornec
Message:

r3911@wsip-70-165-196-181: bruno | 2010-06-22 03:34:20 +0200

  • First packaged version of a mrmin version begining to work (but doing nothing interesting yet ;-)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/mr/lib/MondoRescue/Base.pm

    r2650 r2659  
    2525use Exporter;
    2626
     27# Global hash for configuration params of mr
     28my %mr;
     29our $mr = \%mr;
     30
    2731# Export, by default, all the functions into the namespace of
    2832# any code which uses this module.
    2933
    3034our @ISA = qw(Exporter);
    31 our @EXPORT = qw(mr_init mr_exit);
     35our @EXPORT = qw(mr_init mr_exit mr_conf_get $mr);
    3236
    3337=pod
     
    7175#
    7276# Conf files Management
    73 # the $MRMINI_CONF/mondorescue.conf.dist is delivered as part of the project and
     77# the $etcdir/mondorescue.conf.dist is delivered as part of the project and
    7478# its checksum is verified as we need good default values that we can trust
    7579#
     
    106110exit($code);
    107111}
     112
     113=item B<mr_conf_get>
     114
     115This function get parameters in configuration files and returns from the least significant level (default) to the emost significant level (application name), passing by the project name.
     116It takes a list of parameters to find and returns the values corresponding
     117
     118=cut
     119
     120
     121sub mr_conf_get {
     122    my @params = @_;
     123    my @ptr = ();
     124    my $ptr;
     125   
     126    pb_log(2,"Entering mr_conf_get\n");
     127    my @args1 = pb_conf_get_if(@params);
     128    my $proj = $ENV{'PBPROJ'};
     129    $ENV{'PBPROJ'} = $ENV{'PBPKG'};
     130    my @args2 = pb_conf_get_if(@params);
     131    foreach my $i (0..$#args1) {
     132        $ptr = undef;
     133        # Process from least important to more important
     134        $ptr = $args1[$i]->{'default'};
     135        $ptr[$i] = $ptr if (defined $ptr);
     136        $ptr = $args1[$i]->{$ENV{'PBPROJ'}};
     137        $ptr[$i] = $ptr if (defined $ptr);
     138        $ptr = $args2[$i]->{$ENV{'PBPKG'}};
     139        $ptr[$i] = $ptr if (defined $ptr);
     140        $ptr[$i] = "Undefined" if (not defined $ptr[$i]);
     141        pb_log(2,"Found parameter $params[$i] with value $ptr[$i]\n");
     142    }
     143    $ENV{'PBPROJ'} = $proj;
     144    return(@ptr);
     145}
Note: See TracChangeset for help on using the changeset viewer.