[svn-commits] tzafrir: linux/trunk r4373 - /linux/trunk/drivers/dahdi/xpp/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Jun 17 12:28:43 CDT 2008
Author: tzafrir
Date: Tue Jun 17 12:28:42 2008
New Revision: 4373
URL: http://svn.digium.com/view/dahdi?view=rev&rev=4373
Log:
Adapt xpp init_card_* scripts to dahdi:
* No more dependency in zconf/
* Add new config file: xpp.conf
* Use new perl module XppConfig.pm that read this config file.
Added:
linux/trunk/drivers/dahdi/xpp/XppConfig.pm (with props)
linux/trunk/drivers/dahdi/xpp/xpp.conf (with props)
Modified:
linux/trunk/drivers/dahdi/xpp/init_card_1_30
linux/trunk/drivers/dahdi/xpp/init_card_2_30
linux/trunk/drivers/dahdi/xpp/init_card_4_30
Added: linux/trunk/drivers/dahdi/xpp/XppConfig.pm
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/XppConfig.pm?view=auto&rev=4373
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/XppConfig.pm (added)
+++ linux/trunk/drivers/dahdi/xpp/XppConfig.pm Tue Jun 17 12:28:42 2008
@@ -1,0 +1,84 @@
+package XppConf;
+#
+# Written by Oron Peled <oron at actcom.co.il>
+# Copyright (C) 2008, Xorcom
+# This program is free software; you can redistribute and/or
+# modify it under the same terms as Perl itself.
+#
+# $Id$
+#
+use strict;
+
+my $conf_file = "/etc/dahdi/xpp.conf";
+
+$conf_file = $ENV{XPP_CONFIG} if $ENV{XPP_CONFIG};
+
+sub subst_var($$) {
+ my $lookup = shift;
+ my $string = shift;
+
+ if(defined $lookup->{$string}) {
+ return $lookup->{$string};
+ } else {
+ return $string;
+ }
+}
+
+sub read_config($) {
+ my $input = shift || die;
+ my %xpp_config;
+ my $lookup = \%xpp_config;
+
+ open(F, $input) || die "Failed reading configuration $input: $!\n";
+LINE:
+ 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;
+ }
+ close F;
+ return %xpp_config;
+}
+
+my %x = read_config($conf_file);
+
+sub show_vars {
+ my $assoc = shift;
+ foreach (sort keys %{$assoc}) {
+ print "$_\t$assoc->{$_}\n";
+ }
+}
+
+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);
+}
+
+source_vars(qw(XPP_PRI_SETUP opermode));
+
+1;
Propchange: linux/trunk/drivers/dahdi/xpp/XppConfig.pm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: linux/trunk/drivers/dahdi/xpp/XppConfig.pm
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: linux/trunk/drivers/dahdi/xpp/XppConfig.pm
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: linux/trunk/drivers/dahdi/xpp/init_card_1_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_1_30?view=diff&rev=4373&r1=4372&r2=4373
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_1_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_1_30 Tue Jun 17 12:28:42 2008
@@ -45,7 +45,7 @@
my $program = basename("$0");
my $init_dir = dirname("$0");
BEGIN { $init_dir = dirname($0); unshift(@INC, "$init_dir", "$init_dir/zconf"); }
-use Zaptel::Config::Defaults;
+use XppConfig;
my $unit_id;
my %opts;
$ENV{XPP_BASE} = '/proc/xpp';
@@ -380,7 +380,7 @@
my $var_debug = 'DEBUG_INIT_FXS';
my $var_skip_calib = 'INIT_FXS_SKIP_CALIB';
my ($default_file, %source_defaults) =
- Zaptel::Config::Defaults::source_vars($var_debug, $var_skip_calib);
+ XppConfig::source_vars($var_debug, $var_skip_calib);
$debug = $source_defaults{$var_debug};
$skip_calib = $source_defaults{$var_skip_calib};
main::logit "From $default_file: $var_debug=$debug $var_skip_calib=$skip_calib";
Modified: linux/trunk/drivers/dahdi/xpp/init_card_2_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_2_30?view=diff&rev=4373&r1=4372&r2=4373
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_2_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_2_30 Tue Jun 17 12:28:42 2008
@@ -45,7 +45,7 @@
my $program = basename("$0");
my $init_dir = dirname("$0");
BEGIN { $init_dir = dirname($0); unshift(@INC, "$init_dir", "$init_dir/zconf", "$init_dir/utils/zconf"); }
-use Zaptel::Config::Defaults;
+use XppConfig;
my $unit_id;
my %opts;
$ENV{XPP_BASE} = '/proc/xpp';
@@ -312,7 +312,7 @@
my $var_debug = 'DEBUG_INIT_FXO';
my $var_opermode = 'opermode';
my ($default_file, %source_defaults) =
- Zaptel::Config::Defaults::source_vars($var_debug, $var_opermode);
+ XppConfig::source_vars($var_debug, $var_opermode);
$debug = $source_defaults{$var_debug};
my $tmp_opermode = $source_defaults{$var_opermode};
if(defined($tmp_opermode) and $tmp_opermode) {
Modified: linux/trunk/drivers/dahdi/xpp/init_card_4_30
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/init_card_4_30?view=diff&rev=4373&r1=4372&r2=4373
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/init_card_4_30 (original)
+++ linux/trunk/drivers/dahdi/xpp/init_card_4_30 Tue Jun 17 12:28:42 2008
@@ -149,7 +149,7 @@
my $setup_var = 'XPP_PRI_SETUP';
my $setup_string;
my ($default_file, %source_defaults) =
- Zaptel::Config::Defaults::source_vars($setup_var);
+ XppConfig::source_vars($setup_var);
$setup_string = $source_defaults{$setup_var};
$setup_string =~ s/^\s+//; # trim
$setup_string =~ s/\s+$//; # trim
@@ -345,7 +345,7 @@
package main;
BEGIN { my $dir = dirname($0); unshift(@INC, "$dir", "$dir/zconf"); }
-use Zaptel::Config::Defaults;
+use XppConfig;
logit "Starting '$0'";
Added: linux/trunk/drivers/dahdi/xpp/xpp.conf
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/xpp.conf?view=auto&rev=4373
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpp.conf (added)
+++ linux/trunk/drivers/dahdi/xpp/xpp.conf Tue Jun 17 12:28:42 2008
@@ -1,0 +1,14 @@
+# A local replacement for /etc/default/zaptel
+
+#INIT_FXS_SKIP_CALIB=1
+DEBUG_INIT_FXS=0
+DEBUG_INIT_FXO=0
+
+opermode=ISRAEL
+
+#TYPE=T1
+TYPE = E1
+
+XPP_PRI_SETUP = \
+ NUM/*/XPD-0[02]=TE,$TYPE \
+ NUM/*/XPD-0[13]=NT,$TYPE
Propchange: linux/trunk/drivers/dahdi/xpp/xpp.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: linux/trunk/drivers/dahdi/xpp/xpp.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: linux/trunk/drivers/dahdi/xpp/xpp.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the svn-commits
mailing list