aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_externalivr.c
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-14 19:47:39 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-14 19:47:39 +0000
commit3fb2da6dbbd2e0e6788f61c315182590adb64678 (patch)
tree23f9d0844c0425cda18cb9f89433402a722c556b /apps/app_externalivr.c
parent339bee10d3ae59878edabb7146a727a27f81324f (diff)
a few syntax changes and safer code
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@103682 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_externalivr.c')
-rw-r--r--apps/app_externalivr.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index a3d95aa40..eb1989c62 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -230,16 +230,16 @@ static void ast_eivr_getvariable(struct ast_channel *chan, char *data, char *out
{
/* original input data: "G,var1,var2," */
/* data passed as "data": "var1,var2" */
- char *inbuf, *variable;
+ char *inbuf, *variable;
const char *value;
- char *saveptr;
int j;
+ struct ast_str *newstring = ast_str_alloca(outbuflen);
- outbuf[0] = 0;
+ outbuf[0] = '\0';
- for (j = 1, inbuf = data; ; j++, inbuf = NULL) {
- variable = strtok_r(inbuf, ",", &saveptr);
+ for (j = 1, inbuf = data; ; j++) {
+ variable = strsep(&inbuf, ",");
if (variable == NULL) {
int outstrlen = strlen(outbuf);
if(outstrlen && outbuf[outstrlen - 1] == ',') {
@@ -251,10 +251,8 @@ static void ast_eivr_getvariable(struct ast_channel *chan, char *data, char *out
value = pbx_builtin_getvar_helper(chan, variable);
if(!value)
value = "";
- strncat(outbuf,variable,outbuflen);
- strncat(outbuf,"=",outbuflen);
- strncat(outbuf,value,outbuflen);
- strncat(outbuf,",",outbuflen);
+ ast_str_append(&newstring, 0, "%s=%s,", variable, value);
+ ast_copy_string(outbuf, newstring->str, outbuflen);
}
};
@@ -265,28 +263,24 @@ static void ast_eivr_setvariable(struct ast_channel *chan, char *data)
char *inbuf, *variable;
- char *saveptr;
int j;
- for(j=1, inbuf=data; ; j++, inbuf=NULL) {
- variable = strtok_r(inbuf, ",", &saveptr);
+ for (j = 1, inbuf = data; ; j++, inbuf = NULL) {
+ variable = strsep(&inbuf, ",");
ast_chan_log(LOG_DEBUG, chan, "Setting up a variable: %s\n", variable);
if(variable) {
/* variable contains "varname=value" */
- strncpy(buf, variable, sizeof(buf));
+ ast_copy_string(buf, variable, sizeof(buf));
value = strchr(buf, '=');
if(!value)
value="";
- else {
- value[0] = 0;
- value++;
- }
+ else
+ *value++ = '\0';
pbx_builtin_setvar_helper(chan, buf, value);
}
- else break;
-
+ else
+ break;
}
-
};
static struct playlist_entry *make_entry(const char *filename)