[asterisk-users] How to write a function with a return value in Asterisk

Mike list at virtutel.ca
Wed Aug 8 12:39:34 CDT 2007


Thanks for all the replies, after some thinking AGI seems like the way to go
(writing a function in C would certainly work, but I want to avoid anything
that makes upgrading to newer version of Asterisk a potential pain.  Let's
say using C is plan B).
 
So, I wrote (well, plagarized directly from the Web) a simple Perl program
that prints "Hello World".  I call it using this:
 
exten => 12345,1,AGI(agi-helloworld.agi)
 
Seems to work (I'm not expecting anything, really, just no Asterisk error).
 
When I try to use it as part Noop like this:
exten => 12345,1,Noop(${AGI(agi-helloworld.agi)})
 
In the hope of getting to see Noop(Hello World) in my CLI, I get the
following Asterisk error:
 
Aug  8 13:40:48 ERROR[5771]: pbx.c:1402 ast_func_read: Function AGI not
registered
 
AGI certainly seems registered as it worked in the first case.  Again,
something obvious I missed?
 
Thank you,
 
Mike
 
 

  _____  

From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Anthony
Francis
Sent: Wednesday, August 08, 2007 12:39
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] How to write a function with a return value in
Asterisk


You are looking for the AGI: http://www.voip-info.org/wiki-Asterisk+AGI

Anthony

James FitzGibbon wrote: 

On 8/8/07, Mike <list at virtutel.ca> wrote: 


I'd be most thankful for some link to a page that shows how to write such a
function in Asterisk.


There is a test application in the source tree (not built by default I
believe), but it doesn't look like anyone has made an equivalent sample
function. 

However, many of the functions in 1.4 are pretty simple, and would be a good
jumping off point.  Take func_sha1.c for example: 83 lines in the file, 4
functions and one macro.  You could copy that and do the proper renaming to
make MY_FUNKY_NEW_FUNC that does exactly what func_sha1 does (or
alternatively, nothing by getting rid of the bulk of the sha1() function
therein. 

How big it gets as you add whatever magic that function should perform is up
to you of course.


-- 
j. 


  _____  


_______________________________________________

--Bandwidth and Colocation Provided by http://www.api-digital.com--



asterisk-users mailing list

To UNSUBSCRIBE or update options visit:

   http://lists.digium.com/mailman/listinfo/asterisk-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070808/c36e6372/attachment.htm 


More information about the asterisk-users mailing list