From: Andrew Ruthven Date: Tue, 13 Jan 2009 07:57:40 +0000 (+1300) Subject: Run it through perltidy. X-Git-Tag: debian-0.2-1~19 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=040d97c5f42a5ff76e5aa32a77503926104de120;p=asterisk-agi-enum.git Run it through perltidy. --- diff --git a/enum.agi b/enum.agi index 35e7dff..92da2eb 100644 --- a/enum.agi +++ b/enum.agi @@ -1,7 +1,7 @@ #!/usr/bin/env perl # # Make outgoing calls via enum NAPTR records. -# +# # Add to your extensions.conf like so: # exten => _*164X.,n,AGI(enum.agi, +${EXTEN:4}) # @@ -17,19 +17,13 @@ use warnings; use Net::DNS; use Asterisk::AGI; -my ( - @resolvers, - $A, - %AGI, - $num, - $resources -); +my ( @resolvers, $A, %AGI, $num, $resources ); # in order of preference @resolvers = qw/ e164.org e164.arpa /; # setup AGI environment -$A = Asterisk::AGI->new(); +$A = Asterisk::AGI->new(); %AGI = $A->ReadParse; unless ( $num = $ARGV[0] ) { @@ -40,18 +34,23 @@ $ARGV[0] =~ s/\s+//g; $num =~ s/[^\d]//g; $num = join '.', split //, reverse $num; -foreach ( @resolvers ) { +foreach (@resolvers) { last if $resources; - $A->verbose("Finding resource at $_ for $ARGV[0]...", 4); + $A->verbose( "Finding resource at $_ for $ARGV[0]...", 4 ); $resources = get_resources( $num, $_ ); } -unless ( $resources ) { +unless ($resources) { $A->verbose( "No valid resources found for $ARGV[0].", 4 ); exit; } -foreach ( sort { $resources->{$a}->{'preference'} <=> $resources->{$b}->{'preference'} } - keys %$resources ) { +foreach ( + sort { + $resources->{$a}->{'preference'} <=> $resources->{$b}->{'preference'} + } + keys %$resources + ) +{ my $resource = $resources->{$_}->{'resource'}; if ( $A->exec( 'Dial', "$resource|60|r" ) ) { last; @@ -61,16 +60,16 @@ foreach ( sort { $resources->{$a}->{'preference'} <=> $resources->{$b}->{'prefer exit; -sub get_resources -{ +sub get_resources { my ( $num, $resolver ) = @_; my $resource; my $res = Net::DNS::Resolver->new; my $query = $res->query( "$num.$_", 'NAPTR' ); - unless ( $query ) { - $A->verbose("ENUM query failed at $_ for $ARGV[0]: " . $res->errorstring, 4); + unless ($query) { + $A->verbose( + "ENUM query failed at $_ for $ARGV[0]: " . $res->errorstring, 4 ); return; } @@ -83,13 +82,14 @@ sub get_resources $count++; $resource = $ARGV[0]; - my ( $pattern, $replacement ) = (split '!', $rr->regexp)[1,2]; + my ( $pattern, $replacement ) = ( split '!', $rr->regexp )[ 1, 2 ]; print "$pattern, $replacement\n"; unless ( $resource =~ s/$pattern/$replacement/ ) { - $A->verbose("Unable to apply regexp to $ARGV[0]", 4); + $A->verbose( "Unable to apply regexp to $ARGV[0]", 4 ); } $resource =~ s/^(\w+):/\U$1\//; - $records{$count} = { preference => $rr->preference, resource => $resource }; + $records{$count} = + { preference => $rr->preference, resource => $resource }; } return \%records;