<DIV>I was setting up an extensions.conf the other day when I realized some things I wish were possible and just tossing it up for input. </DIV>
<DIV> </DIV>
<DIV>1)</DIV>
<DIV> </DIV>
<DIV>If you used a certian variable in a context it would be nice if you could</DIV>
<DIV>change the value of that variable right before you do an include so you </DIV>
<DIV>could make templates of sorts that could be controlled by the include command.</DIV>
<DIV> </DIV>
<DIV>For example</DIV>
<DIV> </DIV>
<DIV>[globals]</DIV>
<DIV>OUT1=Zap/1</DIV>
<DIV>OUT2=Zap/2</DIV>
<DIV> </DIV>
<DIV>[generic]</DIV>
<DIV>exten => _9.,1,Dial(${OUT}/${EXTEN:1})</DIV>
<DIV> </DIV>
<DIV>[ex1]</DIV>
<DIV>include => generic, OUT=${OUT1}</DIV>
<DIV> </DIV>
<DIV>[ex2] </DIV>
<DIV>include => generic, OUT=${OUT2}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>I accomplished this using my app_perl module but doing at natively doesnt seem too complicated.</DIV>
<DIV> </DIV>
<DIV>[generic]</DIV>
<DIV>
<DIV>exten => _9.,1,Perl,dial_by_context:${CONTEXT}</DIV></DIV>
<DIV>
<DIV>exten => _9.,2,Dial(${USETRUNK}/${EXTEN:1})</DIV></DIV>
<DIV> </DIV>
<DIV>
<DIV>[ex1]</DIV>
<DIV>include => generic</DIV>
<DIV> </DIV>
<DIV>[ex2] </DIV>
<DIV>include => generic</DIV></DIV>
<DIV> </DIV>
<DIV># in my asterisk_init.pm </DIV>
<DIV> </DIV>
<DIV>sub dial_by_context(@) {<BR> my ($context) = @_;</DIV>
<DIV> my %trunks = (<BR> ex1 => "Zap/1",<BR> ex2 => "Zap/2",<BR> default => "Zap/1"<BR> );</DIV>
<DIV> $trunks{$context} ||= $trunks{default};</DIV>
<DIV> return ("setvar:USETRUNK:$trunks{$context}");</DIV>
<DIV>}<BR></DIV>
<DIV>then when you are in context ex1 the ${USETRUNK} is Zap/1</DIV>
<DIV>and in ex2 it's Zap/2 but you only need 1 generic context.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>2)</DIV>
<DIV> </DIV>
<DIV>Another possibility could be to implement associative arrays as global variables.</DIV>
<DIV> </DIV>
<DIV>[globals]</DIV>
<DIV> </DIV>
<DIV>[global_hashes]</DIV>
<DIV>TRUNKS = (ex1 => "Zap/1", ex2 => "Zap/2") </DIV>
<DIV> </DIV>
<DIV>
<DIV>[generic]</DIV>
<DIV>exten => _9.,1,Dial(${TRUNKS}->[${CONTEXT}]/${EXTEN:1})</DIV>
<DIV> </DIV>
<DIV>[ex1]</DIV>
<DIV>include => generic, OUT=${OUT1}</DIV>
<DIV> </DIV>
<DIV>[ex2] </DIV>
<DIV>include => generic, OUT=${OUT2}</DIV>
<DIV> </DIV>
<DIV>3)</DIV>
<DIV> </DIV></DIV>
<DIV>Finally a regex engine would be nice to perform tranlation on variables</DIV>
<DIV>I also do this with app_perl but it could be native as well</DIV>
<DIV> </DIV>
<DIV>Say you want to be able to dial an IP address on an analog phone by</DIV>
<DIV>using the * as a period and pattern match it and feed it to H323</DIV>
<DIV> </DIV>
<DIV>exten => _9*.*.*.*.,1,Perl,star_to_ip:${EXTEN:2}<BR>exten => _9*.*.*.*.,2,Ringing<BR>exten => _9*.*.*.*.,3,Dial(H323/${CALLIP})<BR>exten => _9*.*.*.*.,4,Congestion<BR></DIV>
<DIV>sub star_to_ip(@) {<BR> my $num = shift;<BR> $num =~ s/\*/\./g;<BR> return "setvar:CALLIP:$num";<BR>}<BR></DIV>
<DIV>perhaps just magic special var called ${SUBSTITUTE}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>exten => _9*.*.*.*.,1,Substitute,${EXTEN:2},*,.<BR>exten => _9*.*.*.*.,2,Ringing<BR>exten => _9*.*.*.*.,3,Dial(H323/${SUBSTITUTED})<BR>exten => _9*.*.*.*.,4,Congestion<BR></DIV>
<DIV>i'm sure app_substitute could be its own module I'm just offering input </DIV>
<DIV>That's kinda why I wanted to make an app_perl so I could just make stuff </DIV>
<DIV>on the fly w/o doing any C but I think i need to go work on it a little more before </DIV>
<DIV>it's pubicly accepted.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com">Yahoo! SiteBuilder</a> - Free, easy-to-use web site design software