aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_osplookup.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/app_osplookup.c')
-rwxr-xr-xapps/app_osplookup.c26
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;