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: https://origsvn.digium.com/svn/asterisk/trunk@6832 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2005-10-19 18:19:02 +00:00
parent e5afdbbe16
commit 4aa7912057
74 changed files with 817 additions and 405 deletions

View File

@@ -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;