[405] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # ProjectBuilder Conf module
|
---|
| 4 | # Conf files subroutines brought by the the Project-Builder project
|
---|
| 5 | # which can be easily used by wahtever perl project
|
---|
| 6 | #
|
---|
[2032] | 7 | # Copyright B. Cornec 2007-2016
|
---|
[1528] | 8 | # Eric Anderson's changes are (c) Copyright 2012 Hewlett Packard
|
---|
| 9 | # Provided under the GPL v2
|
---|
| 10 | #
|
---|
[405] | 11 | # $Id$
|
---|
| 12 | #
|
---|
| 13 |
|
---|
| 14 | package ProjectBuilder::Conf;
|
---|
| 15 |
|
---|
| 16 | use strict;
|
---|
[1507] | 17 | use Carp 'confess';
|
---|
[405] | 18 | use Data::Dumper;
|
---|
| 19 | use ProjectBuilder::Base;
|
---|
[1148] | 20 | use ProjectBuilder::Version;
|
---|
[405] | 21 |
|
---|
| 22 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 23 |
|
---|
[2239] | 24 | use vars qw($VERSION $REVISION $PBCONFVER @ISA @EXPORT);
|
---|
[405] | 25 | use Exporter;
|
---|
| 26 |
|
---|
| 27 | # Export, by default, all the functions into the namespace of
|
---|
| 28 | # any code which uses this module.
|
---|
| 29 |
|
---|
| 30 | our @ISA = qw(Exporter);
|
---|
[2154] | 31 | our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_get_all pb_conf_get_hash pb_conf_cache);
|
---|
[2239] | 32 | ($VERSION,$REVISION,$PBCONFVER) = pb_version_init();
|
---|
[405] | 33 |
|
---|
[898] | 34 | # Global hash of conf files
|
---|
| 35 | # Key is the conf file name
|
---|
| 36 | # Value is its rank
|
---|
| 37 | my %pbconffiles;
|
---|
[409] | 38 |
|
---|
[1495] | 39 | # Global hash of conf file content
|
---|
| 40 | # Key is the config keyword
|
---|
| 41 | # Value is a hash whose key depends on the nature of the config keyword as documented
|
---|
| 42 | # and value is the confguration value
|
---|
[898] | 43 | # We consider that values can not change during the life of pb
|
---|
[1495] | 44 | my $h = ();
|
---|
[898] | 45 |
|
---|
[405] | 46 | =pod
|
---|
| 47 |
|
---|
| 48 | =head1 NAME
|
---|
| 49 |
|
---|
| 50 | ProjectBuilder::Conf, part of the project-builder.org - module dealing with configuration files
|
---|
| 51 |
|
---|
| 52 | =head1 DESCRIPTION
|
---|
| 53 |
|
---|
| 54 | This modules provides functions dealing with configuration files.
|
---|
| 55 |
|
---|
| 56 | =head1 SYNOPSIS
|
---|
| 57 |
|
---|
| 58 | use ProjectBuilder::Conf;
|
---|
| 59 |
|
---|
| 60 | #
|
---|
| 61 | # Read hash codes of values from a configuration file and return table of pointers
|
---|
| 62 | #
|
---|
| 63 | my ($k1, $k2) = pb_conf_read_if("$ENV{'HOME'}/.pbrc","key1","key2");
|
---|
| 64 | my ($k) = pb_conf_read("$ENV{'HOME'}/.pbrc","key");
|
---|
| 65 |
|
---|
| 66 | =head1 USAGE
|
---|
| 67 |
|
---|
[2152] | 68 | The configuration files are loaded in a specific order from most generic to the most specific
|
---|
| 69 | to allow for overwrite to work:
|
---|
| 70 |
|
---|
[2239] | 71 | 1. /usr/share/pb/pb.yml - the read-only system conf file provided by install
|
---|
| 72 | 2. /etc/pb/pb.yml - the same global conf file given to the sysadmin in order to make system wide modifications
|
---|
[2152] | 73 | 3. /path/to/project.pb - Configuration file for the project we're building for
|
---|
| 74 | 4. /(vm|ve|rm)path/to/.pbrc - configuration file for VM, VE or RM specific parameters. Cumulative should be orthogonal
|
---|
| 75 | 5. $HOME/.pbrc - user's configuration file
|
---|
| 76 |
|
---|
[405] | 77 | =over 4
|
---|
| 78 |
|
---|
[505] | 79 | =item B<pb_conf_init>
|
---|
| 80 |
|
---|
[898] | 81 | This function setup the environment PBPROJ for project-builder function usage from other projects.
|
---|
[505] | 82 | The first parameter is the project name.
|
---|
[898] | 83 | It sets up environment variables (PBPROJ)
|
---|
[505] | 84 |
|
---|
| 85 | =cut
|
---|
| 86 |
|
---|
| 87 | sub pb_conf_init {
|
---|
| 88 |
|
---|
[1907] | 89 | my $proj=shift;
|
---|
[505] | 90 |
|
---|
[1495] | 91 | pb_log(1,"Entering pb_conf_init\n");
|
---|
[1584] | 92 | #
|
---|
| 93 | # Check project name
|
---|
| 94 | # Could be with env var PBPROJ
|
---|
| 95 | # or option -p
|
---|
| 96 | # if not defined take the first in conf file
|
---|
| 97 | #
|
---|
| 98 | if ((defined $ENV{'PBPROJ'}) &&
|
---|
| 99 | (not defined $proj)) {
|
---|
| 100 | pb_log(2,"PBPROJ env var setup ($ENV{'PBPROJ'}) so using it\n");
|
---|
| 101 | $proj = $ENV{'PBPROJ'};
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[505] | 104 | if (defined $proj) {
|
---|
| 105 | $ENV{'PBPROJ'} = $proj;
|
---|
| 106 | } else {
|
---|
| 107 | $ENV{'PBPROJ'} = "default";
|
---|
| 108 | }
|
---|
[1495] | 109 | pb_log(1,"PBPROJ = $ENV{'PBPROJ'}\n");
|
---|
[505] | 110 | }
|
---|
| 111 |
|
---|
| 112 |
|
---|
[1495] | 113 | =item B<pb_conf_cache>
|
---|
[505] | 114 |
|
---|
[1495] | 115 | This function caches the configuration file content passed as first parameter into the a hash passed in second parameter
|
---|
| 116 | It returns the modified hash
|
---|
| 117 | Can be used in correlation with the %h hash to store permanently values or not if temporarily.
|
---|
| 118 |
|
---|
| 119 | =cut
|
---|
| 120 |
|
---|
| 121 | sub pb_conf_cache {
|
---|
| 122 |
|
---|
| 123 | my $cf = shift;
|
---|
| 124 | my $lh = shift;
|
---|
| 125 |
|
---|
[2239] | 126 | my $ldfunc;
|
---|
| 127 |
|
---|
| 128 | eval {
|
---|
| 129 | require YAML;
|
---|
| 130 | YAML->import();
|
---|
| 131 | $ldfunc = \&YAML::LoadFile;
|
---|
| 132 | };
|
---|
| 133 | if ($@) {
|
---|
| 134 | # No YAML found using a more std but less complete one. Old perl only
|
---|
| 135 | use Module::Build::YAML;
|
---|
| 136 | $ldfunc = \&Module::Build::YAML::LoadFile;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[2077] | 139 | # Read the content of the config file and cache it in the %h hash then available for queries
|
---|
[2239] | 140 | if ($PBCONFVER < 1) {
|
---|
[2176] | 141 | open(CONF,$cf) || confess "Unable to open $cf";
|
---|
| 142 | # This is the original conf file format for versions up to 0.14
|
---|
| 143 | while(<CONF>) {
|
---|
| 144 | next if (/^#/);
|
---|
| 145 | if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.\?\[\]\*\+\\]+)\s*=\s*(.*)$/) {
|
---|
| 146 | pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n");
|
---|
| 147 | $lh->{$1}->{$2}=$3;
|
---|
| 148 | }
|
---|
[1495] | 149 | }
|
---|
[2176] | 150 | close(CONF);
|
---|
| 151 | } else {
|
---|
[2239] | 152 | $lh = $ldfunc->($cf);
|
---|
[1495] | 153 | }
|
---|
| 154 | return($lh);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[409] | 157 | =item B<pb_conf_add>
|
---|
| 158 |
|
---|
[1495] | 159 | This function adds the configuration file to the list last, and cache their content in the %h hash
|
---|
[409] | 160 |
|
---|
| 161 | =cut
|
---|
| 162 |
|
---|
| 163 | sub pb_conf_add {
|
---|
| 164 |
|
---|
[415] | 165 | pb_log(2,"DEBUG: pb_conf_add with ".Dumper(@_)."\n");
|
---|
[1495] | 166 | my $lh;
|
---|
[898] | 167 |
|
---|
| 168 | foreach my $cf (@_) {
|
---|
[1495] | 169 | if (! -r $cf) {
|
---|
| 170 | pb_log(0,"WARNING: pb_conf_add can not read $cf\n");
|
---|
| 171 | next;
|
---|
| 172 | }
|
---|
[898] | 173 | # Skip already used conf files
|
---|
[1495] | 174 | return($lh) if (defined $pbconffiles{$cf});
|
---|
| 175 |
|
---|
[2154] | 176 | # The new conf file overload values already managed
|
---|
[898] | 177 | my $num = keys %pbconffiles;
|
---|
[1495] | 178 | pb_log(2,"DEBUG: pb_conf_cache of $cf at position $num\n");
|
---|
[898] | 179 | $pbconffiles{$cf} = $num;
|
---|
[1495] | 180 |
|
---|
| 181 | # Read the content of the config file
|
---|
| 182 | $lh = pb_conf_cache($cf,$lh);
|
---|
| 183 | # and cache it in the %h hash for further queries but after the previous
|
---|
| 184 | # as we load conf files in reverse order (most precise first)
|
---|
| 185 | pb_conf_add_last_in_hash($lh)
|
---|
[409] | 186 | }
|
---|
[898] | 187 | }
|
---|
[409] | 188 |
|
---|
[1495] | 189 |
|
---|
[405] | 190 | =item B<pb_conf_read_if>
|
---|
| 191 |
|
---|
| 192 | This function returns a table of pointers on hashes
|
---|
| 193 | corresponding to the keys in a configuration file passed in parameter.
|
---|
| 194 | If that file doesn't exist, it returns undef.
|
---|
| 195 |
|
---|
| 196 | The format of the configuration file is as follows:
|
---|
| 197 |
|
---|
| 198 | key tag = value1,value2,...
|
---|
| 199 |
|
---|
| 200 | Supposing the file is called "$ENV{'HOME'}/.pbrc", containing the following:
|
---|
| 201 |
|
---|
| 202 | $ cat $HOME/.pbrc
|
---|
| 203 | pbver pb = 3
|
---|
| 204 | pbver default = 1
|
---|
| 205 | pblist pb = 12,25
|
---|
| 206 |
|
---|
| 207 | calling it like this:
|
---|
| 208 |
|
---|
| 209 | my ($k1, $k2) = pb_conf_read_if("$ENV{'HOME'}/.pbrc","pbver","pblist");
|
---|
| 210 |
|
---|
| 211 | will allow to get the mapping:
|
---|
| 212 |
|
---|
| 213 | $k1->{'pb'} contains 3
|
---|
[409] | 214 | $k1->{'default'} contains 1
|
---|
[405] | 215 | $k2->{'pb'} contains 12,25
|
---|
| 216 |
|
---|
| 217 | Valid chars for keys and tags are letters, numbers, '-' and '_'.
|
---|
| 218 |
|
---|
[1495] | 219 | The file read is forgotten after its usage. If you want permanent caching of the data, use pb_conf_add then pb_conf_get
|
---|
| 220 |
|
---|
[405] | 221 | =cut
|
---|
| 222 |
|
---|
| 223 | sub pb_conf_read_if {
|
---|
| 224 |
|
---|
| 225 | my $conffile = shift;
|
---|
| 226 | my @param = @_;
|
---|
| 227 |
|
---|
| 228 | open(CONF,$conffile) || return((undef));
|
---|
| 229 | close(CONF);
|
---|
| 230 | return(pb_conf_read($conffile,@param));
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | =item B<pb_conf_read>
|
---|
| 234 |
|
---|
| 235 | This function is similar to B<pb_conf_read_if> except that it dies when the file in parameter doesn't exist.
|
---|
| 236 |
|
---|
| 237 | =cut
|
---|
| 238 |
|
---|
| 239 | sub pb_conf_read {
|
---|
| 240 |
|
---|
| 241 | my $conffile = shift;
|
---|
| 242 | my @param = @_;
|
---|
| 243 | my @ptr;
|
---|
[1495] | 244 | my $lh;
|
---|
[405] | 245 |
|
---|
[1495] | 246 | $lh = pb_conf_cache($conffile,$lh);
|
---|
| 247 |
|
---|
| 248 | foreach my $param (@param) {
|
---|
| 249 | push @ptr,$lh->{$param};
|
---|
[405] | 250 | }
|
---|
[1495] | 251 | return(@ptr);
|
---|
| 252 | }
|
---|
[405] | 253 |
|
---|
[1904] | 254 | =item B<pb_conf_write>
|
---|
[1495] | 255 |
|
---|
[1904] | 256 | This function writes in the file passed ias first parameter the hash of values passed as second parameter
|
---|
[1495] | 257 |
|
---|
[1904] | 258 | =cut
|
---|
| 259 |
|
---|
| 260 | sub pb_conf_write {
|
---|
| 261 |
|
---|
| 262 | my $conffile = shift;
|
---|
[1905] | 263 | my $h = shift;
|
---|
[2239] | 264 | my $dpfunc;
|
---|
[1904] | 265 |
|
---|
[2239] | 266 | eval {
|
---|
| 267 | require YAML;
|
---|
| 268 | YAML->import();
|
---|
| 269 | $dpfunc = \&YAML::Dump;
|
---|
| 270 | };
|
---|
| 271 | if ($@) {
|
---|
| 272 | # No YAML found using a more std but less complete one. Old perl only
|
---|
| 273 | use Module::Build::YAML;
|
---|
| 274 | $dpfunc = \&Module::Build::YAML::Dump;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
[1905] | 277 | confess "No configuration file defined to write into !" if (not defined $conffile);
|
---|
| 278 | confess "No hash defined to read from !" if (not defined $h);
|
---|
| 279 | open(CONF,"> $conffile") || confess "Unable to write into $conffile";
|
---|
[1904] | 280 |
|
---|
[2239] | 281 | if ($PBCONFVER < 1) {
|
---|
[2176] | 282 | # This is the original conf file format for versions up to 0.14
|
---|
| 283 | foreach my $p (sort keys %$h) {
|
---|
| 284 | my $j = $h->{$p};
|
---|
| 285 | foreach my $k (sort keys %$j) {
|
---|
| 286 | print CONF "$p $k = $j->{$k}\n";
|
---|
| 287 | }
|
---|
[1904] | 288 | }
|
---|
[2176] | 289 | } else {
|
---|
| 290 | # This is the new YAML format
|
---|
[2239] | 291 | print CONF $dpfunc->($h);
|
---|
[1904] | 292 | }
|
---|
| 293 | close(CONF);
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 |
|
---|
| 297 |
|
---|
[1495] | 298 | =item B<pb_conf_get_in_hash_if>
|
---|
| 299 |
|
---|
[1594] | 300 | This function returns a table, corresponding to a set of values queried in the hash passed in parameter or undef if it doesn't exist.
|
---|
| 301 | It takes a table of keys as an input parameter.
|
---|
[1495] | 302 |
|
---|
| 303 | =cut
|
---|
| 304 |
|
---|
| 305 | sub pb_conf_get_in_hash_if {
|
---|
| 306 |
|
---|
| 307 | my $lh = shift || return(());
|
---|
| 308 | my @params = @_;
|
---|
| 309 | my @ptr = ();
|
---|
| 310 |
|
---|
| 311 | pb_log(2,"DEBUG: pb_conf_get_in_hash_if on params ".join(' ',@params)."\n");
|
---|
| 312 | foreach my $k (@params) {
|
---|
| 313 | push @ptr,$lh->{$k};
|
---|
[405] | 314 | }
|
---|
[1495] | 315 |
|
---|
| 316 | pb_log(2,"DEBUG: pb_conf_get_in_hash_if returns\n".Dumper(@ptr));
|
---|
[405] | 317 | return(@ptr);
|
---|
| 318 | }
|
---|
| 319 |
|
---|
[1495] | 320 |
|
---|
| 321 |
|
---|
[409] | 322 | =item B<pb_conf_get_if>
|
---|
[405] | 323 |
|
---|
[1495] | 324 | This function returns a table, corresponding to a set of values queried in the %h hash or undef if it doen't exist. It takes a table of keys as an input parameter.
|
---|
[405] | 325 |
|
---|
[409] | 326 | The format of the configurations file is as follows:
|
---|
| 327 |
|
---|
| 328 | key tag = value1,value2,...
|
---|
| 329 |
|
---|
[1495] | 330 | It will gather the values from all the configurations files passed to pb_conf_add, and return the values for the keys
|
---|
[409] | 331 |
|
---|
| 332 | $ cat $HOME/.pbrc
|
---|
| 333 | pbver pb = 1
|
---|
| 334 | pblist pb = 4
|
---|
| 335 | $ cat $HOME/.pbrc2
|
---|
| 336 | pbver pb = 3
|
---|
| 337 | pblist default = 5
|
---|
| 338 |
|
---|
| 339 | calling it like this:
|
---|
| 340 |
|
---|
[505] | 341 | pb_conf_add("$HOME/.pbrc","$HOME/.pbrc2");
|
---|
[409] | 342 | my ($k1, $k2) = pb_conf_get_if("pbver","pblist");
|
---|
| 343 |
|
---|
| 344 | will allow to get the mapping:
|
---|
| 345 |
|
---|
| 346 | $k1->{'pb'} contains 3
|
---|
| 347 | $k2->{'pb'} contains 4
|
---|
| 348 |
|
---|
| 349 | Valid chars for keys and tags are letters, numbers, '-' and '_'.
|
---|
| 350 |
|
---|
| 351 | =cut
|
---|
| 352 |
|
---|
| 353 | sub pb_conf_get_if {
|
---|
| 354 |
|
---|
[2154] | 355 | my @param = @_;
|
---|
| 356 | my @return = pb_conf_get_in_hash_if($h,@_);
|
---|
| 357 | my $proj = undef;
|
---|
| 358 |
|
---|
| 359 | if (not defined $ENV{'PBPROJ'}) {
|
---|
| 360 | $proj = "unknown";
|
---|
| 361 | } else {
|
---|
| 362 | $proj = $ENV{'PBPROJ'};
|
---|
[405] | 363 | }
|
---|
[409] | 364 |
|
---|
[2154] | 365 | foreach my $i (0..$#param) {
|
---|
| 366 | if (not defined $return[$i]->{$proj}) {
|
---|
| 367 | $return[$i]->{$proj} = $return[$i]->{'default'} if (defined $return[$i]->{'default'});
|
---|
| 368 | }
|
---|
| 369 | }
|
---|
| 370 | return(@return);
|
---|
| 371 | }
|
---|
| 372 |
|
---|
[1495] | 373 | =item B<pb_conf_add_last_in_hash>
|
---|
[405] | 374 |
|
---|
[1495] | 375 | This function merges the values passed in the hash parameter into the %h hash, but only if itdoesn't already contain a value, or if the value is more precise (real value instead of default)
|
---|
[405] | 376 |
|
---|
[1495] | 377 | It is used internally by pb_conf_add and is not exported.
|
---|
[409] | 378 |
|
---|
| 379 | =cut
|
---|
| 380 |
|
---|
[1495] | 381 | sub pb_conf_add_last_in_hash {
|
---|
[409] | 382 |
|
---|
[1907] | 383 | my $ptr = shift;
|
---|
[409] | 384 |
|
---|
[1495] | 385 | return if (not defined $ptr);
|
---|
| 386 | # TODO: test $ptr is a hash pointer
|
---|
[405] | 387 |
|
---|
[1509] | 388 | # When called without correct initialization, try to work anyway with default as project
|
---|
| 389 | pb_conf_init("default") if (not defined $ENV{'PBPROJ'});
|
---|
| 390 |
|
---|
[1495] | 391 | my @params = (sort keys %$ptr);
|
---|
[405] | 392 |
|
---|
[1495] | 393 | # Everything is returned via @h
|
---|
| 394 | # @h contains the values overloading what @ptr may contain.
|
---|
[2154] | 395 | my @h = pb_conf_get_in_hash_if($h,@params);
|
---|
[1495] | 396 | my @ptr = pb_conf_get_in_hash_if($ptr,@params);
|
---|
[409] | 397 |
|
---|
[405] | 398 | my $p1;
|
---|
| 399 | my $p2;
|
---|
| 400 |
|
---|
[1495] | 401 | pb_log(2,"DEBUG: pb_conf_add_last_in_hash params: ".Dumper(@params)."\n");
|
---|
[2154] | 402 | pb_log(2,"DEBUG: pb_conf_add_last_in_hash current hash: ".Dumper(@h)."\n");
|
---|
| 403 | pb_log(2,"DEBUG: pb_conf_add_last_in_hash new inputs: ".Dumper(@ptr)."\n");
|
---|
[405] | 404 |
|
---|
[1495] | 405 | foreach my $i (0..$#params) {
|
---|
| 406 | $p1 = $h[$i];
|
---|
| 407 | $p2 = $ptr[$i];
|
---|
[2154] | 408 | # Always try to take the param from h in priority
|
---|
[1495] | 409 | # in order to mask what could be defined already in ptr
|
---|
[405] | 410 | if (not defined $p2) {
|
---|
[415] | 411 | # exit if no p1 either
|
---|
[1509] | 412 | next if (not defined $p1);
|
---|
[405] | 413 | } else {
|
---|
[409] | 414 | # Ref found in p2
|
---|
[405] | 415 | if (not defined $p1) {
|
---|
[409] | 416 | # No ref in p1 so use p2's value
|
---|
[405] | 417 | $p1 = $p2;
|
---|
| 418 | } else {
|
---|
| 419 | # Both are defined - handling the overloading
|
---|
[2154] | 420 | # Now copy back into p1 all p2 content
|
---|
| 421 | # as p1 content always has priority over p2
|
---|
[405] | 422 | if (not defined $p1->{$ENV{'PBPROJ'}}) {
|
---|
| 423 | if (defined $p2->{$ENV{'PBPROJ'}}) {
|
---|
[1594] | 424 | $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}};
|
---|
[405] | 425 | }
|
---|
| 426 | }
|
---|
| 427 | # Now copy back into p1 all p2 content which doesn't exist in p1
|
---|
[2154] | 428 | # # p1 content always has priority over p2
|
---|
[405] | 429 | foreach my $k (keys %$p2) {
|
---|
| 430 | $p1->{$k} = $p2->{$k} if (not defined $p1->{$k});
|
---|
| 431 | }
|
---|
| 432 | }
|
---|
| 433 | }
|
---|
[1495] | 434 | $h->{$params[$i]} = $p1;
|
---|
[405] | 435 | }
|
---|
[1495] | 436 | pb_log(2,"DEBUG: pb_conf_add_last_in_hash output: ".Dumper($h)."\n");
|
---|
[405] | 437 | }
|
---|
| 438 |
|
---|
[409] | 439 | =item B<pb_conf_get>
|
---|
[405] | 440 |
|
---|
[409] | 441 | This function is the same B<pb_conf_get_if>, except that it tests each returned value as they need to exist in that case.
|
---|
| 442 |
|
---|
| 443 | =cut
|
---|
| 444 |
|
---|
| 445 | sub pb_conf_get {
|
---|
| 446 |
|
---|
| 447 | my @param = @_;
|
---|
| 448 | my @return = pb_conf_get_if(@param);
|
---|
[932] | 449 | my $proj = undef;
|
---|
[409] | 450 |
|
---|
[932] | 451 | if (not defined $ENV{'PBPROJ'}) {
|
---|
| 452 | $proj = "unknown";
|
---|
| 453 | } else {
|
---|
| 454 | $proj = $ENV{'PBPROJ'};
|
---|
| 455 | }
|
---|
[409] | 456 |
|
---|
[1538] | 457 | confess "No params found for $proj" if (not @return);
|
---|
[932] | 458 |
|
---|
[409] | 459 | foreach my $i (0..$#param) {
|
---|
[1507] | 460 | confess "No $param[$i] defined for $proj" if (not defined $return[$i]);
|
---|
[409] | 461 | }
|
---|
| 462 | return(@return);
|
---|
| 463 | }
|
---|
| 464 |
|
---|
[1495] | 465 |
|
---|
[1694] | 466 | =item B<pb_conf_get_all>
|
---|
| 467 |
|
---|
[2077] | 468 | This function returns an array with all configuration parameters
|
---|
[1694] | 469 |
|
---|
| 470 | =cut
|
---|
| 471 |
|
---|
| 472 | sub pb_conf_get_all {
|
---|
| 473 |
|
---|
| 474 | return(sort keys %$h);
|
---|
| 475 | }
|
---|
| 476 |
|
---|
[2077] | 477 |
|
---|
| 478 | =item B<pb_conf_get_hash>
|
---|
| 479 |
|
---|
| 480 | This function returns a pointer to the hash with all configuration parameters
|
---|
| 481 |
|
---|
| 482 | =cut
|
---|
| 483 |
|
---|
| 484 | sub pb_conf_get_hash {
|
---|
| 485 |
|
---|
| 486 | return($h);
|
---|
| 487 | }
|
---|
| 488 |
|
---|
[405] | 489 | =back
|
---|
| 490 |
|
---|
| 491 | =head1 WEB SITES
|
---|
| 492 |
|
---|
| 493 | The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
|
---|
| 494 |
|
---|
| 495 | =head1 USER MAILING LIST
|
---|
| 496 |
|
---|
| 497 | None exists for the moment.
|
---|
| 498 |
|
---|
| 499 | =head1 AUTHORS
|
---|
| 500 |
|
---|
| 501 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 502 |
|
---|
| 503 | =head1 COPYRIGHT
|
---|
| 504 |
|
---|
| 505 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 506 | described in the file C<COPYING> included with the distribution.
|
---|
| 507 |
|
---|
| 508 | =cut
|
---|
| 509 |
|
---|
| 510 |
|
---|
| 511 | 1;
|
---|