diff options
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/app_playback.c | 6 | ||||
-rwxr-xr-x | apps/app_sql_postgres.c | 52 | ||||
-rwxr-xr-x | apps/app_url.c | 6 |
3 files changed, 37 insertions, 27 deletions
diff --git a/apps/app_playback.c b/apps/app_playback.c index 346617377..aece3e675 100755 --- a/apps/app_playback.c +++ b/apps/app_playback.c @@ -51,13 +51,15 @@ static int playback_exec(struct ast_channel *chan, void *data) char *options; int option_skip=0; int option_noanswer = 0; + char *stringp; if (!data || !strlen((char *)data)) { ast_log(LOG_WARNING, "Playback requires an argument (filename)\n"); return -1; } strncpy(tmp, (char *)data, sizeof(tmp)-1); - strtok(tmp, "|"); - options = strtok(NULL, "|"); + stringp=tmp; + strsep(&stringp, "|"); + options = strsep(&stringp, "|"); if (options && !strcasecmp(options, "skip")) option_skip = 1; if (options && !strcasecmp(options, "noanswer")) diff --git a/apps/app_sql_postgres.c b/apps/app_sql_postgres.c index 628987ad5..3e7e1f462 100755 --- a/apps/app_sql_postgres.c +++ b/apps/app_sql_postgres.c @@ -201,7 +201,6 @@ static int del_identifier(int identifier,int identifier_type) { static int aPGSQL_connect(struct ast_channel *chan, void *data) { - char *ptrptr; char *s1,*s4; char s[100]; char *optionstring; @@ -210,15 +209,17 @@ static int aPGSQL_connect(struct ast_channel *chan, void *data) { int res; PGconn *karoto; int id; + char *stringp=NULL; res=0; l=strlen(data)+2; s1=malloc(l); strncpy(s1,data,l); - strtok_r(s1," ",&ptrptr); // eat the first token, we already know it :P - var=strtok_r(NULL," ",&ptrptr); - optionstring=strtok_r(NULL,"\n",&ptrptr); + stringp=s1; + strsep(&stringp," "); // eat the first token, we already know it :P + var=strsep(&stringp," "); + optionstring=strsep(&stringp,"\n"); karoto = PQconnectdb(optionstring); if (PQstatus(karoto) == CONNECTION_BAD) { @@ -239,7 +240,6 @@ static int aPGSQL_connect(struct ast_channel *chan, void *data) { static int aPGSQL_query(struct ast_channel *chan, void *data) { - char *ptrptr; char *s1,*s2,*s3,*s4,*s5; char s[100]; char *querystring; @@ -249,6 +249,7 @@ static int aPGSQL_query(struct ast_channel *chan, void *data) { PGconn *karoto; PGresult *PGSQLres; int id,id1; + char *stringp=NULL; res=0; @@ -256,13 +257,14 @@ static int aPGSQL_query(struct ast_channel *chan, void *data) { s1=malloc(l); s2=malloc(l); strcpy(s1,data); - strtok_r(s1," ",&ptrptr); // eat the first token, we already know it :P - s3=strtok_r(NULL," ",&ptrptr); + stringp=s1; + strsep(&stringp," "); // eat the first token, we already know it :P + s3=strsep(&stringp," "); while (1) { // ugly trick to make branches with break; var=s3; - s4=strtok_r(NULL," ",&ptrptr); + s4=strsep(&stringp," "); id=atoi(s4); - querystring=strtok_r(NULL,"\n",&ptrptr); + querystring=strsep(&stringp,"\n"); if ((karoto=find_identifier(id,AST_PGSQL_ID_CONNID))==NULL) { ast_log(LOG_WARNING,"Invalid connection identifier %d passed in aPGSQL_query\n",id); res=-1; @@ -297,7 +299,6 @@ static int aPGSQL_query(struct ast_channel *chan, void *data) { static int aPGSQL_fetch(struct ast_channel *chan, void *data) { - char *ptrptr; char *s1,*s2,*s3,*s4,*s5,*s6,*s7; char s[100]; char *var; @@ -309,6 +310,7 @@ static int aPGSQL_fetch(struct ast_channel *chan, void *data) { int nres; struct ast_var_t *variables; struct varshead *headp; + char *stringp=NULL; headp=&chan->varshead; @@ -318,8 +320,9 @@ static int aPGSQL_fetch(struct ast_channel *chan, void *data) { s1=malloc(l); s2=malloc(l); strcpy(s1,data); - strtok_r(s1," ",&ptrptr); // eat the first token, we already know it :P - s3=strtok_r(NULL," ",&ptrptr); + stringp=s1; + strsep(&stringp," "); // eat the first token, we already know it :P + s3=strsep(&stringp," "); while (1) { // ugly trick to make branches with break; var=s3; // fetchid fnd=0; @@ -337,7 +340,7 @@ static int aPGSQL_fetch(struct ast_channel *chan, void *data) { pbx_builtin_setvar_helper(chan,s3,s7); } - s4=strtok_r(NULL," ",&ptrptr); + s4=strsep(&stringp," "); id=atoi(s4); // resultid if ((PGSQLres=find_identifier(id,AST_PGSQL_ID_RESID))==NULL) { ast_log(LOG_WARNING,"Invalid result identifier %d passed in aPGSQL_fetch\n",id); @@ -355,7 +358,7 @@ static int aPGSQL_fetch(struct ast_channel *chan, void *data) { nres=PQnfields(PGSQLres); ast_log(LOG_WARNING,"ast_PGSQL_fetch : nres = %d i = %d ;\n",nres,i); for (j=0;j<nres;j++) { - s5=strtok_r(NULL," ",&ptrptr); + s5=strsep(&stringp," "); if (s5==NULL) { ast_log(LOG_WARNING,"ast_PGSQL_fetch : More tuples (%d) than variables (%d)\n",nres,j); break; @@ -391,18 +394,19 @@ static int aPGSQL_fetch(struct ast_channel *chan, void *data) { static int aPGSQL_reset(struct ast_channel *chan, void *data) { - char *ptrptr; char *s1,*s3; int l; PGconn *karoto; int id; + char *stringp=NULL; l=strlen(data)+2; s1=malloc(l); strcpy(s1,data); - strtok_r(s1," ",&ptrptr); // eat the first token, we already know it :P - s3=strtok_r(NULL," ",&ptrptr); + stringp=s1; + strsep(&stringp," "); // eat the first token, we already know it :P + s3=strsep(&stringp," "); id=atoi(s3); if ((karoto=find_identifier(id,AST_PGSQL_ID_CONNID))==NULL) { ast_log(LOG_WARNING,"Invalid connection identifier %d passed in aPGSQL_reset\n",id); @@ -416,18 +420,19 @@ static int aPGSQL_reset(struct ast_channel *chan, void *data) { static int aPGSQL_clear(struct ast_channel *chan, void *data) { - char *ptrptr; char *s1,*s3; int l; PGresult *karoto; int id; + char *stringp=NULL; l=strlen(data)+2; s1=malloc(l); strcpy(s1,data); - strtok_r(s1," ",&ptrptr); // eat the first token, we already know it :P - s3=strtok_r(NULL," ",&ptrptr); + stringp=s1; + strsep(&stringp," "); // eat the first token, we already know it :P + s3=strsep(&stringp," "); id=atoi(s3); if ((karoto=find_identifier(id,AST_PGSQL_ID_RESID))==NULL) { ast_log(LOG_WARNING,"Invalid result identifier %d passed in aPGSQL_clear\n",id); @@ -445,18 +450,19 @@ static int aPGSQL_clear(struct ast_channel *chan, void *data) { static int aPGSQL_disconnect(struct ast_channel *chan, void *data) { - char *ptrptr; char *s1,*s3; int l; PGconn *karoto; int id; + char *stringp=NULL; l=strlen(data)+2; s1=malloc(l); strcpy(s1,data); - strtok_r(s1," ",&ptrptr); // eat the first token, we already know it :P - s3=strtok_r(NULL," ",&ptrptr); + stringp=s1; + strsep(&stringp," "); // eat the first token, we already know it :P + s3=strsep(&stringp," "); id=atoi(s3); if ((karoto=find_identifier(id,AST_PGSQL_ID_CONNID))==NULL) { ast_log(LOG_WARNING,"Invalid connection identifier %d passed in aPGSQL_disconnect\n",id); diff --git a/apps/app_url.c b/apps/app_url.c index 53a589481..6cae9eb9b 100755 --- a/apps/app_url.c +++ b/apps/app_url.c @@ -52,13 +52,15 @@ static int sendurl_exec(struct ast_channel *chan, void *data) char *options; int option_wait=0; struct ast_frame *f; + char *stringp=NULL; if (!data || !strlen((char *)data)) { ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n"); return -1; } strncpy(tmp, (char *)data, sizeof(tmp)-1); - strtok(tmp, "|"); - options = strtok(NULL, "|"); + stringp=tmp; + strsep(&stringp, "|"); + options = strsep(&stringp, "|"); if (options && !strcasecmp(options, "wait")) option_wait = 1; LOCAL_USER_ADD(u); |