fix formatting, from bkw

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2902 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jeremy McNamara
2004-05-06 03:20:05 +00:00
parent ab3c603b1c
commit 9c5c609de2

View File

@@ -68,14 +68,14 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
int outstate;
struct localuser *u;
if (!data || (data && !strlen(data))) {
if(!data || (data && !strlen(data))) {
ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
return -1;
}
l=strlen(data)+2;
orig_s=malloc(l);
if (!orig_s) {
if(!orig_s) {
ast_log(LOG_WARNING, "Out of memory\n");
return -1;
}
@@ -83,23 +83,22 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
strncpy(s,data,l);
template=strsep(&s,"|");
if (! template) {
if(! template) {
ast_log(LOG_WARNING, "PARK: An announce template must be defined\n");
free(orig_s);
return -1;
}
if (s) {
if(s) {
timeout = atoi(strsep(&s, "|"));
timeout *= 1000;
}
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");
free(orig_s);
return -1;
}
else {
} else {
dialtech=strsep(&dial, "/");
dialstr=dial;
ast_verbose( VERBOSE_PREFIX_3 "Dial Tech,String: (%s,%s)\n", dialtech,dialstr);
@@ -107,46 +106,45 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
return_context = s;
if (return_context != NULL) {
if(return_context != NULL) {
/* set the return context. Code borrowed from the Goto builtin */
working = return_context;
context = strsep(&working, "|");
exten = strsep(&working, "|");
if (!exten) {
if(!exten) {
/* Only a priority in this one */
priority = context;
exten = NULL;
context = NULL;
} else {
priority = strsep(&working, "|");
if (!priority) {
if(!priority) {
/* Only an extension and priority in this one */
priority = exten;
exten = context;
context = NULL;
}
}
if (atoi(priority) < 0) {
if(atoi(priority) < 0) {
ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority);
free(orig_s);
return -1;
}
/* At this point we have a priority and maybe an extension and a context */
chan->priority = atoi(priority);
if (exten && strcasecmp(exten, "BYEXTENSION"))
if(exten && strcasecmp(exten, "BYEXTENSION"))
strncpy(chan->exten, exten, sizeof(chan->exten)-1);
if (context)
if(context)
strncpy(chan->context, context, sizeof(chan->context)-1);
}
else { /* increment the priority by default*/
} else { /* increment the priority by default*/
chan->priority++;
}
if (option_verbose > 2) {
if(option_verbose > 2) {
ast_verbose( VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n", chan->context,chan->exten, chan->priority, chan->callerid);
if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
ast_verbose( VERBOSE_PREFIX_3 "Warning: Return Context Invalid, call will return to default|s\n");
}
}
@@ -166,12 +164,12 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
dchan = ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->callerid);
if (dchan) {
if (dchan->_state == AST_STATE_UP) {
if (option_verbose > 3)
if(dchan) {
if(dchan->_state == AST_STATE_UP) {
if(option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", dchan->name);
} else {
if (option_verbose > 3)
if(option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", dchan->name);
ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name);
ast_hangup(dchan);
@@ -179,8 +177,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
LOCAL_USER_REMOVE(u);
return -1;
}
}
else {
} else {
ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
free(orig_s);
LOCAL_USER_REMOVE(u);
@@ -196,7 +193,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
tpl_working = template;
tpl_current=strsep(&tpl_working, ":");
while ( tpl_current && looptemp < sizeof(tmp)) {
while(tpl_current && looptemp < sizeof(tmp)) {
tmp[looptemp]=tpl_current;
looptemp++;
tpl_current=strsep(&tpl_working,":");
@@ -204,14 +201,13 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
for(i=0; i<looptemp; i++) {
ast_verbose(VERBOSE_PREFIX_4 "Announce:%s\n", tmp[i]);
if (!strcmp(tmp[i], "PARKED")) {
if(!strcmp(tmp[i], "PARKED")) {
ast_say_digits(dchan, lot, "", dchan->language);
}
else {
} else {
dres = ast_streamfile(dchan, tmp[i], dchan->language);
if (!dres)
if(!dres) {
dres = ast_waitstream(dchan, "");
else {
} else {
ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", tmp[i], dchan->name);
dres = 0;
}