Make ParkAndAnnounce check some things (bug 1194)

This code really needs to get cleaned up


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2395 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
James Golovich
2004-03-11 06:16:15 +00:00
parent 6741234ec9
commit 6406e07a79

View File

@@ -68,13 +68,17 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
int outstate; int outstate;
struct localuser *u; struct localuser *u;
if (!data) { if (!data || (data && !strlen(data))) {
ast_log(LOG_WARNING, "Park requires an argument (parkinglot)\n"); ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
return -1; return -1;
} }
l=strlen(data)+2; l=strlen(data)+2;
orig_s=malloc(l); orig_s=malloc(l);
if (!orig_s) {
ast_log(LOG_WARNING, "Out of memory\n");
return -1;
}
s=orig_s; s=orig_s;
strncpy(s,data,l); strncpy(s,data,l);
@@ -85,9 +89,10 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
return -1; return -1;
} }
timeout = atoi(strsep(&s, "|")); if (s) {
timeout *= 1000; timeout = atoi(strsep(&s, "|"));
timeout *= 1000;
}
dial=strsep(&s, "|"); dial=strsep(&s, "|");
if (! dial) { if (! dial) {
ast_log(LOG_WARNING, "PARK: A dial resouce must be specified i.e: Console/dsp or Zap/g1/5551212\n"); ast_log(LOG_WARNING, "PARK: A dial resouce must be specified i.e: Console/dsp or Zap/g1/5551212\n");