mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
More app_read.c fixes (bug 1261)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2518 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -48,7 +48,7 @@ static int read_exec(struct ast_channel *chan, void *data)
|
|||||||
int res = 0;
|
int res = 0;
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
char tmp2[256]="";
|
char *varname;
|
||||||
char *filename;
|
char *filename;
|
||||||
char *stringp;
|
char *stringp;
|
||||||
char *maxdigitstr;
|
char *maxdigitstr;
|
||||||
@@ -58,10 +58,12 @@ static int read_exec(struct ast_channel *chan, void *data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(tmp, (char *)data, sizeof(tmp)-1);
|
strncpy(tmp, (char *)data, sizeof(tmp)-1);
|
||||||
stringp=tmp;
|
stringp=(char *)calloc(1,strlen(tmp)+1);
|
||||||
strsep(&stringp, "|");
|
snprintf(stringp,strlen(tmp)+1,"%s",tmp);
|
||||||
|
varname = strsep(&stringp, "|");
|
||||||
filename = strsep(&stringp, "|");
|
filename = strsep(&stringp, "|");
|
||||||
maxdigitstr = strsep(&stringp,"|");
|
maxdigitstr = strsep(&stringp,"|");
|
||||||
|
if (!(filename) || (strlen(filename)==0)) filename = NULL;
|
||||||
if (maxdigitstr)
|
if (maxdigitstr)
|
||||||
{
|
{
|
||||||
maxdigits = atoi(maxdigitstr);
|
maxdigits = atoi(maxdigitstr);
|
||||||
@@ -71,7 +73,7 @@ static int read_exec(struct ast_channel *chan, void *data)
|
|||||||
else
|
else
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting a maximum of %i digits.\n", maxdigits);
|
ast_verbose(VERBOSE_PREFIX_3 "Accepting a maximum of %i digits.\n", maxdigits);
|
||||||
}
|
}
|
||||||
if (!strlen(tmp)) {
|
if (!(varname) || (strlen(varname)==0)) {
|
||||||
ast_log(LOG_WARNING, "Read requires an variable name\n");
|
ast_log(LOG_WARNING, "Read requires an variable name\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -80,12 +82,13 @@ static int read_exec(struct ast_channel *chan, void *data)
|
|||||||
/* Answer if the line isn't up. */
|
/* Answer if the line isn't up. */
|
||||||
res = ast_answer(chan);
|
res = ast_answer(chan);
|
||||||
}
|
}
|
||||||
|
strncpy(tmp, (char *)varname, sizeof(tmp)-1);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
ast_stopstream(chan);
|
ast_stopstream(chan);
|
||||||
res = ast_app_getdata(chan, filename, tmp2, maxdigits, 0);
|
res = ast_app_getdata(chan, filename, tmp, maxdigits, 0);
|
||||||
if (!res)
|
if (!res)
|
||||||
pbx_builtin_setvar_helper(chan, tmp, tmp2);
|
pbx_builtin_setvar_helper(chan, varname, tmp);
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp2);
|
ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp);
|
||||||
}
|
}
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
return res;
|
return res;
|
||||||
|
Reference in New Issue
Block a user