summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/XppConfig.pm
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-06-29 15:05:48 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-06-29 15:05:48 +0000
commitd9e8eab9a3869d54c2ae26c2d7a757762b0e68f7 (patch)
treefdc2fe8c67c52dfb722af879837b069cd629bf63 /drivers/dahdi/xpp/XppConfig.pm
parente4de227a9fcedf1a521bd8a885b8bcd8e180101d (diff)
Changes in XPP initialization and configuration:
* The configuration for XPP init_card_* scripts is done now in /etc/dahdi/xpp.conf and uses a simple syntax (example included). For PRI modules, the 'pri_protocol' setting, determines how to configure it (E1/T1). * In Astribank PRI modules, the LED behaviour represent which ports are *CLOCK MASTER* (red color) and which are *CLOCK SLAVE* (green color). Usually (but not always), this corresponds to the NT/TE settings in Asterisk. * dahdi_genconf now replaces zapconf and deprecates genzaptelconf. Relevant configuration settings were removed from the kernel package and are implemented and described in the tools package. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@4480 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/XppConfig.pm')
-rw-r--r--drivers/dahdi/xpp/XppConfig.pm73
1 files changed, 12 insertions, 61 deletions
diff --git a/drivers/dahdi/xpp/XppConfig.pm b/drivers/dahdi/xpp/XppConfig.pm
index 1485a0d..f00811f 100644
--- a/drivers/dahdi/xpp/XppConfig.pm
+++ b/drivers/dahdi/xpp/XppConfig.pm
@@ -11,77 +11,28 @@ use strict;
my $conf_file = "/etc/dahdi/xpp.conf";
-sub subst_var($$) {
- my $lookup = shift;
- my $string = shift;
-
- if(defined $lookup->{$string}) {
- return $lookup->{$string};
- } else {
- return $string;
- }
+sub import {
+ my $pack = shift || die "Import without package?";
+ my $init_dir = shift || die "$pack::import -- missing init_dir parameter";
+ my $local_conf = "$init_dir/xpp.conf";
+ $conf_file = $local_conf if -r $local_conf;
}
sub read_config($) {
- my $input = shift || die;
- my %xpp_config;
- my $lookup = \%xpp_config;
+ my $opts = shift || die;
- open(F, $input) || die "Failed reading configuration $input: $!\n";
-LINE:
+ open(F, $conf_file) || return ();
while(<F>) {
chomp;
s/#.*//; # strip comments
next unless /\S/;
- s/^\s*//;
- if(s/\\$//) {
- my $next = <F>;
- $next =~ s/^\s*//;
- $_ .= " $next";
- redo LINE;
- }
- my ($key, $value) = split(/=/, $_, 2);
- # Trim whitespace around key/value
- $key =~ s/^\s*(\S+)\s*$/$1/;
- $value =~ s/^\s*(\S+)\s*$/$1/;
- # Variable substitution
- my $new_value = $value;
- $new_value =~ s/\$(\w+)/subst_var($lookup,$1)/eg;
- $xpp_config{$key} = $new_value;
+ s/\s*$//; # Trim trailing whitespace
+ my ($key, $value) = split(/\s+/, $_, 2);
+ $opts->{$key} = $value;
}
close F;
- return %xpp_config;
-}
-
-sub import {
- my $pack = shift || die "Import without package?";
- my $init_dir = shift || die "$pack::import -- missing init_dir parameter";
- my $local_conf = "$init_dir/xpp.conf";
- $conf_file = $local_conf if -r $local_conf;
- my %x = read_config($conf_file);
-}
-
-sub show_vars {
- my $assoc = shift;
- foreach (sort keys %{$assoc}) {
- print "$_\t$assoc->{$_}\n";
- }
+ $opts->{'xppconf'} = $conf_file;
+ return %{$opts};
}
-sub source_vars {
- my @keys = @_;
- my %conf = read_config($conf_file);
- my %result;
- my $k;
- my $v;
-
- foreach (@keys) {
- if(defined $conf{$_}) {
- $result{$_} = $conf{$_};
- }
- }
- return ($conf_file, %result);
-}
-
-
1;