[asterisk-doc] How to write new application for Asterisk by using C

Peter Beckman beckman at purplecow.com
Thu Jul 20 09:53:24 MST 2006


On Thu, 20 Jul 2006, Tilghman Lesher wrote:

> On Thursday 20 July 2006 01:38, Thabang Kevin Khanye wrote:
>> Ok, thats touching.. Regarding the application that links to
>> asterisk, I was forwarded to asterisk.org/doxygen, app_skel.c, look
>> there. After you've figured out what that diagram means, please
>> disect it and give us the summarised version.
>
> The diagram is just a dependency graph.  Myself, I usually just look
> at the source code.
>
> Would it be helpful for you to know that when I code a new
> application, I copy an existing application and modify it?  And I'm
> one of the more prolific application authors.  Probably one of the
> simplest applications that actually does something is app_sayunixtime.
> This is because the vast majority of the code that I wrote for it got
> added to say.c because it would be useful elsewhere.  So all of the
> code in app_sayunixtime.c is just parsing arguments and calling a
> common API.
>
> app_skel shows you how to parse more complex application arguments,
> such as options that themselves take an argument, e.g. M(foo).  You
> may or may not need them, but having the simplest case for parsing
> them is probably helpful.

  Would you be willing to post a quick three paragraph about how writing
  your own app is easy, maybe throwing in lines of code to explain what they
  do, where they go and are used, etc?

  Questions I would have:

     When I write my app, how do I link it into Asterisk?
     Why is attempting to answer the channel important in my app?
     For an alias like datetime, why does load and unload use res |= instead
       of res = ?  (OK, this may be my lack of C knowledge -- is it just
       concat?)
     Once I write it, what's the testing procedure?
     Is there anything else to do other than write app_myapp.c?
     What other #include files might be useful in writing apps?
     When I test, I get (this common error).  How to fix?

  It does seem pretty straight forward.

Beckman
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman at purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------


More information about the asterisk-doc mailing list