summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2005-12-03 19:25:33 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2005-12-03 19:25:33 +0000
commit870f98f02de56e35b87f511544a6cda3d4d8fe69 (patch)
treef1b09ce6fd8d356c12bfe4e6b4e24e8f97ef1154 /apps
parent6a6b88c0e33e0e60dbf8039d24d2e8815d194cae (diff)
Bug 5858 - Make the chanvars.c functions return a 'const char *'
This should prevent us from unintentionally changing variable values when they're returned from pbx_builtin_getvar_helper. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7304 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_chanspy.c2
-rw-r--r--apps/app_groupcount.c3
-rw-r--r--apps/app_macro.c23
-rw-r--r--apps/app_meetme.c11
-rw-r--r--apps/app_queue.c5
-rw-r--r--apps/app_stack.c2
-rw-r--r--apps/app_while.c13
-rw-r--r--apps/app_zapscan.c2
8 files changed, 31 insertions, 30 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 7d9061579..80b271ec0 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -468,7 +468,7 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
prev=NULL;
while(peer) {
if (peer != chan) {
- char *group = NULL;
+ const char *group = NULL;
int igrp = 1;
if (peer == prev && !chosen) {
diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c
index aa848c2d5..0d35ca394 100644
--- a/apps/app_groupcount.c
+++ b/apps/app_groupcount.c
@@ -56,7 +56,6 @@ static int group_count_exec(struct ast_channel *chan, void *data)
char group[80] = "";
char category[80] = "";
char ret[80] = "";
- char *grp;
static int deprecation_warning = 0;
LOCAL_USER_ADD(u);
@@ -69,7 +68,7 @@ static int group_count_exec(struct ast_channel *chan, void *data)
ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category));
if (ast_strlen_zero(group)) {
- grp = pbx_builtin_getvar_helper(chan, category);
+ const char *grp = pbx_builtin_getvar_helper(chan, category);
strncpy(group, grp, sizeof(group) - 1);
}
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 72b75777c..f36e979c5 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -89,6 +89,8 @@ LOCAL_USER_DECL;
static int macro_exec(struct ast_channel *chan, void *data)
{
+ const char *s;
+
char *tmp;
char *cur, *rest;
char *macro;
@@ -101,8 +103,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
int oldpriority;
char pc[80], depthc[12];
char oldcontext[AST_MAX_CONTEXT] = "";
- char *offsets;
- int offset, depth;
+ int offset, depth = 0;
int setmacrocontext=0;
int autoloopflag;
@@ -120,13 +121,9 @@ static int macro_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
/* Count how many levels deep the rabbit hole goes */
- tmp = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
- if (tmp) {
- sscanf(tmp, "%d", &depth);
- } else {
- depth = 0;
- }
-
+ s = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
+ if (s)
+ sscanf(s, "%d", &depth);
if (depth >= 7) {
ast_log(LOG_ERROR, "Macro(): possible infinite loop detected. Returning early.\n");
LOCAL_USER_REMOVE(u);
@@ -193,12 +190,13 @@ static int macro_exec(struct ast_channel *chan, void *data)
chan->priority = 1;
while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) {
+ const char *s;
/* Save copy of old arguments if we're overwriting some, otherwise
let them pass through to the other macro */
snprintf(varname, sizeof(varname), "ARG%d", argc);
- oldargs[argc] = pbx_builtin_getvar_helper(chan, varname);
- if (oldargs[argc])
- oldargs[argc] = strdup(oldargs[argc]);
+ s = pbx_builtin_getvar_helper(chan, varname);
+ if (s)
+ oldargs[argc] = strdup(s);
pbx_builtin_setvar_helper(chan, varname, cur);
argc++;
}
@@ -286,6 +284,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
ast_copy_string(chan->context, oldcontext, sizeof(chan->context));
if (!(chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO)) {
/* Copy the extension, so long as we're not in softhangup, where we could be given an asyncgoto */
+ const char *offsets;
ast_copy_string(chan->exten, oldexten, sizeof(chan->exten));
if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) {
/* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 3c9bad6f1..fb5f660ea 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -143,8 +143,8 @@ static struct ast_conference {
int locked; /* Is the conference locked? */
pthread_t recordthread; /* thread for recording */
pthread_attr_t attr; /* thread attribute */
- char *recordingfilename; /* Filename to record the Conference into */
- char *recordingformat; /* Format to record the Conference in */
+ const char *recordingfilename; /* Filename to record the Conference into */
+ const char *recordingformat; /* Format to record the Conference in */
char pin[AST_MAX_EXTENSION]; /* If protected by a PIN */
char pinadmin[AST_MAX_EXTENSION]; /* If protected by a admin PIN */
struct ast_conference *next;
@@ -813,8 +813,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
int duration=20;
struct ast_dsp *dsp=NULL;
struct ast_app *app;
- char *agifile;
- char *agifiledefault = "conf-background.agi";
+ const char *agifile;
+ const char *agifiledefault = "conf-background.agi";
char meetmesecs[30] = "";
char exitcontext[AST_MAX_CONTEXT] = "";
char recordingtmp[AST_MAX_EXTENSION] = "";
@@ -1086,7 +1086,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
/* Find a pointer to the agi app and execute the script */
app = pbx_findapp("agi");
if (app) {
- ret = pbx_exec(chan, app, agifile, 1);
+ char *s = ast_strdupa(agifile);
+ ret = pbx_exec(chan, app, s, 1);
} else {
ast_log(LOG_WARNING, "Could not find application (agi)\n");
ret = -2;
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 7f28a6ece..5564d0fcd 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1992,7 +1992,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
char oldcontext[AST_MAX_CONTEXT]="";
char queuename[256]="";
char *newnum;
- char *monitorfilename;
struct ast_channel *peer;
struct ast_channel *which;
struct localuser *lpeer;
@@ -2209,7 +2208,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
}
/* Begin Monitoring */
if (qe->parent->monfmt && *qe->parent->monfmt) {
- monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
+ const char *monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
if (pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC") || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS"))
which = qe->chan;
else
@@ -2845,7 +2844,7 @@ static int queue_exec(struct ast_channel *chan, void *data)
char *options = NULL;
char *url = NULL;
char *announceoverride = NULL;
- char *user_priority;
+ const char *user_priority;
int prio;
char *queuetimeoutstr = NULL;
enum queue_result reason = QUEUE_UNKNOWN;
diff --git a/apps/app_stack.c b/apps/app_stack.c
index d24f2267f..ccf24b2b4 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -82,7 +82,7 @@ static int pop_exec(struct ast_channel *chan, void *data)
static int return_exec(struct ast_channel *chan, void *data)
{
- char *label = pbx_builtin_getvar_helper(chan, STACKVAR);
+ const char *label = pbx_builtin_getvar_helper(chan, STACKVAR);
if (ast_strlen_zero(label)) {
ast_log(LOG_ERROR, "Return without Gosub: stack is empty\n");
diff --git a/apps/app_while.c b/apps/app_while.c
index 7c98afe80..1c91446aa 100644
--- a/apps/app_while.c
+++ b/apps/app_while.c
@@ -122,7 +122,7 @@ static int execif_exec(struct ast_channel *chan, void *data) {
#define VAR_SIZE 64
-static char *get_index(struct ast_channel *chan, const char *prefix, int index) {
+static const char *get_index(struct ast_channel *chan, const char *prefix, int index) {
char varname[VAR_SIZE];
snprintf(varname, VAR_SIZE, "%s_%d", prefix, index);
@@ -209,15 +209,15 @@ static int _while_exec(struct ast_channel *chan, void *data, int end)
{
int res=0;
struct localuser *u;
- char *while_pri = NULL;
- char *goto_str = NULL, *my_name = NULL;
- char *condition = NULL, *label = NULL;
+ const char *while_pri = NULL;
+ char *my_name = NULL;
+ const char *condition = NULL, *label = NULL;
char varname[VAR_SIZE], end_varname[VAR_SIZE];
const char *prefix = "WHILE";
size_t size=0;
int used_index_i = -1, x=0;
char used_index[VAR_SIZE] = "0", new_index[VAR_SIZE] = "0";
-
+
if (!chan) {
/* huh ? */
return -1;
@@ -271,6 +271,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end)
if (!end && !ast_true(condition)) {
/* Condition Met (clean up helper vars) */
+ const char *goto_str;
pbx_builtin_setvar_helper(chan, varname, NULL);
pbx_builtin_setvar_helper(chan, my_name, NULL);
snprintf(end_varname,VAR_SIZE,"END_%s",varname);
@@ -291,6 +292,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end)
}
if (!end && !while_pri) {
+ char *goto_str;
size = strlen(chan->context) + strlen(chan->exten) + 32;
goto_str = alloca(size);
memset(goto_str, 0, size);
@@ -302,6 +304,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end)
/* END of loop */
snprintf(end_varname, VAR_SIZE, "END_%s", varname);
if (! pbx_builtin_getvar_helper(chan, end_varname)) {
+ char *goto_str;
size = strlen(chan->context) + strlen(chan->exten) + 32;
goto_str = alloca(size);
memset(goto_str, 0, size);
diff --git a/apps/app_zapscan.c b/apps/app_zapscan.c
index ed0c77977..337f52815 100644
--- a/apps/app_zapscan.c
+++ b/apps/app_zapscan.c
@@ -296,7 +296,6 @@ static int conf_exec(struct ast_channel *chan, void *data)
char confstr[80] = "", *tmp = NULL;
struct ast_channel *tempchan = NULL, *lastchan = NULL,*ichan = NULL;
struct ast_frame *f;
- char *mygroup;
char *desired_group;
int input=0,search_group=0;
@@ -335,6 +334,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
break;
if (tempchan && search_group) {
+ const char *mygroup;
if((mygroup = pbx_builtin_getvar_helper(tempchan, "GROUP")) && (!strcmp(mygroup, desired_group))) {
ast_verbose(VERBOSE_PREFIX_3 "Found Matching Channel %s in group %s\n", tempchan->name, desired_group);
} else {