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?

Writing an app is easy. Writing about how to write an app is difficult,
mainly because there aren't very many limits on what you can do with
an app.

Quote:

Questions I would have:

When I write my app, how do I link it into Asterisk?

You don't. Asterisk does the linking.

Quote:

Why is attempting to answer the channel important in my app?

It isn't, necessarily. It depends on what your app is doing and with
what type of channel.

Quote:

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?)

It's your lack of C knowledge. "|=" means to bitwise-or the return
value of the right side with the value on the left side. It's an easy
method to ensure that if there's an error, it will be propagated all
the way to the return value. If the return value is already -1 (all
bits set), the compiler may even choose not to execute any more right
sides (short circuit).

Quote:

Once I write it, what's the testing procedure?

Depends upon what the app does.

Quote:

Is there anything else to do other than write app_myapp.c?

No.

Quote:

What other #include files might be useful in writing apps?

Any of them, all of them, or none of them. It depends upon what your
app does.

Quote:

When I test, I get (this common error). How to fix?

I'm not sure there are any common errors.

Quote:

It does seem pretty straight forward.

You could write a book the size of the Sendmail book and still not cover
everything in the detail necessary to teach someone how to write their
own.