[asterisk-users] How to write a function with a return value in Asterisk
John Millican
jmillican at sentinelcommunications.com
Wed Aug 8 11:27:12 CDT 2007
On Wednesday August 08 2007 12:10 pm, Mike wrote:
> I can be a bit slow sometimes, but you said that it's not possible, and on
> the other hand told me to write my own function (which appears to
> contradict the first statement).
>
> Your example of the use of a function is exactly what I need (Create a
> function and Dial(SIP/${MY_FUNKY_NEW_FUNC(ooga)})) , what I don't know is
> how to actually write the function with a return value (and Googling this
> doesn't get me any relevant result, apparently).
>
> I'd be most thankful for some link to a page that shows how to write such a
> function in Asterisk.
>
> Mike
>
> -----Original Message-----
> From: asterisk-users-bounces at lists.digium.com
> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Andrew
> Kohlsmith
> Sent: Wednesday, August 08, 2007 11:59
> To: asterisk-users at lists.digium.com
> Subject: Re: [asterisk-users] How to write a function with a return
> valueinAsterisk
>
> On Wednesday 08 August 2007 11:41:38 am Mike wrote:
> > But what if I wanted to write my own custom application for one
> > specific purpose, I can't set a return value? It's not possible at all?
>
> Not possible, to my knowledge.
>
> > Let me put it this way then, if I needed to have some processing all
> > done in the same Asterisk priority (in my case, I want to use the "hint"
> > priority but I need to find the value of a variable and use it in the
> > same line).
>
> Create a function and Dial(SIP/${MY_FUNKY_NEW_FUNC(ooga)})
>
> > Exten => 12345,hint,Dial(SIP/${A}) ; I need to know ${A} first, but I
> > can't know before this line is called (it's very DB driven).
>
> Give the function method a try; that's about the only way I can think of
> doing something like that... Note that if it's a very DB driven system,
> you can use func_odbc to do what you want by declaring an SQL statement as
> a function.
>
> -A.
>
Asterisk will listen on stdin if you have your agi code write the var and
value out to stdout asterisk will then be able touse that var in the dial
plan. this is how I do this in a C++ app that i use often:
fprintf(stdout,"EXEC SETVAR RESERVED=1 \n");
then in the dial plan I look at the value of ${RESERVED} and use a gotif to do
what needs to be done based on that value.
JohnM
More information about the asterisk-users
mailing list