Need to strip a number, and add a prefix

Hi,

I’ve seen the page detailing a method for making a suitable dial plan for UK use (3 outbound routes, each trunk with 3 dial plan rules), but if I could strip a 0 and add a 44 I could do it in 1 outbound route and only need dial plan rules in certain trunks, not all.

Basically, leave the default outbound route alone (strip the 9), and for trunks needing full international dialing codes (in my case ENUM lookups) a rule to match full UK national numbers (01234567890) strip the leading 0 and add 44 (or +44, but macro-dialout-enum sorts out + or no +) to make it 441234567890.
I was thinking perhaps an extension to fixlocalprefix to pass the number as it stands after being processed by a matching rule, back in to the next rule?
Being able to stack rules like this would be extremely powerful. Shouldn’t be especially hard either.

if($last_digit == “>”){
break;
}else{
// note, because this matched, we exit even if we didn’t change anything
exit(0);
}

?

I was right, wasn’t so hard.
Asterisk doesn’t seem to mind being told to set the number X times, but it might be worth not telling if($last_digit).

[code:1]

diff -u /var/lib/asterisk/agi-bin/fixlocalprefix.orig /var/lib/asterisk/agi-bin/fixlocalprefix

— /var/lib/asterisk/agi-bin/fixlocalprefix.orig 2006-09-22 17:04:40.000000000 +0100
+++ /var/lib/asterisk/agi-bin/fixlocalprefix 2006-09-22 17:28:35.000000000 +0100
@@ -150,6 +150,20 @@
$regex = $rule;
$prefix = “”;

  •                   // if the last rule continued, but didn't match, we skip this rule
    
  •                   if(empty($match) && isset($last_digit)){
    
  •                           unset($last_digit);
    
  •                           continue;
    
  •                   }
    
  •                   unset($match);
    
  •                   // check for and strip off >, the indicator to try the next rule even if we match
    
  •                   if((strrpos($regex, ">")+1) == strlen($regex)){
    
  •                           $regex = substr($regex, 0, -1);
    
  •                           $last_digit = ">";
    
  •                   }else{
    
  •                           unset($last_digit);
    
  •                   }
                      // Remove all non-pattern characters from $regex except for '+' and '|'.
                      // Allow groups like "[0-9]" to remain.
                      $regex = preg_replace("/[^0-9XNZ#*\.\[\]\-\+\|]/", "", $regex);
    

@@ -199,17 +213,23 @@
$number = preg_replace("/^$regex$/", “$1”, $number);
$agi->verbose(“Removed prefix. New number: $number”);
$agi->set_variable(“DIAL_NUMBER”, $number);

  •                                           $match=1;
                                      break;
                                      case "add":
                                              // we're adding digits
                                              $number = $prefix . $number;
                                              $agi->verbose("Added prefix.  New number: $number");
                                              $agi->set_variable("DIAL_NUMBER", $number);
    
  •                                           $match=1;
                                      break;
                              }
    
  •                           // note, because this matched, we exit even if we didn't change anything
    
  •                           exit(0);
    
  •                           if($last_digit == ">"){
    
  •                                   continue;
    
  •                           }else{
    
  •                                   // note, because this matched, we exit even if we didn't change anything
    
  •                                   exit(0);
    
  •                           }
                      } // else, it didn't match this rule
              } // else, this isn't a rule
      }
    

[/code:1][/code]

No one?

I find it useful.

Here is a quick change to the javascript to accept > as a valid dial pattern character.

[code:1]

diff -u script.js.php.orig script.js.php

— script.js.php.orig 2006-10-05 17:21:19.000000000 +0100
+++ script.js.php 2006-10-05 17:21:38.000000000 +0100
@@ -565,7 +565,7 @@
}

function isDialpatternChar ©
-{ return ( ((c >= “0”) && (c <= “9”)) || (c == “[”) || (c == “]”) || (c == “-”) || (c == “+”) || (c == “.”) || (c == “|”) || (c == “Z” || c == “z”) || (c == “X” || c == “x”) || (c == “N” || c == “n”) || (c == “") || (c == “#” ) || (c == “_”) || (c == “!”))
+{ return ( ((c >= “0”) && (c <= “9”)) || (c == “[”) || (c == “]”) || (c == “-”) || (c == “+”) || (c == “.”) || (c == “|”) || (c == “Z” || c == “z”) || (c == “X” || c == “x”) || (c == “N” || c == “n”) || (c == "
”) || (c == “#” ) || (c == “_”) || (c == “!”) || (c == “>”))
}

function isDialDigitChar ©
@@ -574,4 +574,4 @@

function isFilenameChar ©
{ return ( ((c >= “0”) && (c <= “9”)) || ((c >= “a”) && (c <= “z”)) || ((c >= “A”) && (c <= “Z”)) || (c == “_”) || (c == “-”) )
-}
\ No newline at end of file
+}
[/code:1]

In 2.2, you can do that in trunks, no problems 8)

44+0|.

Sending 0123456 to the trunk will strip off the zero, and add 44 on the start.

–Rob

where can I get 2.2 at? last I checked 2.13 was the latest
----- Original Message -----
From: “xrobau” [email protected]
To: [email protected]
Sent: Sunday, October 15, 2006 11:51 PM
Subject: Re: [Amportal-users] Need to strip a number, and add a prefix

[quote] In 2.2, you can do that in trunks, no problems 8)

44+0|.

Sending 0123456 to the trunk will strip off the zero, and add 44 on the
start.

–Rob


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


Amportal-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amportal-users
[/quote]


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


Amportal-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amportal-users

Post generated using Mail2Forum (http://www.mail2forum.com)

[quote=“xrobau”]In 2.2, you can do that in trunks, no problems 8)

44+0|.

Sending 0123456 to the trunk will strip off the zero, and add 44 on the start.

–Rob[/quote]

That was the exact first thing that I tried! :slight_smile:
Except I had 2.1.2 at time, and 2.1.3 now.

Is trunk what will be 2.2?

Thanks