static int adsi_exec(struct ast_channel *chan, void *data)
{
- int res=0;
- struct ast_module_user *u;
-
- u = ast_module_user_add(chan);
+ int res = 0;
if (ast_strlen_zero(data))
data = "asterisk.adsi";
ast_verbose(VERBOSE_PREFIX_3 "ADSI Available on CPE. Attempting Upload.\n");
res = adsi_prog(chan, data);
}
-
- ast_module_user_remove(u);
return res;
}
static int alarmreceiver_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
event_node_t *elp, *efree;
char signalling_type[64] = "";
event_node_t *event_head = NULL;
- u = ast_module_user_add(chan);
-
/* Set write and read formats to ULAW */
if(option_verbose >= 4)
if (ast_set_write_format(chan,AST_FORMAT_ULAW)){
ast_log(LOG_WARNING, "AlarmReceiver: Unable to set write format to Mu-law on %s\n",chan->name);
- ast_module_user_remove(u);
return -1;
}
if (ast_set_read_format(chan,AST_FORMAT_ULAW)){
ast_log(LOG_WARNING, "AlarmReceiver: Unable to set read format to Mu-law on %s\n",chan->name);
- ast_module_user_remove(u);
return -1;
}
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: Answering channel\n");
if (chan->_state != AST_STATE_UP) {
-
- res = ast_answer(chan);
-
- if (res) {
- ast_module_user_remove(u);
+ if ((res = ast_answer(chan)))
return -1;
- }
}
/* Wait for the connection to settle post-answer */
ast_free(efree);
}
-
- ast_module_user_remove(u);
-
return 0;
}
static int amd_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u = NULL;
-
- u = ast_module_user_add(chan);
isAnsweringMachine(chan, data);
- ast_module_user_remove(u);
return 0;
}
{
int res=0;
int retries;
- struct ast_module_user *u;
char passwd[256];
char *prompt;
int maxdigits;
ast_log(LOG_WARNING, "Authenticate requires an argument(password)\n");
return -1;
}
-
- u = ast_module_user_add(chan);
if (chan->_state != AST_STATE_UP) {
- res = ast_answer(chan);
- if (res) {
- ast_module_user_remove(u);
+ if ((res = ast_answer(chan)))
return -1;
- }
}
argcopy = ast_strdupa(data);
res = ast_waitstream(chan, "");
res = -1;
}
- ast_module_user_remove(u);
+
return res;
}
static int nocdr_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
-
- u = ast_module_user_add(chan);
-
- if (chan->cdr) {
+ if (chan->cdr)
ast_set_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED);
- }
-
- ast_module_user_remove(u);
return 0;
}
{
int res=-1, inuse=-1, option_state=0, string_compare=0;
int status;
- struct ast_module_user *u;
char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur;
struct ast_channel *tempchan;
AST_DECLARE_APP_ARGS(args,
return -1;
}
- u = ast_module_user_add(chan);
-
info = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, info);
number = strchr(tech, '/');
if (!number) {
ast_log(LOG_WARNING, "ChanIsAvail argument takes format ([technology]/[device])\n");
- ast_module_user_remove(u);
return -1;
}
*number = '\0';
pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", "");
}
- ast_module_user_remove(u);
return 0;
}
static int asyncgoto_exec(struct ast_channel *chan, void *data)
{
int res = -1;
- struct ast_module_user *u;
char *info, *context, *exten, *priority;
int prio = 1;
struct ast_channel *chan2 = NULL;
return -1;
}
- u = ast_module_user_add(chan);
-
info = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, info);
chanquit:
ast_mutex_unlock(&chan2->lock);
quit:
- ast_module_user_remove(u);
return res;
}
static int chanspy_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
char *options = NULL;
char *spec = NULL;
char *argv[2];
data = ast_strdupa(data);
- u = ast_module_user_add(chan);
-
if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
spec = argv[0];
if (argc > 1)
oldwf = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
- ast_module_user_remove(u);
return -1;
}
if (oldwf && ast_set_write_format(chan, oldwf) < 0)
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
- ast_module_user_remove(u);
-
return res;
}
static int extenspy_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
char *options = NULL;
char *exten = NULL;
char *context = NULL;
data = ast_strdupa(data);
- u = ast_module_user_add(chan);
-
if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
context = argv[0];
if (!ast_strlen_zero(argv[0]))
oldwf = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
- ast_module_user_remove(u);
return -1;
}
if (oldwf && ast_set_write_format(chan, oldwf) < 0)
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
- ast_module_user_remove(u);
-
return res;
}
int skipms = 0;
long offsetms = 0;
char offsetbuf[20];
- struct ast_module_user *u;
char *tmp;
int argc;
char *argv[8] = { NULL, };
ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n");
return -1;
}
-
- u = ast_module_user_add(chan);
tmp = ast_strdupa(data);
if (argc < 1) {
ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n");
- ast_module_user_remove(u);
return -1;
}
snprintf(offsetbuf, sizeof(offsetbuf), "%ld", offsetms);
pbx_builtin_setvar_helper(chan, "CPLAYBACKOFFSET", offsetbuf);
- ast_module_user_remove(u);
-
return res;
}
static int deltree_exec(struct ast_channel *chan, void *data)
{
char *argv, *family, *keytree;
- struct ast_module_user *u;
-
- u = ast_module_user_add(chan);
argv = ast_strdupa(data);
keytree = strsep(&argv, "\0");
if (!family || !keytree) {
ast_debug(1, "Ignoring; Syntax error in argument\n");
- ast_module_user_remove(u);
return 0;
}
if (ast_strlen_zero(keytree))
ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: Error deleting key from database.\n");
}
- ast_module_user_remove(u);
-
return 0;
}
static int del_exec(struct ast_channel *chan, void *data)
{
char *argv, *family, *key;
- struct ast_module_user *u;
static int deprecation_warning = 0;
- u = ast_module_user_add(chan);
-
if (!deprecation_warning) {
deprecation_warning = 1;
ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n");
key = strsep(&argv, "\0");
if (!family || !key) {
ast_debug(1, "Ignoring; Syntax error in argument\n");
- ast_module_user_remove(u);
return 0;
}
if (option_verbose > 2)
} else {
ast_debug(1, "Ignoring, no parameters\n");
}
-
- ast_module_user_remove(u);
return 0;
}
static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags *peerflags, int *continue_exec)
{
int res = -1; /* default: error */
- struct ast_module_user *u;
char *rest, *cur; /* scan the list of destinations */
struct chanlist *outgoing = NULL; /* list of destinations */
struct ast_channel *peer;
return -1;
}
- u = ast_module_user_add(chan); /* XXX is this the right place ? */
-
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
}
done:
- ast_module_user_remove(u); /* XXX probably not the right place for this. */
return res;
}
char *announce = NULL, *dialdata = NULL;
const char *context = NULL;
int sleep = 0, loops = 0, res = -1;
- struct ast_module_user *u;
struct ast_flags peerflags;
if (ast_strlen_zero(data)) {
return -1;
}
- u = ast_module_user_add(chan);
-
announce = ast_strdupa(data);
memset(&peerflags, 0, sizeof(peerflags));
if (ast_test_flag(chan, AST_FLAG_MOH))
ast_moh_stop(chan);
done:
- ast_module_user_remove(u);
return res;
}
res = ast_unregister_application(app);
res |= ast_unregister_application(rapp);
- if ((con = ast_context_find("app_dial_gosub_virtual_context"))) {
+ if ((con = ast_context_find("app_dial_gosub_virtual_context")))
ast_context_remove_extension2(con, "s", 1, NULL);
- }
return res;
}
struct ast_flags flags = {0};
struct ast_filestream *fs;
struct ast_frame *f = NULL;
- struct ast_module_user *u;
int ffactor = 320 * 80,
res = 0,
done = 0,
len = 0,
maxlen = 0,
mode = 0;
-
- u = ast_module_user_add(chan);
snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
if (!ast_strlen_zero(data)) {
oldr = chan->readformat;
if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
- ast_module_user_remove(u);
return -1;
}
if (oldr) {
ast_set_read_format(chan, oldr);
}
- ast_module_user_remove(u);
return 0;
}
static int pickup_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u = NULL;
char *tmp = ast_strdupa(data);
char *exten = NULL, *context = NULL;
ast_log(LOG_WARNING, "Pickup requires an argument (extension)!\n");
return -1;
}
-
- u = ast_module_user_add(chan);
/* Parse extension (and context if there) */
while (!ast_strlen_zero(tmp) && (exten = strsep(&tmp, "&"))) {
ast_log(LOG_NOTICE, "No target channel found for %s.\n", exten);
}
- ast_module_user_remove(u);
-
return res;
}
static int directory_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
struct ast_config *cfg, *ucfg;
int last = 1;
int readext = 0;
return -1;
}
- u = ast_module_user_add(chan);
-
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
cfg = realtime_directory(args.vmcontext);
if (!cfg) {
ast_log(LOG_ERROR, "Unable to read the configuration data!\n");
- ast_module_user_remove(u);
return -1;
}
if (ucfg)
ast_config_destroy(ucfg);
ast_config_destroy(cfg);
- ast_module_user_remove(u);
return res;
}
int i,j,k,x,did_ignore,special_noanswer;
int firstdigittimeout = 20000;
int digittimeout = 10000;
- struct ast_module_user *u;
struct ast_flags flags;
char *tmp, exten[AST_MAX_EXTENSION],acctcode[20]="";
char pwline[256];
ast_log(LOG_WARNING, "DISA requires an argument (passcode/passcode file)\n");
return -1;
}
-
- u = ast_module_user_add(chan);
if (chan->pbx) {
firstdigittimeout = chan->pbx->rtimeout*1000;
if (ast_set_write_format(chan,AST_FORMAT_ULAW)) {
ast_log(LOG_WARNING, "Unable to set write format to Mu-law on %s\n", chan->name);
- ast_module_user_remove(u);
return -1;
}
if (ast_set_read_format(chan,AST_FORMAT_ULAW)) {
ast_log(LOG_WARNING, "Unable to set read format to Mu-law on %s\n", chan->name);
- ast_module_user_remove(u);
return -1;
}
f = ast_read(chan);
if (f == NULL) {
- ast_module_user_remove(u);
return -1;
}
if ((f->frametype == AST_FRAME_CONTROL) &&
(f->subclass == AST_CONTROL_HANGUP)) {
ast_frfree(f);
- ast_module_user_remove(u);
return -1;
}
if (f->frametype == AST_FRAME_VOICE) {
fp = fopen(args.passcode,"r");
if (!fp) {
ast_log(LOG_WARNING,"DISA password file %s not found on chan %s\n",args.passcode,chan->name);
- ast_module_user_remove(u);
return -1;
}
pwline[0] = 0;
if (special_noanswer) flags.flags = 0;
ast_cdr_reset(chan->cdr, &flags);
ast_explicit_goto(chan, args.context, exten, 1);
- ast_module_user_remove(u);
return 0;
}
}
ast_frfree(f);
}
ast_playtones_stop(chan);
- ast_module_user_remove(u);
return -1;
}
static int dumpchan_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
struct ast_str *vars = ast_str_alloca(BUFSIZ * 4); /* XXX very large! */
char info[1024];
int level = 0;
static char *line = "================================================================================";
- u = ast_module_user_add(chan);
-
if (!ast_strlen_zero(data))
level = atoi(data);
serialize_showchan(chan, info, sizeof(info));
if (option_verbose >= level)
ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, vars->str, line);
-
- ast_module_user_remove(u);
return 0;
}
{
int res = -1;
int format;
- struct ast_module_user *u;
-
- u = ast_module_user_add(chan);
format = ast_best_codec(chan->nativeformats);
ast_set_write_format(chan, format);
ast_frfree(f);
}
end:
- ast_module_user_remove(u);
return res;
}
static int exec_exec(struct ast_channel *chan, void *data)
{
- int res=0;
- struct ast_module_user *u;
+ int res = 0;
char *s, *appname, *endargs, args[MAXRESULT] = "";
struct ast_app *app;
if (ast_strlen_zero(data))
return 0;
-
- u = ast_module_user_add(chan);
s = ast_strdupa(data);
appname = strsep(&s, "(");
}
}
- ast_module_user_remove(u);
-
return res;
}
static int tryexec_exec(struct ast_channel *chan, void *data)
{
- int res=0;
- struct ast_module_user *u;
+ int res = 0;
char *s, *appname, *endargs, args[MAXRESULT] = "";
struct ast_app *app;
if (ast_strlen_zero(data))
return 0;
- u = ast_module_user_add(chan);
-
s = ast_strdupa(data);
appname = strsep(&s, "(");
if (s) {
}
}
- ast_module_user_remove(u);
-
return 0;
}
static int execif_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *myapp = NULL;
char *mydata = NULL;
char *expr = NULL;
struct ast_app *app = NULL;
- u = ast_module_user_add(chan);
-
expr = ast_strdupa(data);
if ((myapp = strchr(expr,'|'))) {
ast_log(LOG_ERROR,"Invalid Syntax.\n");
res = -1;
}
-
- ast_module_user_remove(u);
return res;
}
static int app_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *lu;
struct playlist_entry *entry;
const char *args = data;
int child_stdin[2] = { 0,0 };
struct ivr_localuser *u = &foo;
sigset_t fullset, oldset;
- lu = ast_module_user_add(chan);
-
sigfillset(&fullset);
pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
if (ast_strlen_zero(args)) {
ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n");
- ast_module_user_remove(lu);
return -1;
}
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list)))
ast_free(entry);
- ast_module_user_remove(lu);
-
return res;
}
{
int usecache;
int res=0;
- struct ast_module_user *u;
struct sockaddr_in serv_addr;
struct hostent *serverhost;
struct ast_hostent ahp;
return -1;
}
- u = ast_module_user_add(chan);
-
cfg = ast_config_load(FESTIVAL_CONFIG);
if (!cfg) {
ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
- ast_module_user_remove(u);
return -1;
}
if (!(host = ast_variable_retrieve(cfg, "general", "host"))) {
if (fd < 0) {
ast_log(LOG_WARNING,"festival_client: can't get socket\n");
ast_config_destroy(cfg);
- ast_module_user_remove(u);
return -1;
}
if (serverhost == (struct hostent *)0) {
ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
ast_config_destroy(cfg);
- ast_module_user_remove(u);
return -1;
}
memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) {
ast_log(LOG_WARNING,"festival_client: connect to server failed\n");
ast_config_destroy(cfg);
- ast_module_user_remove(u);
return -1;
}
ast_log(LOG_WARNING,"Unable to read from cache/festival fd\n");
close(fd);
ast_config_destroy(cfg);
- ast_module_user_remove(u);
return -1;
}
n += read_data;
} while (strcmp(ack,"OK\n") != 0);
close(fd);
ast_config_destroy(cfg);
- ast_module_user_remove(u);
return res;
}
{
int res = -1;
int x;
- struct ast_module_user *u;
struct zt_params ztp;
if (strcasecmp(chan->tech->type, "Zap")) {
ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
return -1;
}
-
- u = ast_module_user_add(chan);
memset(&ztp, 0, sizeof(ztp));
res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
} else
ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
- ast_module_user_remove(u);
-
return res;
}
struct call_followme *f;
struct number *nm, *newnm;
int res = 0;
- struct ast_module_user *u;
char *argstr;
char namerecloc[255];
int duration = 0;
return -1;
}
- u = ast_module_user_add(chan);
-
AST_STANDARD_APP_ARGS(args, argstr);
if (!ast_strlen_zero(args.followmeid))
}
outrun:
- ast_module_user_remove(u);
-
return res;
}
static int forkcdr_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
if (!chan->cdr) {
ast_log(LOG_WARNING, "Channel does not have a CDR\n");
return 0;
}
- u = ast_module_user_add(chan);
-
if (!ast_strlen_zero(data))
ast_set2_flag(chan->cdr, strchr(data, 'v'), AST_CDR_FLAG_KEEP_VARS);
ast_cdr_fork(chan);
- ast_module_user_remove(u);
return res;
}
static int cpeid_exec(struct ast_channel *chan, void *idata)
{
int res=0;
- struct ast_module_user *u;
unsigned char cpeid[4];
int gotgeometry = 0;
int gotcpeid = 0;
char *data[4];
unsigned int x;
- u = ast_module_user_add(chan);
-
for (x = 0; x < 4; x++)
data[x] = alloca(80);
ast_adsi_unload_session(chan);
}
}
- ast_module_user_remove(u);
+
return res;
}
static int ices_exec(struct ast_channel *chan, void *data)
{
- int res=0;
- struct ast_module_user *u;
+ int res = 0;
int fds[2];
int ms = -1;
int pid = -1;
ast_log(LOG_WARNING, "ICES requires an argument (configfile.xml)\n");
return -1;
}
-
- u = ast_module_user_add(chan);
last = ast_tv(0, 0);
if (pipe(fds)) {
ast_log(LOG_WARNING, "Unable to create pipe\n");
- ast_module_user_remove(u);
return -1;
}
flags = fcntl(fds[1], F_GETFL);
close(fds[0]);
close(fds[1]);
ast_log(LOG_WARNING, "Answer failed!\n");
- ast_module_user_remove(u);
return -1;
}
close(fds[0]);
close(fds[1]);
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
- ast_module_user_remove(u);
return -1;
}
if (((char *)data)[0] == '/')
if (!res && oreadformat)
ast_set_read_format(chan, oreadformat);
- ast_module_user_remove(u);
-
return res;
}
static int sendimage_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *parse;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
AST_APP_ARG(options);
);
- u = ast_module_user_add(chan);
-
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (!ast_supports_images(chan)) {
/* Does not support transport */
pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
- ast_module_user_remove(u);
return 0;
}
if (!(res = ast_send_image(chan, args.filename)))
pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
-
- ast_module_user_remove(u);
-
+
return res;
}
static int skel_exec(struct ast_channel *chan, void *data)
{
int res=0;
- struct ast_module_user *u;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
return -1;
}
- u = ast_module_user_add(chan);
-
/* Do our thing here */
if (chan->_state != AST_STATE_UP)
if (!res)
res = ast_ivr_menu_run(chan, &ivr_demo, data);
- ast_module_user_remove(u);
-
return res;
}
char *save_macro_context;
char *save_macro_priority;
char *save_macro_offset;
- struct ast_module_user *u;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Macro() requires arguments. See \"show application macro\" for help.\n");
return -1;
}
- u = ast_module_user_add(chan);
-
/* does the user want a deeper rabbit hole? */
s = pbx_builtin_getvar_helper(chan, "MACRO_RECURSION");
if (s)
if (depth >= maxdepth) {
ast_log(LOG_ERROR, "Macro(): possible infinite loop detected. Returning early.\n");
- ast_module_user_remove(u);
return 0;
}
snprintf(depthc, sizeof(depthc), "%d", depth + 1);
macro = strsep(&rest, "|");
if (ast_strlen_zero(macro)) {
ast_log(LOG_WARNING, "Invalid macro name specified\n");
- ast_module_user_remove(u);
return 0;
}
ast_log(LOG_WARNING, "No such context '%s' for macro '%s'\n", fullmacro, macro);
else
ast_log(LOG_WARNING, "Context '%s' for macro '%s' lacks 's' extension, priority 1\n", fullmacro, macro);
- ast_module_user_remove(u);
return 0;
}
if (ast_context_lockmacro(fullmacro)) {
ast_log(LOG_WARNING, "Failed to lock macro '%s' as in-use\n", fullmacro);
ast_autoservice_stop(chan);
- ast_module_user_remove(u);
-
return 0;
}
ast_autoservice_stop(chan);
res = 0;
}
}
-
- ast_module_user_remove(u);
return res;
}
{
char *expr = NULL, *label_a = NULL, *label_b = NULL;
int res = 0;
- struct ast_module_user *u;
- u = ast_module_user_add(chan);
-
- if (!(expr = ast_strdupa(data))) {
- ast_module_user_remove(u);
+ if (!(expr = ast_strdupa(data)))
return -1;
- }
if ((label_a = strchr(expr, '?'))) {
*label_a = '\0';
} else
ast_log(LOG_WARNING, "Invalid Syntax.\n");
- ast_module_user_remove(u);
-
return res;
}
/*! \brief The MeetmeCount application */
static int count_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
int res = 0;
struct ast_conference *conf;
int count;
ast_log(LOG_WARNING, "MeetMeCount requires an argument (conference number)\n");
return -1;
}
-
- u = ast_module_user_add(chan);
- if (!(localdata = ast_strdupa(data))) {
- ast_module_user_remove(u);
+ if (!(localdata = ast_strdupa(data)))
return -1;
- }
AST_STANDARD_APP_ARGS(args, localdata);
ast_answer(chan);
res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */
}
- ast_module_user_remove(u);
return res;
}
static int conf_exec(struct ast_channel *chan, void *data)
{
int res=-1;
- struct ast_module_user *u;
char confno[MAX_CONFNUM] = "";
int allowretry = 0;
int retrycnt = 0;
);
char *optargs[OPT_ARG_ARRAY_SIZE] = { NULL, };
- u = ast_module_user_add(chan);
-
if (ast_strlen_zero(data)) {
allowretry = 1;
notdata = "";
if (cnf)
dispose_conf(cnf);
-
- ast_module_user_remove(u);
return res;
}
char *params;
struct ast_conference *cnf;
struct ast_conf_user *user = NULL;
- struct ast_module_user *u;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(confno);
AST_APP_ARG(command);
return -1;
}
- u = ast_module_user_add(chan);
-
params = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, params);
if (!args.command) {
ast_log(LOG_WARNING, "MeetmeAdmin requires a command!\n");
- ast_module_user_remove(u);
return -1;
}
if (!cnf) {
ast_log(LOG_WARNING, "Conference number '%s' not found!\n", args.confno);
AST_LIST_UNLOCK(&confs);
- ast_module_user_remove(u);
return 0;
}
AST_LIST_UNLOCK(&confs);
dispose_conf(cnf);
-
- ast_module_user_remove(u);
return 0;
}
char *params;
struct ast_conference *conf = NULL;
struct ast_conf_user *user = NULL;
- struct ast_module_user *u;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(channel);
AST_APP_ARG(command);
return -1;
}
- u = ast_module_user_add(chan);
-
params = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, params);
if (!args.channel) {
ast_log(LOG_WARNING, "MeetMeChannelAdmin requires a channel name!\n");
- ast_module_user_remove(u);
return -1;
}
if (!args.command) {
ast_log(LOG_WARNING, "MeetMeChannelAdmin requires a command!\n");
- ast_module_user_remove(u);
return -1;
}
if (!user) {
ast_log(LOG_NOTICE, "Specified user (%s) not found\n", args.channel);
AST_LIST_UNLOCK(&confs);
- ast_module_user_remove(u);
return 0;
}
}
AST_LIST_UNLOCK(&confs);
-
- ast_module_user_remove(u);
return 0;
}
static int milliwatt_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
- u = ast_module_user_add(chan);
-
ast_set_write_format(chan, AST_FORMAT_ULAW);
ast_set_read_format(chan, AST_FORMAT_ULAW);
if (ast_activate_generator(chan,&milliwattgen,"milliwatt") < 0) {
ast_log(LOG_WARNING,"Failed to activate generator on '%s'\n",chan->name);
- ast_module_user_remove(u);
return -1;
}
ast_deactivate_generator(chan);
- ast_module_user_remove(u);
-
return -1;
}
/*! \brief Notify voicemail account owners - either generic template or user specific */
static int minivm_notify_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
int argc;
char *argv[2];
int res = 0;
const char *format;
const char *duration_string;
- u = ast_module_user_add(chan);
-
-
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Minivm needs at least an account argument \n");
- ast_module_user_remove(u);
return -1;
}
tmpptr = ast_strdupa((char *)data);
if (!tmpptr) {
ast_log(LOG_ERROR, "Out of memory\n");
- ast_module_user_remove(u);
return -1;
}
argc = ast_app_separate_args(tmpptr, '|', argv, sizeof(argv) / sizeof(argv[0]));
}
if (ast_strlen_zero(domain) || ast_strlen_zero(username)) {
ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument 0 %s\n", argv[0]);
- ast_module_user_remove(u);
return -1;
}
/* We could not find user, let's exit */
ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain);
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", "FAILED");
- ast_module_user_remove(u);
return -1;
}
free_user(vmu);
/* Ok, we're ready to rock and roll. Return to dialplan */
- ast_module_user_remove(u);
return res;
static int minivm_record_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *tmp;
struct leave_vm_options leave_options;
int argc;
char *argv[2];
struct ast_flags flags = { 0 };
char *opts[OPT_ARG_ARRAY_SIZE];
-
- u = ast_module_user_add(chan);
-
+
memset(&leave_options, 0, sizeof(leave_options));
/* Answer channel if it's not already answered */
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Minivm needs at least an account argument \n");
- ast_module_user_remove(u);
return -1;
}
tmp = ast_strdupa((char *)data);
if (!tmp) {
ast_log(LOG_ERROR, "Out of memory\n");
- ast_module_user_remove(u);
return -1;
}
argc = ast_app_separate_args(tmp, '|', argv, sizeof(argv) / sizeof(argv[0]));
if (argc == 2) {
if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) {
- ast_module_user_remove(u);
return -1;
}
ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING );
if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
- ast_module_user_remove(u);
return -1;
} else
leave_options.record_gain = (signed char) gain;
}
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "SUCCESS");
-
- ast_module_user_remove(u);
-
return res;
}
/*! \brief Play voicemail prompts - either generic or user specific */
static int minivm_greet_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
struct leave_vm_options leave_options = { 0, '\0'};
int argc;
char *argv[2];
char *tmpptr;
struct minivm_account *vmu;
char *username = argv[0];
-
- u = ast_module_user_add(chan);
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Minivm needs at least an account argument \n");
- ast_module_user_remove(u);
return -1;
}
tmpptr = ast_strdupa((char *)data);
if (!tmpptr) {
ast_log(LOG_ERROR, "Out of memory\n");
- ast_module_user_remove(u);
return -1;
}
argc = ast_app_separate_args(tmpptr, '|', argv, sizeof(argv) / sizeof(argv[0]));
if (argc == 2) {
- if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) {
- ast_module_user_remove(u);
+ if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1]))
return -1;
- }
ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING );
}
}
if (ast_strlen_zero(domain) || ast_strlen_zero(username)) {
ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument: %s\n", argv[0]);
- ast_module_user_remove(u);
return -1;
}
ast_debug(1, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain);
if (!(vmu = find_account(domain, username, TRUE))) {
ast_log(LOG_ERROR, "Could not allocate memory. \n");
- ast_module_user_remove(u);
return -1;
}
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu);
- ast_module_user_remove(u);
return -1;
}
if (res == '#') {
/* Ok, we're ready to rock and roll. Return to dialplan */
- ast_module_user_remove(u);
-
return res;
}
static int minivm_delete_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char filename[BUFSIZ];
-
- u = ast_module_user_add(chan);
-
+
if (!ast_strlen_zero(data))
ast_copy_string(filename, (char *) data, sizeof(filename));
else
ast_copy_string(filename, pbx_builtin_getvar_helper(chan, "MVM_FILENAME"), sizeof(filename));
if (ast_strlen_zero(filename)) {
- ast_module_user_remove(u);
ast_log(LOG_ERROR, "No filename given in application arguments or channel variable MVM_FILENAME\n");
return res;
}
ast_debug(2, "-_-_- Filename does not exist: %s\n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED");
}
-
- ast_module_user_remove(u);
return res;
}
/*! \brief Record specific messages for voicemail account */
static int minivm_accmess_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
int argc = 0;
char *argv[2];
int res = 0;
char *prompt = NULL;
int duration;
int cmd;
-
- u = ast_module_user_add(chan);
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "MinivmAccmess needs at least two arguments: account and option\n");
error = TRUE;
}
- if (error) {
- ast_module_user_remove(u);
+ if (error)
return -1;
- }
ast_copy_string(tmp, argv[0], sizeof(tmp));
username = tmp;
}
if (ast_strlen_zero(domain) || ast_strlen_zero(username)) {
ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument 0 %s\n", argv[0]);
- ast_module_user_remove(u);
return -1;
}
/* We could not find user, let's exit */
ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain);
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", "FAILED");
- ast_module_user_remove(u);
return -1;
}
/* Ok, we're ready to rock and roll. Return to dialplan */
- ast_module_user_remove(u);
-
return res;
}
static int mixmonitor_exec(struct ast_channel *chan, void *data)
{
int x, readvol = 0, writevol = 0;
- struct ast_module_user *u;
struct ast_flags flags = {0};
char *parse, *tmp, *slash;
AST_DECLARE_APP_ARGS(args,
return -1;
}
- u = ast_module_user_add(chan);
-
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.filename)) {
ast_log(LOG_WARNING, "MixMonitor requires an argument (filename)\n");
- ast_module_user_remove(u);
return -1;
}
pbx_builtin_setvar_helper(chan, "MIXMONITOR_FILENAME", args.filename);
launch_monitor_thread(chan, args.filename, flags.flags, readvol, writevol, args.post_process);
- ast_module_user_remove(u);
-
return 0;
}
static int stop_mixmonitor_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
-
- u = ast_module_user_add(chan);
-
ast_channel_lock(chan);
ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
ast_channel_unlock(chan);
-
- ast_module_user_remove(u);
-
return 0;
}
int res=0, ditlen, tone;
char *digit;
const char *ditlenc, *tonec;
- struct ast_module_user *u;
-
- u = ast_module_user_add(chan);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: Morsecode(<string>) - no argument found\n");
- ast_module_user_remove(u);
return 0;
}
playtone(chan, 0, 2 * ditlen);
}
- ast_module_user_remove(u);
return res;
}
static int mp3_exec(struct ast_channel *chan, void *data)
{
int res=0;
- struct ast_module_user *u;
int fds[2];
int ms = -1;
int pid = -1;
return -1;
}
- u = ast_module_user_add(chan);
-
if (pipe(fds)) {
ast_log(LOG_WARNING, "Unable to create pipe\n");
- ast_module_user_remove(u);
return -1;
}
res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
- ast_module_user_remove(u);
return -1;
}
kill(pid, SIGKILL);
if (!res && owriteformat)
ast_set_write_format(chan, owriteformat);
-
- ast_module_user_remove(u);
return res;
}
static int NBScat_exec(struct ast_channel *chan, void *data)
{
int res=0;
- struct ast_module_user *u;
int fds[2];
int ms = -1;
int pid = -1;
short frdata[160];
} myf;
- u = ast_module_user_add(chan);
-
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds)) {
ast_log(LOG_WARNING, "Unable to create socketpair\n");
- ast_module_user_remove(u);
return -1;
}
res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
- ast_module_user_remove(u);
return -1;
}
if (!res && owriteformat)
ast_set_write_format(chan, owriteformat);
- ast_module_user_remove(u);
-
return res;
}
void* data)
{
int res;
- struct ast_module_user* u;
const char* provider = OSP_DEF_PROVIDER;
struct varshead* headp;
struct ast_var_t* current;
AST_APP_ARG(options);
);
- u = ast_module_user_add(chan);
-
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
- ast_module_user_remove(u);
return -1;
}
res = 0;
}
- ast_module_user_remove(u);
-
return res;
}
void* data)
{
int res, cres;
- struct ast_module_user* u;
const char* provider = OSP_DEF_PROVIDER;
struct varshead* headp;
struct ast_var_t* current;
return -1;
}
- u = ast_module_user_add(chan);
-
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
- ast_module_user_remove(u);
return -1;
}
ast_debug(1, "OSPLookup: source device '%s'\n", srcdev);
if ((cres = ast_autoservice_start(chan)) < 0) {
- ast_module_user_remove(u);
return -1;
}
}
if ((cres = ast_autoservice_stop(chan)) < 0) {
- ast_module_user_remove(u);
return -1;
}
res = 0;
}
- ast_module_user_remove(u);
-
return res;
}
void* data)
{
int res;
- struct ast_module_user* u;
const char* provider = OSP_DEF_PROVIDER;
int cause = 0;
struct varshead* headp;
return -1;
}
- u = ast_module_user_add(chan);
-
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
- ast_module_user_remove(u);
return -1;
}
res = 0;
}
- ast_module_user_remove(u);
-
return res;
}
void* data)
{
int res = 1;
- struct ast_module_user* u;
int cause = 0;
struct varshead* headp;
struct ast_var_t* current;
AST_APP_ARG(options);
);
- u = ast_module_user_add(chan);
-
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
- ast_module_user_remove(u);
return -1;
}
res = 0;
}
- ast_module_user_remove(u);
-
return res;
}
static int page_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
char *options, *tech, *resource, *tmp;
char meetmeopts[88], originator[AST_CHANNEL_NAME];
struct ast_flags flags = { 0 };
return -1;
}
- u = ast_module_user_add(chan);
-
if (!(app = pbx_findapp("MeetMe"))) {
ast_log(LOG_WARNING, "There is no MeetMe application available!\n");
- ast_module_user_remove(u);
return -1;
};
ast_dial_destroy(dial);
}
- ast_module_user_remove(u);
-
return -1;
}
struct outgoing_helper oh;
int outstate;
- struct ast_module_user *u;
-
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
return -1;
}
- u = ast_module_user_add(chan);
-
s = ast_strdupa(data);
template=strsep(&s,"|");
if(! template) {
ast_log(LOG_WARNING, "PARK: An announce template must be defined\n");
- ast_module_user_remove(u);
return -1;
}
dial=strsep(&s, "|");
if(!dial) {
ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or Zap/g1/5551212\n");
- ast_module_user_remove(u);
return -1;
} else {
dialtech=strsep(&dial, "/");
}
if(atoi(priority) < 0) {
ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority);
- ast_module_user_remove(u);
return -1;
}
/* At this point we have a priority and maybe an extension and a context */
ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", dchan->name);
ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name);
ast_hangup(dchan);
- ast_module_user_remove(u);
return -1;
}
} else {
ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
- ast_module_user_remove(u);
return -1;
}
ast_stopstream(dchan);
ast_hangup(dchan);
- ast_module_user_remove(u);
-
return res;
}
{
int res = 0;
int mres = 0;
- struct ast_module_user *u;
char *tmp;
int option_skip=0;
int option_say=0;
}
tmp = ast_strdupa(data);
-
- u = ast_module_user_add(chan);
AST_STANDARD_APP_ARGS(args, tmp);
if (args.options) {
}
done:
pbx_builtin_setvar_helper(chan, "PLAYBACKSTATUS", mres ? "FAILED" : "SUCCESS");
- ast_module_user_remove(u);
return res;
}
int x = 0;
const char *s;
char phone[30];
- struct ast_module_user *u;
struct ast_config *cfg = NULL;
char *parse = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(options);
);
- u = ast_module_user_add(chan);
-
if (!ast_strlen_zero(chan->cid.cid_num)) {
if (option_verbose > 2)
ast_verbose (VERBOSE_PREFIX_3 "CallerID Present: Skipping\n");
} else {
/*Answer the channel if it is not already*/
if (chan->_state != AST_STATE_UP) {
- res = ast_answer(chan);
- if (res) {
- ast_module_user_remove(u);
+ if ((res = ast_answer(chan)))
return -1;
- }
}
if (!ast_strlen_zero(data)) {
ast_config_destroy(cfg);
}
- ast_module_user_remove(u);
-
return 0;
}
static int pqm_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *lu;
char *parse;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename);
AST_STANDARD_APP_ARGS(args, parse);
- lu = ast_module_user_add(chan);
-
- if (args.options) {
- }
-
if (ast_strlen_zero(args.interface)) {
ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename]|interface[|options])\n");
- ast_module_user_remove(lu);
return -1;
}
if (set_member_paused(args.queuename, args.interface, 1)) {
ast_log(LOG_WARNING, "Attempt to pause interface %s, not found\n", args.interface);
- ast_module_user_remove(lu);
pbx_builtin_setvar_helper(chan, "PQMSTATUS", "NOTFOUND");
return -1;
}
- ast_module_user_remove(lu);
pbx_builtin_setvar_helper(chan, "PQMSTATUS", "PAUSED");
return 0;
static int upqm_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *lu;
char *parse;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename);
AST_STANDARD_APP_ARGS(args, parse);
- lu = ast_module_user_add(chan);
-
- if (args.options) {
- }
-
if (ast_strlen_zero(args.interface)) {
ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename]|interface[|options])\n");
- ast_module_user_remove(lu);
return -1;
}
if (set_member_paused(args.queuename, args.interface, 0)) {
ast_log(LOG_WARNING, "Attempt to unpause interface %s, not found\n", args.interface);
- ast_module_user_remove(lu);
pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "NOTFOUND");
return -1;
}
- ast_module_user_remove(lu);
pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "UNPAUSED");
return 0;
static int rqm_exec(struct ast_channel *chan, void *data)
{
int res=-1;
- struct ast_module_user *lu;
char *parse, *temppos = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename);
AST_STANDARD_APP_ARGS(args, parse);
- lu = ast_module_user_add(chan);
-
if (ast_strlen_zero(args.interface)) {
args.interface = ast_strdupa(chan->name);
temppos = strrchr(args.interface, '-');
*temppos = '\0';
}
- if (args.options) {
- }
-
switch (remove_from_queue(args.queuename, args.interface)) {
case RES_OKAY:
ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", "");
break;
}
- ast_module_user_remove(lu);
-
return res;
}
static int aqm_exec(struct ast_channel *chan, void *data)
{
int res=-1;
- struct ast_module_user *lu;
char *parse, *temppos = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename);
AST_STANDARD_APP_ARGS(args, parse);
- lu = ast_module_user_add(chan);
-
if (ast_strlen_zero(args.interface)) {
args.interface = ast_strdupa(chan->name);
temppos = strrchr(args.interface, '-');
penalty = 0;
}
}
-
- if (args.options) {
- }
if (ast_strlen_zero(args.membername))
args.membername = args.interface;
break;
}
- ast_module_user_remove(lu);
-
return res;
}
static int ql_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
char *parse;
AST_DECLARE_APP_ARGS(args,
return -1;
}
- u = ast_module_user_add(chan);
-
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.queuename) || ast_strlen_zero(args.uniqueid)
|| ast_strlen_zero(args.membername) || ast_strlen_zero(args.event)) {
ast_log(LOG_WARNING, "QueueLog requires arguments (queuename|uniqueid|membername|event[|additionalinfo])\n");
- ast_module_user_remove(u);
return -1;
}
ast_queue_log(args.queuename, args.uniqueid, args.membername, args.event,
"%s", args.params ? args.params : "");
- ast_module_user_remove(u);
-
return 0;
}
{
int res=-1;
int ringing=0;
- struct ast_module_user *lu;
const char *user_priority;
const char *max_penalty_str;
int prio;
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
- lu = ast_module_user_add(chan);
-
/* Setup our queue entry */
memset(&qe, 0, sizeof(qe));
qe.start = time(NULL);
set_queue_result(chan, reason);
res = 0;
}
- ast_module_user_remove(lu);
return res;
}
{
int res = -1;
struct call_queue *q;
- struct ast_module_user *lu;
char interfacevar[256]="";
float sl = 0;
ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd);
return -1;
}
-
- lu = ast_module_user_add(chan);
AST_LIST_LOCK(&queues);
AST_LIST_TRAVERSE(&queues, q, list) {
ast_log(LOG_WARNING, "queue %s was not found\n", data);
snprintf(buf, len, "%d", res);
- ast_module_user_remove(lu);
return 0;
}
{
int count = 0;
struct call_queue *q;
- struct ast_module_user *lu;
struct member *m;
buf[0] = '\0';
ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd);
return -1;
}
-
- lu = ast_module_user_add(chan);
AST_LIST_LOCK(&queues);
AST_LIST_TRAVERSE(&queues, q, list) {
ast_log(LOG_WARNING, "queue %s was not found\n", data);
snprintf(buf, len, "%d", count);
- ast_module_user_remove(lu);
return 0;
}
{
int count = 0;
struct call_queue *q;
- struct ast_module_user *lu;
buf[0] = '\0';
ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd);
return -1;
}
-
- lu = ast_module_user_add(chan);
AST_LIST_LOCK(&queues);
AST_LIST_TRAVERSE(&queues, q, list) {
ast_log(LOG_WARNING, "queue %s was not found\n", data);
snprintf(buf, len, "%d", count);
- ast_module_user_remove(lu);
+
return 0;
}
static int queue_function_queuememberlist(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- struct ast_module_user *u;
struct call_queue *q;
struct member *m;
ast_log(LOG_ERROR, "QUEUE_MEMBER_LIST requires an argument: queuename\n");
return -1;
}
-
- u = ast_module_user_add(chan);
AST_LIST_LOCK(&queues);
AST_LIST_TRAVERSE(&queues, q, list) {
/* We should already be terminated, but let's make sure. */
buf[len - 1] = '\0';
- ast_module_user_remove(u);
return 0;
}
static int read_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char tmp[256] = "";
int maxdigits = 255;
int tries = 1, to = 0, x = 0;
ast_log(LOG_WARNING, "Read requires an argument (variable)\n");
return -1;
}
-
- u = ast_module_user_add(chan);
argcopy = ast_strdupa(data);
}
if (ast_strlen_zero(arglist.variable)) {
ast_log(LOG_WARNING, "Invalid! Usage: Read(variable[|filename][|maxdigits][|option][|attempts][|timeout])\n\n");
- ast_module_user_remove(u);
return -1;
}
ts=NULL;
if (ast_test_flag(&flags,OPT_SKIP)) {
/* At the user's option, skip if the line is not up */
pbx_builtin_setvar_helper(chan, arglist.variable, "\0");
- ast_module_user_remove(u);
return 0;
} else if (!ast_test_flag(&flags,OPT_NOANSWER)) {
/* Otherwise answer unless we're supposed to read while on-hook */
}
}
}
- ast_module_user_remove(u);
+
return res;
}
static int readfile_exec(struct ast_channel *chan, void *data)
{
int res=0;
- struct ast_module_user *u;
char *s, *varname=NULL, *file=NULL, *length=NULL, *returnvar=NULL;
int len=0;
return -1;
}
- u = ast_module_user_add(chan);
-
s = ast_strdupa(data);
varname = strsep(&s, "=");
if (!varname || !file) {
ast_log(LOG_ERROR, "No file or variable specified!\n");
- ast_module_user_remove(u);
return -1;
}
pbx_builtin_setvar_helper(chan, varname, returnvar);
ast_free(returnvar);
}
- ast_module_user_remove(u);
+
return res;
}
char tmp[256];
struct ast_filestream *s = '\0';
- struct ast_module_user *u;
struct ast_frame *f = NULL;
struct ast_dsp *sildet = NULL; /* silence detector dsp */
return -1;
}
- u = ast_module_user_add(chan);
-
/* Yay for strsep being easy */
vdata = ast_strdupa(data);
}
if (!ext) {
ast_log(LOG_WARNING, "No extension specified to filename!\n");
- ast_module_user_remove(u);
return -1;
}
if (silstr) {
if (chan->_state != AST_STATE_UP) {
if (option_skip) {
/* At the user's option, skip if the line is not up */
- ast_module_user_remove(u);
return 0;
} else if (!option_noanswer) {
/* Otherwise answer unless we're supposed to record while on-hook */
res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
- ast_module_user_remove(u);
return -1;
}
sildet = ast_dsp_new();
if (!sildet) {
ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
- ast_module_user_remove(u);
return -1;
}
ast_dsp_set_threshold(sildet, 256);
ast_dsp_free(sildet);
}
- ast_module_user_remove(u);
-
return res;
}
static int rpt_exec(struct ast_channel *chan, void *data)
{
int res = -1, i, rem_totx, n, phone_mode = 0;
- struct ast_module_user *u;
char *tmp, keyed = 0;
char *options, *tele, c;
struct rpt *myrpt;
ast_log(LOG_WARNING, "Cant get io permission on IO port %x hex\n", myrpt->p.iobase);
return -1;
}
- u = ast_module_user_add(chan);
rpt_mutex_unlock(&myrpt->lock);
/* find our index, and load the vars initially */
for (i = 0; i < nrpts; i++) {
myrpt->remoteon = 0;
rpt_mutex_unlock(&myrpt->lock);
closerem(myrpt);
- ast_module_user_remove(u);
return res;
}
);
char *parse;
int res = 0;
- struct ast_module_user *u;
time_t unixtime;
if (!data)
parse = ast_strdupa(data);
- u = ast_module_user_add(chan);
-
AST_STANDARD_APP_ARGS(args, parse);
ast_get_time_t(args.timeval, &unixtime, time(NULL), NULL);
res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY,
chan->language, args.format, args.timezone);
- ast_module_user_remove(u);
-
return res;
}
static int senddtmf_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *digits = NULL, *to = NULL;
int timeout = 250;
return 0;
}
- u = ast_module_user_add(chan);
-
digits = ast_strdupa(data);
if ((to = strchr(digits,'|'))) {
timeout = 250;
res = ast_dtmf_stream(chan,NULL,digits,timeout);
-
- ast_module_user_remove(u);
return res;
}
static int sendtext_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *status = "UNSUPPORTED";
char *parse = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(text);
AST_APP_ARG(options);
);
-
- u = ast_module_user_add(chan);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n");
- ast_module_user_remove(u);
return -1;
} else
parse = ast_strdupa(data);
if (!chan->tech->send_text) {
ast_channel_unlock(chan);
/* Does not support transport */
- ast_module_user_remove(u);
return 0;
}
status = "FAILURE";
if (!res)
status = "SUCCESS";
pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
- ast_module_user_remove(u);
return 0;
}
static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
int pres = -1;
static int deprecated = 0;
- u = ast_module_user_add(chan);
-
if (!deprecated) {
deprecated = 1;
ast_log(LOG_WARNING, "SetCallerPres is deprecated. Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
if (pres < 0) {
ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
(char *) data);
- ast_module_user_remove(u);
return 0;
}
chan->cid.cid_pres = pres;
- ast_module_user_remove(u);
return 0;
}
{
int res = 0;
struct ast_flags flags;
- struct ast_module_user *u;
char *parse, *opts[OPTION_ARG_ARRAY_SIZE];
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(dummy);
return -1;
}
- u = ast_module_user_add(chan);
-
/* Do our thing here */
/* We need to make a copy of the input string if we are going to modify it! */
if (ast_test_flag(&flags, OPTION_C))
ast_log(LOG_NOTICE, "Option C is set with : %s\n", opts[OPTION_ARG_C] ? opts[OPTION_ARG_C] : "<unspecified>");
- ast_module_user_remove(u);
-
return res;
}
static int sms_exec(struct ast_channel *chan, void *data)
{
int res = -1;
- struct ast_module_user *u;
sms_t h = { 0 };
/* argument parsing support */
struct ast_flags sms_flags;
S_OR(sms_args.addr, ""),
S_OR(sms_args.body, "") );
- u = ast_module_user_add(chan);
h.ipc0 = h.ipc1 = 20; /* phase for cosine */
h.dcs = 0xF1; /* default */
sms_log(&h, '?'); /* log incomplete message */
done:
- ast_module_user_remove(u);
return (res);
}
static int softhangup_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
struct ast_channel *c=NULL;
char *options, *cut, *cdata, *match;
char name[AST_CHANNEL_NAME] = "";
return 0;
}
- u = ast_module_user_add(chan);
-
cdata = ast_strdupa(data);
match = strsep(&cdata, "|");
options = strsep(&cdata, "|");
}
c = ast_channel_walk_locked(c);
}
-
- ast_module_user_remove(u);
return 0;
}
/*! \brief SpeechCreate() Dialplan Application */
static int speech_create(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u = NULL;
struct ast_speech *speech = NULL;
struct ast_datastore *datastore = NULL;
- u = ast_module_user_add(chan);
-
/* Request a speech object */
speech = ast_speech_new(data, chan->nativeformats);
if (speech == NULL) {
/* Not available */
pbx_builtin_setvar_helper(chan, "ERROR", "1");
- ast_module_user_remove(u);
return 0;
}
if (datastore == NULL) {
ast_speech_destroy(speech);
pbx_builtin_setvar_helper(chan, "ERROR", "1");
- ast_module_user_remove(u);
return 0;
}
datastore->data = speech;
ast_channel_datastore_add(chan, datastore);
- ast_module_user_remove(u);
-
return 0;
}
static int speech_load(struct ast_channel *chan, void *data)
{
int res = 0, argc = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
char *argv[2], *args = NULL, *name = NULL, *path = NULL;
args = ast_strdupa(data);
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
+ if (speech == NULL)
return -1;
- }
/* Parse out arguments */
argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0]));
- if (argc != 2) {
- ast_module_user_remove(u);
+ if (argc != 2)
return -1;
- }
name = argv[0];
path = argv[1];
/* Load the grammar locally on the object */
res = ast_speech_grammar_load(speech, name, path);
- ast_module_user_remove(u);
-
return res;
}
static int speech_unload(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
- return -1;
- }
+ if (speech == NULL)
+ return -1;
/* Unload the grammar */
res = ast_speech_grammar_unload(speech, data);
- ast_module_user_remove(u);
-
return res;
}
static int speech_deactivate(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
+ if (speech == NULL)
return -1;
- }
/* Deactivate the grammar on the speech object */
res = ast_speech_grammar_deactivate(speech, data);
- ast_module_user_remove(u);
-
return res;
}
static int speech_activate(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
+ if (speech == NULL)
return -1;
- }
/* Activate the grammar on the speech object */
res = ast_speech_grammar_activate(speech, data);
- ast_module_user_remove(u);
-
return res;
}
static int speech_start(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
+ if (speech == NULL)
return -1;
- }
ast_speech_start(speech);
- ast_module_user_remove(u);
-
return res;
}
static int speech_processing_sound(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
+ if (speech == NULL)
return -1;
- }
if (speech->processing_sound != NULL) {
ast_free(speech->processing_sound);
speech->processing_sound = ast_strdup(data);
- ast_module_user_remove(u);
-
return res;
}
{
unsigned int timeout = 0;
int res = 0, done = 0, argc = 0, started = 0, quieted = 0, max_dtmf_len = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
struct ast_frame *f = NULL;
int oldreadformat = AST_FORMAT_SLINEAR;
args = ast_strdupa(data);
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
+ if (speech == NULL)
return -1;
- }
/* If channel is not already answered, then answer it */
- if (chan->_state != AST_STATE_UP && ast_answer(chan)) {
- ast_module_user_remove(u);
+ if (chan->_state != AST_STATE_UP && ast_answer(chan))
return -1;
- }
/* Record old read format */
oldreadformat = chan->readformat;
/* Change read format to be signed linear */
- if (ast_set_read_format(chan, speech->format)) {
- ast_module_user_remove(u);
+ if (ast_set_read_format(chan, speech->format))
return -1;
- }
/* Parse out options */
argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0]));
ast_set_read_format(chan, oldreadformat);
}
- ast_module_user_remove(u);
-
return 0;
}
static int speech_destroy(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u = NULL;
struct ast_speech *speech = find_speech(chan);
struct ast_datastore *datastore = NULL;
- u = ast_module_user_add(chan);
-
- if (speech == NULL) {
- ast_module_user_remove(u);
+ if (speech == NULL)
return -1;
- }
/* Destroy speech structure */
ast_speech_destroy(speech);
ast_channel_datastore_remove(chan, datastore);
}
- ast_module_user_remove(u);
-
return res;
}
struct gosub_stack_frame *newframe;
char argname[15], *tmp = ast_strdupa(data), *label, *endparen;
int i;
- struct ast_module_user *u;
AST_DECLARE_APP_ARGS(args2,
AST_APP_ARG(argval)[100];
);
return -1;
}
- u = ast_module_user_add(chan);
-
if (!stack_store) {
ast_debug(1, "Channel %s has no datastore, so we're allocating one.\n", chan->name);
stack_store = ast_channel_datastore_alloc(&stack_info, NULL);
if (!stack_store) {
ast_log(LOG_ERROR, "Unable to allocate new datastore. Gosub will fail.\n");
- ast_module_user_remove(u);
return -1;
}
if (!oldlist) {
ast_log(LOG_ERROR, "Unable to allocate datastore list head. Gosub will fail.\n");
ast_channel_datastore_free(stack_store);
- ast_module_user_remove(u);
return -1;
}
if (ast_parseable_goto(chan, label)) {
ast_log(LOG_ERROR, "Gosub address is invalid: '%s'\n", (char *)data);
ast_free(newframe);
- ast_module_user_remove(u);
return -1;
}
AST_LIST_INSERT_HEAD(oldlist, newframe, entries);
AST_LIST_UNLOCK(oldlist);
- ast_module_user_remove(u);
-
return 0;
}
static int gosubif_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
char *args;
int res=0;
AST_DECLARE_APP_ARGS(cond,
return 0;
}
- u = ast_module_user_add(chan);
-
args = ast_strdupa(data);
AST_NONSTANDARD_APP_ARGS(cond, args, '?');
if (cond.argc != 2) {
ast_log(LOG_WARNING, "GosubIf requires an argument: GosubIf(cond?label1(args):label2(args)\n");
- ast_module_user_remove(u);
return 0;
}
res = gosub_exec(chan, label.iffalse);
}
- ast_module_user_remove(u);
return res;
}
static int system_exec_helper(struct ast_channel *chan, void *data, int failmode)
{
- int res=0;
- struct ast_module_user *u;
+ int res = 0;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "System requires an argument(command)\n");
return failmode;
}
- u = ast_module_user_add(chan);
-
/* Do our thing here */
res = ast_safe_system((char *)data);
if ((res < 0) && (errno != ECHILD)) {
res = 0;
}
- ast_module_user_remove(u);
-
return res;
}
static int background_detect_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *tmp;
char *options;
char *stringp;
return -1;
}
- u = ast_module_user_add(chan);
-
tmp = ast_strdupa(data);
stringp=tmp;
}
if (dsp)
ast_dsp_free(dsp);
- ast_module_user_remove(u);
return res;
}
static int testclient_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
int res = 0;
char *testid=data;
char fn[80];
return -1;
}
- u = ast_module_user_add(chan);
-
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", chan->name);
res = -1;
}
- ast_module_user_remove(u);
return res;
}
static int testserver_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
int res = 0;
char testid[80]="";
char fn[80];
FILE *f;
- u = ast_module_user_add(chan);
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
/* Read version */
ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", chan->name);
res = -1;
}
- ast_module_user_remove(u);
return res;
}
{
int res;
int len;
- struct ast_module_user *u;
char *slash;
char *tech = NULL;
char *dest = NULL;
AST_APP_ARG(options);
);
- u = ast_module_user_add(chan);
-
if (ast_strlen_zero((char *)data)) {
ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination[|options])\n");
- ast_module_user_remove(u);
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
return 0;
} else
/* Allow execution only if the Tech/destination agrees with the type of the channel */
if (strncasecmp(chan->tech->type, tech, len)) {
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
- ast_module_user_remove(u);
return 0;
}
}
/* Check if the channel supports transfer before we try it */
if (!chan->tech->transfer) {
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
- ast_module_user_remove(u);
return 0;
}
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status);
- ast_module_user_remove(u);
-
return res;
}
static int sendurl_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *tmp;
char *options;
int local_option_wait=0;
return -1;
}
- u = ast_module_user_add(chan);
-
tmp = ast_strdupa(data);
stringp=tmp;
if (!ast_channel_supports_html(chan)) {
/* Does not support transport */
pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED");
- ast_module_user_remove(u);
return 0;
}
res = ast_channel_sendurl(chan, tmp);
if (res == -1) {
pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE");
- ast_module_user_remove(u);
return res;
}
status = "SUCCESS";
}
out:
pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
- ast_module_user_remove(u);
return res;
}
static int userevent_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
char *parse, buf[2048] = "";
int x, buflen = 0;
AST_DECLARE_APP_ARGS(args,
return -1;
}
- u = ast_module_user_add(chan);
-
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, buf);
- ast_module_user_remove(u);
-
return 0;
}
{
char *vtext;
int vsize;
- struct ast_module_user *u;
-
- u = ast_module_user_add(chan);
if (data) {
char *tmp;
}
}
- ast_module_user_remove(u);
-
return 0;
}
static int log_exec(struct ast_channel *chan, void *data)
{
char *level, *ltext;
- struct ast_module_user *u;
int lnum = -1;
char extension[AST_MAX_EXTENSION + 5], context[AST_MAX_EXTENSION + 2];
- u = ast_module_user_add(chan);
- if (ast_strlen_zero(data)) {
- ast_module_user_remove(u);
+ if (ast_strlen_zero(data))
return 0;
- }
ltext = ast_strdupa(data);
ast_log(lnum, extension, chan->priority, context, "%s\n", ltext);
}
- ast_module_user_remove(u);
+
return 0;
}
int res=-1;
int cmd=0;
int valid = 0;
- struct ast_module_user *u;
char prefixstr[80] ="";
char ext_context[256]="";
int box;
#ifdef IMAP_STORAGE
int deleted = 0;
#endif
- u = ast_module_user_add(chan);
/* Add the vm_state to the active list and keep it active */
memset(&vms, 0, sizeof(vms));
AST_STANDARD_APP_ARGS(args, parse);
if (args.argc == 2) {
- if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1)) {
- ast_module_user_remove(u);
+ if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1))
return -1;
- }
if (ast_test_flag(&flags, OPT_RECORDGAIN)) {
int gain;
if (!ast_strlen_zero(opts[OPT_ARG_RECORDGAIN])) {
if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
- ast_module_user_remove(u);
return -1;
} else {
record_gain = (signed char) gain;
free(vms.deleted);
if (vms.heard)
free(vms.heard);
- ast_module_user_remove(u);
return res;
}
static int vm_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
char *tmp;
struct leave_vm_options leave_options;
struct ast_flags flags = { 0 };
AST_APP_ARG(argv0);
AST_APP_ARG(argv1);
);
-
- u = ast_module_user_add(chan);
memset(&leave_options, 0, sizeof(leave_options));
tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
if (args.argc == 2) {
- if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1)) {
- ast_module_user_remove(u);
+ if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1))
return -1;
- }
ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING);
if (ast_test_flag(&flags, OPT_RECORDGAIN)) {
int gain;
if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
- ast_module_user_remove(u);
return -1;
} else {
leave_options.record_gain = (signed char) gain;
} else {
char tmp[256];
res = ast_app_getdata(chan, "vm-whichbox", tmp, sizeof(tmp) - 1, 0);
- if (res < 0) {
- ast_module_user_remove(u);
+ if (res < 0)
return res;
- }
- if (ast_strlen_zero(tmp)) {
- ast_module_user_remove(u);
+ if (ast_strlen_zero(tmp))
return 0;
- }
args.argv0 = ast_strdupa(tmp);
}
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
res = 0;
}
-
- ast_module_user_remove(u);
return res;
}
static int vm_box_exists(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
struct ast_vm_user svm;
char *context, *box;
AST_DECLARE_APP_ARGS(args,
return -1;
}
- u = ast_module_user_add(chan);
-
if (!dep_warning) {
dep_warning = 1;
ast_log(LOG_WARNING, "MailboxExists is deprecated. Please use ${MAILBOX_EXISTS(%s)} instead.\n", (char *)data);
pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "SUCCESS");
} else
pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "FAILED");
- ast_module_user_remove(u);
+
return 0;
}
static int vmauthenticate(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
char *s = data, *user=NULL, *context=NULL, mailbox[AST_MAX_EXTENSION] = "";
struct ast_vm_user vmus;
char *options = NULL;
int silent = 0, skipuser = 0;
int res = -1;
-
- u = ast_module_user_add(chan);
if (s) {
s = ast_strdupa(s);
res = 0;
}
- ast_module_user_remove(u);
return res;
}
static int waitforring_exec(struct ast_channel *chan, void *data)
{
- struct ast_module_user *u;
struct ast_frame *f;
int res = 0;
double s;
return 0;
}
- u = ast_module_user_add(chan);
-
ms = s*1000.0;
while(ms > 0) {
ms = ast_waitfor(chan, ms);
}
}
}
- ast_module_user_remove(u);
return res;
}
#include "asterisk/lock.h"
#include "asterisk/options.h"
-#define ALL_DONE(u,ret) {ast_module_user_remove(u); return ret;}
-
-
static char *start_app = "While";
static char *start_desc =
"Usage: While(<expr>)\n"
static int _while_exec(struct ast_channel *chan, void *data, int end)
{
int res=0;
- struct ast_module_user *u;
const char *while_pri = NULL;
char *my_name = NULL;
const char *condition = NULL, *label = NULL;
return -1;
}
- u = ast_module_user_add(chan);
-
/* dont want run away loops if the chan isn't even up
this is up for debate since it slows things down a tad ......
*/
if (ast_waitfordigit(chan,1) < 0)
- ALL_DONE(u,-1);
-
+ return -1;
for (x=0;;x++) {
if (get_index(chan, prefix, x)) {
ast_log(LOG_WARNING, "Couldn't find matching EndWhile? (While at %s@%s priority %d)\n", chan->context, chan->exten, chan->priority);
}
}
- ALL_DONE(u,res);
+ return res;
}
if (!end && !while_pri) {
}
ast_parseable_goto(chan, while_pri);
}
-
-
-
- ALL_DONE(u, res);
+ return res;
}
static int while_start_exec(struct ast_channel *chan, void *data) {
static int zapateller_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- struct ast_module_user *u;
int i, answer = 0, nocallerid = 0;
char *parse = ast_strdupa((char *)data);
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(options)[2];
);
- u = ast_module_user_add(chan);
-
AST_STANDARD_APP_ARGS(args, parse);
for (i = 0; i < args.argc; i++) {
res = ast_safe_sleep(chan, 500);
}
- if (!ast_strlen_zero(chan->cid.cid_num) && nocallerid) {
- ast_module_user_remove(u);
+ if (!ast_strlen_zero(chan->cid.cid_num) && nocallerid)
return res;
- }
if (!res)
res = ast_tonepair(chan, 950, 0, 330, 0);
if (!res)
res = ast_tonepair(chan, 0, 0, 1000, 0);
- ast_module_user_remove(u);
return res;
}
static int conf_exec(struct ast_channel *chan, void *data)
{
int res=-1;
- struct ast_module_user *u;
int retrycnt = 0;
int confflags = 0;
int confno = 0;
char confstr[80] = "";
-
- u = ast_module_user_add(chan);
if (!ast_strlen_zero(data)) {
if ((sscanf(data, "Zap/%d", &confno) != 1) &&
(sscanf(data, "%d", &confno) != 1)) {
ast_log(LOG_WARNING, "ZapBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data);
- ast_module_user_remove(u);
return 0;
}
}
}
out:
/* Do the conference */
- ast_module_user_remove(u);
return res;
}
{
int res=-1;
char *args;
- struct ast_module_user *u;
ZT_PARAMS ztp;
if (!data)
data = "";
- u = ast_module_user_add(chan);
-
args = ast_strdupa(data);
/* Answer the channel if it's not up */
run_ras(chan, args);
}
}
- ast_module_user_remove(u);
return res;
}
static int conf_exec(struct ast_channel *chan, void *data)
{
int res=-1;
- struct ast_module_user *u;
int confflags = 0;
int confno = 0;
char confstr[80] = "", *tmp = NULL;
struct ast_frame *f;
char *desired_group;
int input=0,search_group=0;
-
- u = ast_module_user_add(chan);
-
+
if (chan->_state != AST_STATE_UP)
ast_answer(chan);
ast_mutex_unlock(&tempchan->lock);
lastchan = tempchan;
}
- ast_module_user_remove(u);
return res;
}
* \retval 0 success
* \retval -1 failure.
*/
-int ast_register_application(const char *app, int (*execute)(struct ast_channel *, void *),
- const char *synopsis, const char *description);
+#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, ast_module_info->self)
+
+/*!
+ * \brief Register an application.
+ *
+ * \param app Short name of the application
+ * \param execute a function callback to execute the application. It should return
+ * non-zero if the channel needs to be hung up.
+ * \param synopsis a short description (one line synopsis) of the application
+ * \param description long description with all of the details about the use of
+ * the application
+ * \param mod module this application belongs to
+ *
+ * This registers an application with Asterisk's internal application list.
+ * \note The individual applications themselves are responsible for registering and unregistering
+ * and unregistering their own CLI commands.
+ *
+ * \retval 0 success
+ * \retval -1 failure.
+ */
+int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, void *),
+ const char *synopsis, const char *description, void *mod);
/*!
* \brief Unregister an application
#include "asterisk/devicestate.h"
#include "asterisk/stringfields.h"
#include "asterisk/event.h"
+#include "asterisk/module.h"
/*!
* \note I M P O R T A N T :
const char *synopsis; /*!< Synopsis text for 'show applications' */
const char *description; /*!< Description (help text) for 'show application <name>' */
AST_RWLIST_ENTRY(ast_app) list; /*!< Next app in list */
- struct module *module; /*!< Module this app belongs to */
+ struct ast_module *module; /*!< Module this app belongs to */
char name[0]; /*!< Name of the application */
};
void *data) /*!< Data for execution */
{
int res;
-
+ struct ast_module_user *u = NULL;
const char *saved_c_appl;
const char *saved_c_data;
c->appl = app->name;
c->data = data;
- /* XXX remember what to to when we have linked apps to modules */
- if (app->module) {
- /* XXX LOCAL_USER_ADD(app->module) */
- }
+ if (app->module)
+ u = __ast_module_user_add(app->module, c);
res = app->execute(c, data);
- if (app->module) {
- /* XXX LOCAL_USER_REMOVE(app->module) */
- }
+ if (app->module && u)
+ __ast_module_user_remove(app->module, u);
/* restore channel values */
c->appl = saved_c_appl;
c->data = saved_c_data;
}
/*! \brief Dynamically register a new dial plan application */
-int ast_register_application(const char *app, int (*execute)(struct ast_channel *, void *), const char *synopsis, const char *description)
+int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, void *), const char *synopsis, const char *description, void *mod)
{
struct ast_app *tmp, *cur = NULL;
char tmps[80];
tmp->execute = execute;
tmp->synopsis = synopsis;
tmp->description = description;
+ tmp->module = mod;
/* Store in alphabetical order */
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, cur, list) {
for (x=0; x<sizeof(builtins) / sizeof(struct pbx_builtin); x++) {
if (option_verbose)
ast_verbose( VERBOSE_PREFIX_1 "[%s]\n", builtins[x].name);
- if (ast_register_application(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description)) {
+ if (ast_register_application2(builtins[x].name, builtins[x].execute, builtins[x].synopsis, builtins[x].description, NULL)) {
ast_log(LOG_ERROR, "Unable to register builtin application '%s'\n", builtins[x].name);
return -1;
}