static int settransfercapability_exec(struct cw_channel *chan, int argc, char **argv) { struct localuser *u; int x; int transfercapability = -1; LOCAL_USER_ADD(u); for (x = 0; x < (sizeof(transcaps) / sizeof(transcaps[0])); x++) { if (!strcasecmp(transcaps[x].name, argv[0])) { transfercapability = transcaps[x].val; break; } } if (transfercapability < 0) { cw_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", argv[0]); LOCAL_USER_REMOVE(u); return 0; } chan->transfercapability = (unsigned short)transfercapability; if (option_verbose > 2) cw_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, argv[0]); LOCAL_USER_REMOVE(u); return 0; }
static int directory_exec(struct cw_channel *chan, int argc, char **argv) { struct localuser *u; struct cw_config *cfg; char *context, *dialcontext, *dirintro; int res = 0; int last = 1; if (argc < 1 || argc > 3) { cw_log(LOG_ERROR, "Syntax: %s\n", directory_syntax); return -1; } LOCAL_USER_ADD(u); context = argv[0]; dialcontext = (argc > 1 && argv[1][0] ? argv[1] : context); if (argc > 2 && strchr(argv[2], 'f')) last = 0; cfg = realtime_directory(context); if (!cfg) { LOCAL_USER_REMOVE(u); return -1; } dirintro = cw_variable_retrieve(cfg, context, "directoryintro"); if (cw_strlen_zero(dirintro)) dirintro = cw_variable_retrieve(cfg, "general", "directoryintro"); if (cw_strlen_zero(dirintro)) { if (last) dirintro = "dir-intro"; else dirintro = "dir-intro-fn"; } for (;;) { if (!res) res = cw_streamfile(chan, dirintro, chan->language); if (!res) res = cw_waitstream(chan, CW_DIGIT_ANY); cw_stopstream(chan); if (!res) res = cw_waitfordigit(chan, 5000); if (res >0) { res = do_directory(chan, cfg, context, dialcontext, res, last); if (res > 0){ res = cw_waitstream(chan, CW_DIGIT_ANY); cw_stopstream(chan); if (res >= 0) { continue; } } } break; } cw_config_destroy(cfg); LOCAL_USER_REMOVE(u); return res; }
static int macroif_exec(struct ast_channel *chan, void *data) { char *expr = NULL, *label_a = NULL, *label_b = NULL; int res = 0; struct localuser *u; LOCAL_USER_ADD(u); expr = ast_strdupa(data); if (!expr) { ast_log(LOG_ERROR, "Out of Memory!\n"); LOCAL_USER_REMOVE(u); return -1; } if ((label_a = strchr(expr, '?'))) { *label_a = '\0'; label_a++; if ((label_b = strchr(label_a, ':'))) { *label_b = '\0'; label_b++; } if (ast_true(expr)) macro_exec(chan, label_a); else if (label_b) macro_exec(chan, label_b); } else ast_log(LOG_WARNING, "Invalid Syntax.\n"); LOCAL_USER_REMOVE(u); return res; }
static int app_exec(struct ast_channel *chan, void *data) { int res = 0; struct ast_flags flags; struct localuser *u; char *options=NULL; char *dummy = NULL; char *args; int argc = 0; char *opts[2]; char *argv[2]; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "%s requires an argument (dummy|[options])\n",app); return -1; } LOCAL_USER_ADD(u); /* Do our thing here */ /* We need to make a copy of the input string if we are going to modify it! */ args = ast_strdupa(data); if (!args) { ast_log(LOG_ERROR, "Out of memory!\n"); LOCAL_USER_REMOVE(u); return -1; } if ((argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) { dummy = argv[0]; options = argv[1]; ast_app_parse_options(app_opts, &flags, opts, options); } if (!ast_strlen_zero(dummy)) ast_log(LOG_NOTICE, "Dummy value is : %s\n", dummy); if (ast_test_flag(&flags, OPTION_A)) ast_log(LOG_NOTICE, "Option A is set\n"); if (ast_test_flag(&flags, OPTION_B)) ast_log(LOG_NOTICE,"Option B is set with : %s\n", opts[0] ? opts[0] : "<unspecified>"); if (ast_test_flag(&flags, OPTION_C)) ast_log(LOG_NOTICE,"Option C is set with : %s\n", opts[1] ? opts[1] : "<unspecified>"); LOCAL_USER_REMOVE(u); return res; }
static int readfile_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; char *s, *varname=NULL, *file=NULL, *length=NULL, *returnvar=NULL; int len=0; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "ReadFile require an argument!\n"); return -1; } LOCAL_USER_ADD(u); s = ast_strdupa(data); if (!s) { ast_log(LOG_ERROR, "Out of memory\n"); LOCAL_USER_REMOVE(u); return -1; } varname = strsep(&s, "="); file = strsep(&s, "|"); length = s; if (!varname || !file) { ast_log(LOG_ERROR, "No file or variable specified!\n"); LOCAL_USER_REMOVE(u); return -1; } if (length) { if ((sscanf(length, "%d", &len) != 1) || (len < 0)) { ast_log(LOG_WARNING, "%s is not a positive number, defaulting length to max\n", length); len = 0; } } if ((returnvar = ast_read_textfile(file))) { if (len > 0) { if (len < strlen(returnvar)) returnvar[len]='\0'; else ast_log(LOG_WARNING, "%s is longer than %d, and %d \n", file, len, (int)strlen(returnvar)); } pbx_builtin_setvar_helper(chan, varname, returnvar); free(returnvar); } LOCAL_USER_REMOVE(u); return res; }
static int cut_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; char *s, *newvar=NULL, result[512]; static int dep_warning = 0; LOCAL_USER_ADD(u); if (!dep_warning) { ast_log(LOG_WARNING, "The application Cut is deprecated. Please use the CUT() function instead.\n"); dep_warning=1; } /* Check and parse arguments */ if (data) { s = ast_strdupa((char *)data); if (s) { newvar = strsep(&s, "="); } else { ast_log(LOG_ERROR, "Out of memory\n"); LOCAL_USER_REMOVE(u); return -1; } } switch (cut_internal(chan, s, result, sizeof(result))) { case ERROR_NOARG: ast_log(LOG_ERROR, "Cut() requires an argument\n"); res = 0; break; case ERROR_NOMEM: ast_log(LOG_ERROR, "Out of memory\n"); res = -1; break; case ERROR_USAGE: ast_log(LOG_ERROR, "Usage: %s\n", cut_synopsis); res = 0; break; case 0: pbx_builtin_setvar_helper(chan, newvar, result); res = 0; break; default: ast_log(LOG_ERROR, "Unknown internal error\n"); res = -1; } LOCAL_USER_REMOVE(u); return res; }
static int intercom_exec(struct ast_channel *chan, void *data) { int res = 0; struct localuser *u; struct ast_frame *f; int oreadformat; LOCAL_USER_ADD(u); /* Remember original read format */ oreadformat = chan->readformat; /* Set mode to signed linear */ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); if (res < 0) { ast_log(LOG_WARNING, "Unable to set format to signed linear on channel %s\n", chan->name); LOCAL_USER_REMOVE(u); return -1; } /* Read packets from the channel */ while(!res) { res = ast_waitfor(chan, -1); if (res > 0) { res = 0; f = ast_read(chan); if (f) { if (f->frametype == AST_FRAME_DTMF) { ast_frfree(f); break; } else { if (f->frametype == AST_FRAME_VOICE) { if (f->subclass == AST_FORMAT_SLINEAR) { res = write_audio(f->data, f->datalen); if (res > 0) res = 0; } else ast_log(LOG_DEBUG, "Unable to handle non-signed linear frame (%d)\n", f->subclass); } } ast_frfree(f); } else res = -1; } } if (!res) ast_set_read_format(chan, oreadformat); LOCAL_USER_REMOVE(u); return res; }
static int eval_exec(struct cw_channel *chan, int argc, char **argv) { static int dep_warning = 0; char tmp[MAXRESULT]; struct localuser *u; char *newvar = NULL; int res = 0; if (!dep_warning) { cw_log(LOG_WARNING, "This application has been deprecated in favor of the dialplan function, EVAL\n"); dep_warning = 1; } LOCAL_USER_ADD(u); /* Check and parse arguments */ if (argv[0]) { newvar = strsep(&argv[0], "="); if (newvar && (newvar[0] != '\0')) { pbx_substitute_variables_helper(chan, argv[0], tmp, sizeof(tmp)); pbx_builtin_setvar_helper(chan, newvar, tmp); } } LOCAL_USER_REMOVE(u); return res; }
static int waitforsilence_exec(struct ast_channel *chan, void *data) { int res = 1; struct localuser *u; int maxsilence = 1000; int iterations = 1, i; LOCAL_USER_ADD(u); res = ast_answer(chan); /* Answer the channel */ if (!data || ((sscanf(data, "%d|%d", &maxsilence, &iterations) != 2) && (sscanf(data, "%d", &maxsilence) != 1))) { ast_log(LOG_WARNING, "Using default value of 1000ms, 1 iteration\n"); } if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Waiting %d time(s) for %d ms silence\n", iterations, maxsilence); res = 1; for (i=0; (i<iterations) && (res == 1); i++) { res = do_waiting(chan, maxsilence); } LOCAL_USER_REMOVE(u); if (res > 0) res = 0; return res; }
/*--- count_exec: The MeetmeCount application */ static int count_exec(struct ast_channel *chan, void *data) { struct localuser *u; int res = 0; struct ast_conference *conf; int count; char *confnum, *localdata; char val[80] = "0"; if (!data || ast_strlen_zero(data)) { ast_log(LOG_WARNING, "MeetMeCount requires an argument (conference number)\n"); return -1; } localdata = ast_strdupa(data); LOCAL_USER_ADD(u); confnum = strsep(&localdata,"|"); conf = find_conf(chan, confnum, 0, 0, NULL); if (conf) count = conf->users; else count = 0; if (localdata && !ast_strlen_zero(localdata)){ /* have var so load it and exit */ snprintf(val,sizeof(val), "%i",count); pbx_builtin_setvar_helper(chan, localdata,val); } else { if (chan->_state != AST_STATE_UP) ast_answer(chan); res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */ } LOCAL_USER_REMOVE(u); return res; }
static int system_exec_helper(struct ast_channel *chan, void *data, int failmode) { int res=0; struct localuser *u; if (!data) { ast_log(LOG_WARNING, "System requires an argument(command)\n"); return failmode; } LOCAL_USER_ADD(u); /* Do our thing here */ res = ast_safe_system((char *)data); if ((res < 0) && (errno != ECHILD)) { ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data); res = failmode; } else if (res == 127) { ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data); res = failmode; } else { if (res < 0) res = 0; if (res && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid)) chan->priority+=100; res = 0; } LOCAL_USER_REMOVE(u); return res; }
static int waitforring_exec(struct ast_channel *chan, void *data) { struct localuser *u; struct ast_frame *f; int res = 0; int ms; if (!data || (sscanf(data, "%d", &ms) != 1)) { ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n"); return 0; } ms *= 1000; LOCAL_USER_ADD(u); while(ms > 0) { ms = ast_waitfor(chan, ms); if (ms < 0) { res = ms; break; } if (ms > 0) { f = ast_read(chan); if (!f) { res = -1; break; } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Got a ring but still waiting for timeout\n"); } ast_frfree(f); } } /* Now we're really ready for the ring */ if (!res) { ms = 99999999; while(ms > 0) { ms = ast_waitfor(chan, ms); if (ms < 0) { res = ms; break; } if (ms > 0) { f = ast_read(chan); if (!f) { res = -1; break; } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Got a ring after the timeout\n"); ast_frfree(f); break; } ast_frfree(f); } } } LOCAL_USER_REMOVE(u); return res; }
static int gosubif_exec(struct ast_channel *chan, void *data) { struct localuser *u; char *condition="", *label1, *label2, *args; int res=0; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "GosubIf requires an argument\n"); return 0; } args = ast_strdupa((char *)data); if (!args) { ast_log(LOG_ERROR, "Out of memory\n"); return -1; } LOCAL_USER_ADD(u); condition = strsep(&args, "?"); label1 = strsep(&args, ":"); label2 = args; if (pbx_checkcondition(condition)) { if (label1) { res = gosub_exec(chan, label1); } } else if (label2) { res = gosub_exec(chan, label2); } LOCAL_USER_REMOVE(u); return res; }
static int flash_exec(struct ast_channel *chan, void *data) { int res = -1; int x; struct localuser *u; struct zt_params ztp; LOCAL_USER_ADD(u); if (!strcasecmp(chan->type, "Zap")) { memset(&ztp, 0, sizeof(ztp)); res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp); if (!res) { if (ztp.sigtype & __ZT_SIG_FXS) { x = ZT_FLASH; res = ioctl(chan->fds[0], ZT_HOOK, &x); if (!res || (errno == EINPROGRESS)) { if (res) { /* Wait for the event to finish */ zt_wait_event(chan->fds[0]); } res = ast_safe_sleep(chan, 1000); if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Flashed channel %s\n", chan->name); } else ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno)); } else ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name); } else ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno)); } else ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name); LOCAL_USER_REMOVE(u); return res; }
static int userevent_exec(struct cw_channel *chan, int argc, char **argv) { char eventname[512]; struct localuser *u; if (argc < 1 || argc > 2 || !argv[0][0]) { cw_log(LOG_ERROR, "Syntax: %s\n", userevent_syntax); return -1; } LOCAL_USER_ADD(u); snprintf(eventname, sizeof(eventname), "UserEvent%s", argv[0]); if (argc > 1 && argv[1][0]) { cw_log(LOG_DEBUG, "Sending user event: %s, %s\n", eventname, argv[1]); manager_event(EVENT_FLAG_USER, eventname, "Channel: %s\r\nUniqueid: %s\r\n%s\r\n", chan->name, chan->uniqueid, argv[1]); } else { cw_log(LOG_DEBUG, "Sending user event: %s\n", eventname); manager_event(EVENT_FLAG_USER, eventname, "Channel: %s\r\nUniqueid: %s\r\n", chan->name, chan->uniqueid); } LOCAL_USER_REMOVE(u); return 0; }
static int exec_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; char *s, *appname, *endargs, args[MAXRESULT] = ""; struct ast_app *app; LOCAL_USER_ADD(u); /* Check and parse arguments */ if (data) { s = ast_strdupa(data); appname = strsep(&s, "("); if (s) { endargs = strrchr(s, ')'); if (endargs) *endargs = '\0'; pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1); } if (appname) { app = pbx_findapp(appname); if (app) { res = pbx_exec(chan, app, args); } else { ast_log(LOG_WARNING, "Could not find application (%s)\n", appname); res = -1; } } } LOCAL_USER_REMOVE(u); return res; }
static int eval_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; char *s, *newvar=NULL, tmp[MAXRESULT]; static int dep_warning = 0; LOCAL_USER_ADD(u); if (!dep_warning) { ast_log(LOG_WARNING, "This application has been deprecated in favor of the dialplan function, EVAL\n"); dep_warning = 1; } /* Check and parse arguments */ if (data) { s = ast_strdupa((char *)data); if (s) { newvar = strsep(&s, "="); if (newvar && (newvar[0] != '\0')) { memset(tmp, 0, MAXRESULT); pbx_substitute_variables_helper(chan, s, tmp, MAXRESULT - 1); pbx_builtin_setvar_helper(chan, newvar, tmp); } } else { ast_log(LOG_ERROR, "Out of memory\n"); res = -1; } } LOCAL_USER_REMOVE(u); return res; }
static int senddtmf_exec(struct ast_channel *chan, void *data) { int res = 0; struct localuser *u; char *digits = NULL, *to = NULL; int timeout = 250; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n"); return 0; } LOCAL_USER_ADD(u); digits = ast_strdupa(data); if ((to = strchr(digits,'|'))) { *to = '\0'; to++; timeout = atoi(to); } if (timeout <= 0) timeout = 250; res = ast_dtmf_stream(chan,NULL,digits,timeout); LOCAL_USER_REMOVE(u); return res; }
static int curl_exec(struct ast_channel *chan, void *data) { int res = 0; struct localuser *u; char *info, *post_data=NULL, *url; struct MemoryStruct chunk = { NULL, 0 }; static int dep_warning = 0; if (!dep_warning) { ast_log(LOG_WARNING, "The application Curl is deprecated. Please use the CURL() function instead.\n"); dep_warning = 1; } if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "Curl requires an argument (URL)\n"); return -1; } LOCAL_USER_ADD(u); if ((info = ast_strdupa(data))) { url = strsep(&info, "|"); post_data = info; } else { ast_log(LOG_ERROR, "Out of memory\n"); LOCAL_USER_REMOVE(u); return -1; } if (! curl_internal(&chunk, url, post_data)) { if (chunk.memory) { chunk.memory[chunk.size] = '\0'; if (chunk.memory[chunk.size - 1] == 10) chunk.memory[chunk.size - 1] = '\0'; pbx_builtin_setvar_helper(chan, "CURL", chunk.memory); free(chunk.memory); } } else { ast_log(LOG_ERROR, "Cannot allocate curl structure\n"); res = -1; } LOCAL_USER_REMOVE(u); return res; }
static int sort_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; char *varname, *strings, result[512] = ""; static int dep_warning=0; if (!dep_warning) { ast_log(LOG_WARNING, "The application Sort is deprecated. Please use the SORT() function instead.\n"); dep_warning=1; } if (!data) { ast_log(LOG_ERROR, "Sort() requires an argument\n"); return 0; } LOCAL_USER_ADD(u); strings = ast_strdupa((char *)data); if (!strings) { ast_log(LOG_ERROR, "Out of memory\n"); LOCAL_USER_REMOVE(u); return 0; } varname = strsep(&strings, "="); switch (sort_internal(chan, strings, result, sizeof(result))) { case ERROR_NOARG: ast_log(LOG_ERROR, "Sort() requires an argument\n"); res = 0; break; case ERROR_NOMEM: ast_log(LOG_ERROR, "Out of memory\n"); res = -1; break; case 0: pbx_builtin_setvar_helper(chan, varname, result); res = 0; break; default: ast_log(LOG_ERROR, "Unknown internal error\n"); res = -1; } LOCAL_USER_REMOVE(u); return res; }
int app_conference_main( struct cw_channel* chan, int argc, char **argv ) { int res = 0 ; struct localuser *u ; LOCAL_USER_ADD( u ) ; res = member_exec( chan, argc, argv ) ; LOCAL_USER_REMOVE( u ) ; return res ; }
static int zapateller_exec(struct ast_channel *chan, void *data) { int res = 0; struct localuser *u; int answer = 0, nocallerid = 0; char *c; char *stringp=NULL; LOCAL_USER_ADD(u); stringp=data; c = strsep(&stringp, "|"); while(!ast_strlen_zero(c)) { if (!strcasecmp(c, "answer")) answer = 1; else if (!strcasecmp(c, "nocallerid")) nocallerid = 1; c = strsep(&stringp, "|"); } ast_stopstream(chan); if (chan->_state != AST_STATE_UP) { if (answer) res = ast_answer(chan); if (!res) { res = ast_safe_sleep(chan, 500); } } if (chan->cid.cid_num && nocallerid) { LOCAL_USER_REMOVE(u); return res; } if (!res) res = ast_tonepair(chan, 950, 0, 330, 0); if (!res) res = ast_tonepair(chan, 1400, 0, 330, 0); if (!res) res = ast_tonepair(chan, 1800, 0, 330, 0); if (!res) res = ast_tonepair(chan, 0, 0, 1000, 0); LOCAL_USER_REMOVE(u); return res; }
static int log_exec(struct ast_channel *chan, void *data) { char *level, *ltext; struct localuser *u; int lnum = -1; char extension[AST_MAX_EXTENSION + 5], context[AST_MAX_EXTENSION + 2]; LOCAL_USER_ADD(u); if (ast_strlen_zero(data)) { LOCAL_USER_REMOVE(u); return 0; } ltext = ast_strdupa(data); level = strsep(<ext, "|"); if (!strcasecmp(level, "ERROR")) { lnum = __LOG_ERROR; } else if (!strcasecmp(level, "WARNING")) { lnum = __LOG_WARNING; } else if (!strcasecmp(level, "NOTICE")) { lnum = __LOG_NOTICE; } else if (!strcasecmp(level, "DEBUG")) { lnum = __LOG_DEBUG; } else if (!strcasecmp(level, "VERBOSE")) { lnum = __LOG_VERBOSE; } else if (!strcasecmp(level, "DTMF")) { lnum = __LOG_DTMF; } else if (!strcasecmp(level, "EVENT")) { lnum = __LOG_EVENT; } else { ast_log(LOG_ERROR, "Unknown log level: '%s'\n", level); } if (lnum > -1) { snprintf(context, sizeof(context), "@ %s", chan->context); snprintf(extension, sizeof(extension), "Ext. %s", chan->exten); ast_log(lnum, extension, chan->priority, context, "%s\n", ltext); } LOCAL_USER_REMOVE(u); return 0; }
static int userevent_exec(struct ast_channel *chan, void *data) { struct localuser *u; char *info; char eventname[512]; char *eventbody; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "UserEvent requires an argument (eventname|optional event body)\n"); return -1; } LOCAL_USER_ADD(u); info = ast_strdupa(data); if (!info) { ast_log(LOG_ERROR, "Out of memory\n"); LOCAL_USER_REMOVE(u); return -1; } snprintf(eventname, sizeof(eventname), "UserEvent%s", info); eventbody = strchr(eventname, '|'); if (eventbody) { *eventbody = '\0'; eventbody++; } if(eventbody) { ast_log(LOG_DEBUG, "Sending user event: %s, %s\n", eventname, eventbody); manager_event(EVENT_FLAG_USER, eventname, "Channel: %s\r\nUniqueid: %s\r\n%s\r\n", chan->name, chan->uniqueid, eventbody); } else { ast_log(LOG_DEBUG, "Sending user event: %s\n", eventname); manager_event(EVENT_FLAG_USER, eventname, "Channel: %s\r\nUniqueid: %s\r\n", chan->name, chan->uniqueid); } LOCAL_USER_REMOVE(u); return 0; }
static int forkcdr_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; LOCAL_USER_ADD(u); ast_cdr_fork(chan); LOCAL_USER_REMOVE(u); return res; }
static int setcallerid_pres_exec(struct ast_channel *chan, void *data) { struct localuser *u; int pres = -1; LOCAL_USER_ADD(u); pres = ast_parse_caller_presentation(data); if (pres < 0) { ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n", (char *) data); LOCAL_USER_REMOVE(u); return 0; } chan->cid.cid_pres = pres; LOCAL_USER_REMOVE(u); return 0; }
static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct localuser *u; char *info, *post_data=NULL, *url; struct MemoryStruct chunk = { NULL, 0 }; *buf = '\0'; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "CURL requires an argument (URL)\n"); return buf; } LOCAL_USER_ACF_ADD(u); info = ast_strdupa(data); if (!info) { ast_log(LOG_ERROR, "Out of memory\n"); LOCAL_USER_REMOVE(u); return buf; } url = strsep(&info, "|"); post_data = info; if (! curl_internal(&chunk, url, post_data)) { if (chunk.memory) { chunk.memory[chunk.size] = '\0'; if (chunk.memory[chunk.size - 1] == 10) chunk.memory[chunk.size - 1] = '\0'; ast_copy_string(buf, chunk.memory, len); free(chunk.memory); } } else { ast_log(LOG_ERROR, "Cannot allocate curl structure\n"); } LOCAL_USER_REMOVE(u); return buf; }
static int conf_exec(struct ast_channel *chan, void *data) { int res=-1; struct localuser *u; int retrycnt = 0; int confflags = 0; int confno = 0; char confstr[80] = ""; LOCAL_USER_ADD(u); 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); LOCAL_USER_REMOVE(u); return 0; } } if (chan->_state != AST_STATE_UP) ast_answer(chan); while(!confno && (++retrycnt < 4)) { /* Prompt user for conference number */ confstr[0] = '\0'; res = ast_app_getdata(chan, "conf-getchannel",confstr, sizeof(confstr) - 1, 0); if (res <0) goto out; if (sscanf(confstr, "%d", &confno) != 1) confno = 0; } if (confno) { /* XXX Should prompt user for pin if pin is required XXX */ /* Run the conference */ res = conf_run(chan, confno, confflags); } out: /* Do the conference */ LOCAL_USER_REMOVE(u); return res; }
static int changrab_exec(struct cw_channel *chan, int argc, char **argv) { int res=0; struct localuser *u; struct cw_channel *newchan; struct cw_channel *oldchan; struct cw_frame *f; struct cw_bridge_config config; if (argc < 1 || argc > 2) { cw_log(LOG_ERROR, "Syntax: %s\n", changrab_syntax); return -1; } if ((oldchan = my_cw_get_channel_by_name_locked(argv[0]))) { cw_mutex_unlock(&oldchan->lock); } else { cw_log(LOG_WARNING, "No Such Channel: %s\n", argv[0]); return -1; } if (argc > 1) { if (oldchan->_bridge && strchr(argv[1], 'b')) oldchan = oldchan->_bridge; if (strchr(argv[1],'r') && oldchan->_state == CW_STATE_UP) return -1; } LOCAL_USER_ADD(u); newchan = cw_channel_alloc(0); snprintf(newchan->name, sizeof (newchan->name), "ChanGrab/%s",oldchan->name); newchan->readformat = oldchan->readformat; newchan->writeformat = oldchan->writeformat; cw_channel_masquerade(newchan, oldchan); if((f = cw_read(newchan))) { cw_fr_free(f); memset(&config,0,sizeof(struct cw_bridge_config)); cw_set_flag(&(config.features_callee), CW_FEATURE_REDIRECT); cw_set_flag(&(config.features_caller), CW_FEATURE_REDIRECT); if(newchan->_state != CW_STATE_UP) { cw_answer(newchan); } chan->appl = "Bridged Call"; res = cw_bridge_call(chan, newchan, &config); cw_hangup(newchan); } LOCAL_USER_REMOVE(u); return res ? 0 : -1; }
static int skel_exec(struct ast_channel *chan, void *data) { int res=0; struct localuser *u; if (!data) { ast_log(LOG_WARNING, "skel requires an argument (filename)\n"); return -1; } LOCAL_USER_ADD(u); /* Do our thing here */ LOCAL_USER_REMOVE(u); return res; }