aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-16 18:37:01 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-16 18:37:01 +0000
commit1bb80944bcd0992b365b5ca00dc37ef7093837f0 (patch)
tree0493dd43b3face09863cbaaeb1885d1ed76d0d67 /res
parent17adf2ca4e2c2bcd2404f1c64faafbb34657175e (diff)
minor readability fixes in preparation for more work on this file:
- replace nested 'if' with '&&' - fix indentation - annotate the end brace of some huge block - remove useless parentheses git-svn-id: http://svn.digium.com/svn/asterisk/trunk@20597 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_features.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/res/res_features.c b/res/res_features.c
index 468d656d7..cf6c6f914 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -294,10 +294,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
}
pu->start = ast_tvnow();
pu->parkingnum = x;
- if (timeout > 0)
- pu->parkingtime = timeout;
- else
- pu->parkingtime = parkingtime;
+ pu->parkingtime = (timeout > 0) ? timeout : parkingtime;
if (extout)
*extout = x;
if (peer)
@@ -425,12 +422,10 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
return -1;
}
- if (!monitor_app) {
- if (!(monitor_app = pbx_findapp("Monitor"))) {
- monitor_ok=0;
- ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
- return -1;
- }
+ if (!monitor_app && !(monitor_app = pbx_findapp("Monitor"))) {
+ monitor_ok=0;
+ ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
+ return -1;
}
if (!ast_strlen_zero(courtesytone)) {
if (ast_autoservice_start(callee_chan))
@@ -848,7 +843,8 @@ void ast_register_feature(struct ast_call_feature *feature)
/*! \brief unregister feature from feature_list */
void ast_unregister_feature(struct ast_call_feature *feature)
{
- if (!feature) return;
+ if (!feature)
+ return;
AST_LIST_LOCK(&feature_list);
AST_LIST_REMOVE(&feature_list,feature,feature_entry);
@@ -902,9 +898,7 @@ static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer,
app = pbx_findapp(feature->app);
if (app) {
- struct ast_channel *work = chan;
- if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE))
- work = peer;
+ struct ast_channel *work = ast_test_flag(feature,AST_FEATURE_FLAG_CALLEE) ? peer : chan;
res = pbx_exec(work, app, feature->app_args);
if (res < 0)
return res;
@@ -913,7 +907,7 @@ static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer,
return -2;
}
- return FEATURE_RETURN_SUCCESS;
+ return FEATURE_RETURN_SUCCESS; /* XXX should probably return res */
}
static void unmap_features(void)
@@ -1018,26 +1012,23 @@ static void set_config_flags(struct ast_channel *chan, struct ast_channel *peer,
char *tok;
struct ast_call_feature *feature;
- if (!tmp) {
+ if (!tmp) /* no memory */
return;
- }
/* while we have a feature */
while (NULL != (tok = strsep(&tmp, "#"))) {
- if ((feature = find_feature(tok))) {
- if (ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
- if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
- ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
- if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE))
- ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
- }
+ if ((feature = find_feature(tok)) && ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
+ if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
+ ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
+ if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE))
+ ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
}
}
}
}
}
-
+/* XXX this is very similar to the code in channel.c */
static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name)
{
int state = 0;
@@ -1340,10 +1331,11 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
return -1;
}
- if (!f || ((f->frametype == AST_FRAME_CONTROL) && ((f->subclass == AST_CONTROL_HANGUP) || (f->subclass == AST_CONTROL_BUSY) ||
- (f->subclass == AST_CONTROL_CONGESTION)))) {
- res = -1;
- break;
+ if (!f || (f->frametype == AST_FRAME_CONTROL &&
+ (f->subclass == AST_CONTROL_HANGUP || f->subclass == AST_CONTROL_BUSY ||
+ f->subclass == AST_CONTROL_CONGESTION ) ) ) {
+ res = -1;
+ break;
}
/* many things should be sent to the 'other' channel */
other = (who == chan) ? peer : chan;
@@ -1362,7 +1354,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
}
}
/* check for '*', if we find it it's time to disconnect */
- if (f && (f->frametype == AST_FRAME_DTMF)) {
+ if (f && f->frametype == AST_FRAME_DTMF) {
char *featurecode;
int sense;
@@ -1576,7 +1568,7 @@ static void *do_parking_thread(void *ignore)
goto std; /* XXX Ick: jumping into an else statement??? XXX */
}
}
- }
+ } /* end for */
if (x >= AST_MAX_FDS) {
std: for (x=0; x<AST_MAX_FDS; x++) {
/* Keep this one for next one */
@@ -1594,7 +1586,7 @@ std: for (x=0; x<AST_MAX_FDS; x++) {
pu = pu->next;
}
}
- }
+ } /* end while */
ast_mutex_unlock(&parking_lock);
rfds = nrfds;
efds = nefds;