From dc271ee187704032407459958ba47c0ce5fd7155 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Tue, 29 Sep 2009 16:04:12 +0000 Subject: xpp: FXO init scripts: -L to list opermodes * '/usr/share/dahdi/init_card_2_30 -L' will now list valid opermodes * Proper usage message while we're at it. * Make input opermode case-insensitive. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@7236 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/xpp/init_card_2_30 | 30 ++++++++++++++++++++++++++++-- drivers/dahdi/xpp/xpp.conf | 8 ++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'drivers/dahdi/xpp') diff --git a/drivers/dahdi/xpp/init_card_2_30 b/drivers/dahdi/xpp/init_card_2_30 index efc19a9..e3fa236 100755 --- a/drivers/dahdi/xpp/init_card_2_30 +++ b/drivers/dahdi/xpp/init_card_2_30 @@ -51,8 +51,25 @@ BEGIN { $init_dir = dirname($0); unshift(@INC, "$init_dir"); } use XppConfig $init_dir; my $unit_id; my %opts; +$Getopt::Std::STANDARD_HELP_VERSION = 1; +our $VERSION = '$Id$'; + +sub usage() { + print <<"EOF"; +$0 [-L] [-v verify_file] [-o output_file] + -L: List all available opermodes and exit + -v: verify opermodes and exit + -o: simulate: output to file instead of astribank +EOF + exit 1; +} + +sub HELP_MESSAGE() { + eval {usage}; + return 0; +} -getopts('o:v:', \%opts); +getopts('Lo:v:', \%opts) || usage; my %settings; $settings{debug} = 0; @@ -282,6 +299,11 @@ sub opermode_to_string($) { return join(" ", @params); } +sub opermode_list() { + my $l = join("\n", sort keys %opermode_table); + print "$l\n"; +} + sub opermode_verify($) { my $input = shift or die; my %verification_table; @@ -339,6 +361,7 @@ sub read_defaults() { my $o = $settings{opermode}; if(defined($o)) { # Verify + $o = uc($o); # Uppercase my $mode = $opermode_table{$o}; if(! defined $mode) { main::logit "Unknown opermode='$o'"; @@ -358,11 +381,14 @@ FXO::opermode_preprocess; # Must be first if($opts{v}) { my $verify_file = $opts{v}; - die "Usage: $0 [-v verify_filename]\n" unless $verify_file; + usage unless $verify_file; main::debug "$0: opermode verification (input='$verify_file')"; my $mismatches = FXO::opermode_verify($verify_file); die "$0: Verification against $verify_file failed\n" if $mismatches != 0; exit 0; +} elsif($opts{L}) { + FXO::opermode_list(); + exit 0; } main::debug "Starting"; diff --git a/drivers/dahdi/xpp/xpp.conf b/drivers/dahdi/xpp/xpp.conf index b639020..3e4bc9b 100644 --- a/drivers/dahdi/xpp/xpp.conf +++ b/drivers/dahdi/xpp/xpp.conf @@ -16,8 +16,12 @@ # International settings for the XPP FXO module. This is similar to the # 'opermode' kernel module of wctdm and wctdm24xxp . The default value -# is 'FCC' (US settings). You can find the full list of countries in -# the script /usr/share/dahdi/init_card_1_30 . +# is 'FCC' (US settings). +# +# The valid settings can be shown by running the init_card_2_30 script with +# the '-L' option. For example: +# /usr/share/dahdi/init_card_2_30 -L +# #opermode UK # Set this to enable debug mode for the scripts: -- cgit v1.2.3