#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"
Include dependency graph for app_eval.c:
Go to the source code of this file.
Defines | |
#define | MAXRESULT 1024 |
Functions | |
char * | description (void) |
Provides a description of the module. | |
static int | eval_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_eval = "Eval" |
static char * | eval_descrip |
static char * | eval_synopsis = "Evaluates a string" |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | tdesc = "Reevaluates strings" |
Definition in file app_eval.c.
|
Definition at line 43 of file app_eval.c. |
|
Provides a description of the module.
Definition at line 112 of file app_eval.c. 00113 { 00114 return tdesc; 00115 }
|
|
Definition at line 62 of file app_eval.c. References ast_log(), ast_strdupa, localuser::chan, dep_warning, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, LOG_WARNING, MAXRESULT, pbx_builtin_setvar_helper(), pbx_substitute_variables_helper(), s, and strsep(). Referenced by load_module(). 00063 { 00064 int res=0; 00065 struct localuser *u; 00066 char *s, *newvar=NULL, tmp[MAXRESULT]; 00067 static int dep_warning = 0; 00068 00069 LOCAL_USER_ADD(u); 00070 00071 if (!dep_warning) { 00072 ast_log(LOG_WARNING, "This application has been deprecated in favor of the dialplan function, EVAL\n"); 00073 dep_warning = 1; 00074 } 00075 00076 /* Check and parse arguments */ 00077 if (data) { 00078 s = ast_strdupa((char *)data); 00079 if (s) { 00080 newvar = strsep(&s, "="); 00081 if (newvar && (newvar[0] != '\0')) { 00082 memset(tmp, 0, MAXRESULT); 00083 pbx_substitute_variables_helper(chan, s, tmp, MAXRESULT - 1); 00084 pbx_builtin_setvar_helper(chan, newvar, tmp); 00085 } 00086 } else { 00087 ast_log(LOG_ERROR, "Out of memory\n"); 00088 res = -1; 00089 } 00090 } 00091 00092 LOCAL_USER_REMOVE(u); 00093 return res; 00094 }
|
|
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 124 of file app_eval.c. References ASTERISK_GPL_KEY. 00125 { 00126 return ASTERISK_GPL_KEY; 00127 }
|
|
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 107 of file app_eval.c. References ast_register_application(), and eval_exec(). 00108 { 00109 return ast_register_application(app_eval, eval_exec, eval_synopsis, eval_descrip); 00110 }
|
|
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 96 of file app_eval.c. References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS. 00097 { 00098 int res; 00099 00100 res = ast_unregister_application(app_eval); 00101 00102 STANDARD_HANGUP_LOCALUSERS; 00103 00104 return res; 00105 }
|
|
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 117 of file app_eval.c. References STANDARD_USECOUNT. 00118 { 00119 int res; 00120 STANDARD_USECOUNT(res); 00121 return res; 00122 }
|
|
Definition at line 47 of file app_eval.c. |
|
Definition at line 51 of file app_eval.c. |
|
Definition at line 49 of file app_eval.c. |
|
Definition at line 60 of file app_eval.c. |
|
Definition at line 58 of file app_eval.c. |
|
Definition at line 45 of file app_eval.c. |