#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
Go to the source code of this file.
Defines | |
#define | MAXRESULT 1024 |
Functions | |
char * | description (void) |
Provides a description of the module. | |
static int | exec_exec (struct ast_channel *chan, void *data) |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
static char * | app_exec = "Exec" |
static char * | exec_descrip |
static char * | exec_synopsis = "Executes internal application" |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | tdesc = "Executes applications" |
Definition in file app_exec.c.
|
Definition at line 44 of file app_exec.c. |
|
Provides a description of the module.
Definition at line 120 of file app_exec.c. 00121 { 00122 return tdesc; 00123 }
|
|
Definition at line 63 of file app_exec.c. References app, ast_log(), ast_strdupa, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, LOG_WARNING, MAXRESULT, pbx_exec(), pbx_findapp(), pbx_substitute_variables_helper(), s, and strsep(). Referenced by load_module(). 00064 { 00065 int res=0; 00066 struct localuser *u; 00067 char *s, *appname, *endargs, args[MAXRESULT]; 00068 struct ast_app *app; 00069 00070 LOCAL_USER_ADD(u); 00071 00072 memset(args, 0, MAXRESULT); 00073 00074 /* Check and parse arguments */ 00075 if (data) { 00076 s = ast_strdupa((char *)data); 00077 if (s) { 00078 appname = strsep(&s, "("); 00079 if (s) { 00080 endargs = strrchr(s, ')'); 00081 if (endargs) 00082 *endargs = '\0'; 00083 pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1); 00084 } 00085 if (appname) { 00086 app = pbx_findapp(appname); 00087 if (app) { 00088 res = pbx_exec(chan, app, args, 1); 00089 } else { 00090 ast_log(LOG_WARNING, "Could not find application (%s)\n", appname); 00091 res = -1; 00092 } 00093 } 00094 } else { 00095 ast_log(LOG_ERROR, "Out of memory\n"); 00096 res = -1; 00097 } 00098 } 00099 00100 LOCAL_USER_REMOVE(u); 00101 return res; 00102 }
|
|
Returns the ASTERISK_GPL_KEY. This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:
char *key(void) { return ASTERISK_GPL_KEY; }
Definition at line 132 of file app_exec.c. References ASTERISK_GPL_KEY. 00133 { 00134 return ASTERISK_GPL_KEY; 00135 }
|
|
Initialize the module. Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
Definition at line 115 of file app_exec.c. References ast_register_application(), and exec_exec(). 00116 { 00117 return ast_register_application(app_exec, exec_exec, exec_synopsis, exec_descrip); 00118 }
|
|
Cleanup all module structures, sockets, etc. This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).
Definition at line 104 of file app_exec.c. References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS. 00105 { 00106 int res; 00107 00108 res = ast_unregister_application(app_exec); 00109 00110 STANDARD_HANGUP_LOCALUSERS; 00111 00112 return res; 00113 }
|
|
Provides a usecount. This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.
Definition at line 125 of file app_exec.c. References STANDARD_USECOUNT. 00126 { 00127 int res; 00128 STANDARD_USECOUNT(res); 00129 return res; 00130 }
|
|
Definition at line 48 of file app_exec.c. Referenced by load_module(). |
|
Definition at line 52 of file app_exec.c. |
|
Definition at line 50 of file app_exec.c. Referenced by load_module(). |
|
Definition at line 61 of file app_exec.c. |
|
Definition at line 59 of file app_exec.c. |
|
Definition at line 46 of file app_exec.c. |