summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/init_card_2_30
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-09-29 16:04:12 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-09-29 16:04:12 +0000
commitdc271ee187704032407459958ba47c0ce5fd7155 (patch)
tree5e945efd1835a6c2106638c7c9d121b1f20881a6 /drivers/dahdi/xpp/init_card_2_30
parent1d30081bd5314876b0036ceabb19df725ca02696 (diff)
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
Diffstat (limited to 'drivers/dahdi/xpp/init_card_2_30')
-rwxr-xr-xdrivers/dahdi/xpp/init_card_2_3030
1 files changed, 28 insertions, 2 deletions
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";