From 4fc8108a2b17ea4066fb5ecfcab9d439090b9614 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Mon, 11 Nov 2002 16:37:01 +0000 Subject: Version 0.3.0 from FTP git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@546 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_playback.c | 6 ++++-- apps/app_sql_postgres.c | 52 +++++++++++++++++++++++++++---------------------- apps/app_url.c | 6 ++++-- 3 files changed, 37 insertions(+), 27 deletions(-) (limited to 'apps') 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