diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-10-19 18:19:02 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-10-19 18:19:02 +0000 |
commit | 58818426d60d583c4becc6a99b398cbac1b7b12f (patch) | |
tree | 5fee3540f8d72d45cd1b2e5bf15e5860581dd4f8 /apps/app_osplookup.c | |
parent | a4d6ea67a7536e2cb2337527357ce6d3db8639f3 (diff) |
Massive cleanups to applications for LOCAL_USER handling and some other things.
In general, LOCAL_USER_ADD/REMOVE should be the first/last thing called in an
application. An exception is if there is some *fast* setup code that might
halt the execution of the application, such as checking to see if an argument
exists.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6832 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_osplookup.c')
-rwxr-xr-x | apps/app_osplookup.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c index d141ae14e..a27f4d0c2 100755 --- a/apps/app_osplookup.c +++ b/apps/app_osplookup.c @@ -109,10 +109,21 @@ static int osplookup_exec(struct ast_channel *chan, void *data) char *temp; char *provider, *opts=NULL; struct ast_osp_result result; - if (!data || ast_strlen_zero(data) || !(temp = ast_strdupa(data))) { + + if (!data || ast_strlen_zero(data)) { ast_log(LOG_WARNING, "OSPLookup requires an argument (extension)\n"); return -1; } + + LOCAL_USER_ADD(u); + + temp = ast_strdupa(data); + if (!temp) { + ast_log(LOG_ERROR, "Out of memory!\n"); + LOCAL_USER_REMOVE(u); + return -1; + } + provider = strchr(temp, '|'); if (provider) { *provider = '\0'; @@ -123,7 +134,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data) opts++; } } - LOCAL_USER_ADD(u); + ast_log(LOG_DEBUG, "Whoo hoo, looking up OSP on '%s' via '%s'\n", temp, provider ? provider : "<default>"); if ((res = ast_osp_lookup(chan, provider, temp, chan->cid.cid_num, &result)) > 0) { char tmp[80]; @@ -157,10 +168,14 @@ static int ospnext_exec(struct ast_channel *chan, void *data) char *temp; int cause; struct ast_osp_result result; + if (!data || ast_strlen_zero(data)) { ast_log(LOG_WARNING, "OSPNext should have an argument (cause)\n"); + return -1; } + LOCAL_USER_ADD(u); + cause = str2cause((char *)data); temp = pbx_builtin_getvar_helper(chan, "OSPHANDLE"); result.handle = -1; @@ -201,9 +216,14 @@ static int ospfinished_exec(struct ast_channel *chan, void *data) int cause; time_t start=0, duration=0; struct ast_osp_result result; + if (!data || ast_strlen_zero(data)) { ast_log(LOG_WARNING, "OSPFinish should have an argument (cause)\n"); + return -1; } + + LOCAL_USER_ADD(u); + if (chan->cdr) { start = chan->cdr->answer.tv_sec; if (start) @@ -212,7 +232,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data) duration = 0; } else ast_log(LOG_WARNING, "OSPFinish called on channel '%s' with no CDR!\n", chan->name); - LOCAL_USER_ADD(u); + cause = str2cause((char *)data); temp = pbx_builtin_getvar_helper(chan, "OSPHANDLE"); result.handle = -1; |