diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-08-12 13:05:47 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-08-12 13:05:47 +0000 |
commit | 7e08fd7340d1cdb0f51afdcc13ad342016768263 (patch) | |
tree | 065da831242a204ae1dc4ad93690bf6bbc4c686b | |
parent | 7d1d0aa73e6c57e758e37ca94a1390e233de8fab (diff) |
Zaptel-perl: more robust parsing of channel signalling types.
Parse them from a list rather thna fusing a regex of a "word".
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@4475 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rw-r--r-- | xpp/utils/zconf/Zaptel/Chans.pm | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/xpp/utils/zconf/Zaptel/Chans.pm b/xpp/utils/zconf/Zaptel/Chans.pm index aa552a2..38e8a4b 100644 --- a/xpp/utils/zconf/Zaptel/Chans.pm +++ b/xpp/utils/zconf/Zaptel/Chans.pm @@ -62,6 +62,29 @@ Returns the type of the channel: 'FXS', 'FXO', 'EMPTY', etc. my @alarm_types = qw(BLUE YELLOW RED LOOP RECOVERING NOTOPEN); +# Taken from zaptel-base.c +my @sigtypes = ( + "FXSLS", + "FXSKS", + "FXSGS", + "FXOLS", + "FXOKS", + "FXOGS", + "E&M", + "E&M-E1", + "Clear", + "HDLCRAW", + "HDLCFCS", + "HDLCNET", + "Hardware-assisted HDLC", + "Slave", + "CAS", + "DACS", + "DACS+RBS", + "SF (ToneOnly)", + "Unconfigured" + ); + sub new($$$$$$) { my $pack = shift or die "Wasn't called as a class method\n"; my $span = shift or die "Missing a span parameter\n"; @@ -81,7 +104,7 @@ sub new($$$$$$) { my $info = ''; if(defined $rest) { # remarks in parenthesis (In use), (no pcm) - while($rest =~ s/(\([^)]+\))\s*//) { + while($rest =~ s/\s*(\([^)]+\))\s*//) { $info .= " $1"; } # Alarms @@ -90,10 +113,13 @@ sub new($$$$$$) { push(@alarms, $1); } } - if($rest =~ s/^\s*(\w+)\s*//) { - $signalling = $1; + foreach my $sig (@sigtypes) { + if($rest =~ s/^\Q$sig\E//) { + $signalling = $sig; + last; + } } - die "Unrecognized garbage '$rest' in $fqn\n" + warn "Unrecognized garbage '$rest' in $fqn\n" if length($rest); } $self->{NUM} = $num; |