Introduction
I did this with the application MCC from http://www.kolmisoft.com, and it works flawlessly.
Please follow these simple steps to port your Asterisk application to CallWeaver.
Renaming for use in CallWeaver
Open up your favorite editor and rename all instances of:
ast_ TO opbx_
AST_ TO OPBX_
asterisk to callweaver
Remove the following function completely from your application:
char *key()
{
return ASTERISK_GPL_KEY;
}
Changing to stdarg
Change calls to opbx_register_application to include syntax between synopsis and description and save the return value. If the return value is NULL the register failed.
Change the matching calls to opbx_unregister_application to pass the value returned by opbx_register_application instead of the application name. If opbx_unregister_application returns non-zero it failed. In this case unload_module MUST also return non-zero or the module will be unloaded even though there are still functions registered.
In your handler function replace “char ∗data” with “int argc, char ∗∗argv”, remove any code to split the old data string and simply use argc/argv as you would for a normal C “main()”.
(Note: argv is guaranteed to have a NULL pointer at the end. This is NOT included in the argc count. Preceeding arguments are guaranteed to be non-NULL and point to zero or more characters. The argv pointers DO point to writable space, it is private to your function and you ARE allowed to write into the arguments, e.g. for further parsing. It is NOT necessary to preserve the arguments you are given.)
static void *app_handle;
static const char *app_syntax = "APP(arg1[, arg2[, arg3]])";
...
static int app_exec(struct opbx_channel *chan, int argc, char **argv)
{
if (argc < 1 || argc > 3 || !argv[0][0]) {
opbx_log(LOG_ERROR, "Syntax: %s\n", app_syntax);
return -1;
}
if (argc > 1) {
/* Do something with argv[r1] (arg2) */
}
...
return 0;
}
...
int load_module(void)
{
...
app_handle = opbx_register_application(app_name, app_exec, app_synopsis, app_syntax, app_description);
...
return 0;
}
int unload_module(void)
{
int res = 0;
...
res |= opbx_unregister_application(app_handle);
...
return res;
}
Compiling
Remember to change the Makefile of your application so that it builds against CallWeaver’s includes instead of Asterisk’s. If you see /usr/src/asterisk/include in the Makefile, change it to /usr/src/callweaver/include or the location of your CallWeaver includes.
Now make and install your application and look for any errors or warnings.
If all goes well, you have ported your application to CallWeaver.
![Home wiki [home]](../../images/logo__q__1180520111.png)
RSS Feeds