[svn-commits] tzafrir: branch tools/tzafrir/perl-sysstate r7717 - in /tools/team/tzafrir/pe...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 21 15:59:50 CST 2009


Author: tzafrir
Date: Mon Dec 21 15:59:49 2009
New Revision: 7717

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7717
Log:
Get rid of separate proc_base in Dahdi::Span

Get the /proc/dahdi file itself as a parameter rather than passing it as
a number.

Modified:
    tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm
    tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Span.pm

Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm?view=diff&rev=7717&r1=7716&r2=7717
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm Mon Dec 21 15:59:49 2009
@@ -45,8 +45,7 @@
 
 	-d $proc_base or return ();
 	foreach my $zfile (glob "$proc_base/*") {
-		$zfile =~ s:$proc_base/::;
-		next unless ($zfile =~ /^\d+$/);
+		next unless ($zfile =~ m{^$proc_base/\d+$});
 		my $span = Dahdi::Span->new($zfile);
 		push(@spans, $span);
 	}

Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Span.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Span.pm?view=diff&rev=7717&r1=7716&r2=7717
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Span.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Span.pm Mon Dec 21 15:59:49 2009
@@ -112,8 +112,6 @@
 "signalling" is set, look for "SIGNALLING".
 
 =cut
-
-my $proc_base = "/proc/dahdi";
 
 sub chans($) {
 	my $span = shift;
@@ -175,7 +173,9 @@
 
 sub new($$) {
 	my $pack = shift or die "Wasn't called as a class method\n";
-	my $num = shift or die "Missing a span number parameter\n";
+	my $proc_file = shift or die "Missing a proc file parameter\n";
+	$proc_file =~ m{[^/]*/(\d+)$};
+	my $num = $1 or die " Invalid span file name: $proc_file\n";
 	my $self = { NUM => $num };
 	bless $self, $pack;
 	$self->{TYPE} = "UNKNOWN";
@@ -185,7 +185,7 @@
 		die "Spanno mismatch: $xpd->spanno, $num" unless $xpd->spanno == $num;
 		$self->{XPD} = $xpd;
 	}
-	open(F, "$proc_base/$num") or die "Failed to open '$proc_base/$num\n";
+	open(F, "$proc_file") or die "Failed to open '$proc_file\n";
 	my $head = <F>;
 	chomp $head;
 	$self->{IS_DIGITAL} = 0;




More information about the svn-commits mailing list