Cleanup code. Spacing issues, nested if issues, lots of strlen used instead of ast_strlen_zero

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3800 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
James Golovich
2004-09-17 14:15:11 +00:00
parent a9f5393bfe
commit 877f1f64c2
3 changed files with 130 additions and 137 deletions

View File

@@ -894,15 +894,11 @@ static int action_originate(struct mansession *s, struct message *m)
}
*data = '\0';
data++;
if (ast_true(async))
{
if (ast_true(async)) {
struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
if (!fast)
{
if (!fast) {
res = -1;
}
else
{
} else {
memset(fast, 0, sizeof(struct fast_originate_helper));
if (id && !ast_strlen_zero(id))
snprintf(fast->idtext, sizeof(fast->idtext), "ActionID: %s\r\n", id);
@@ -919,12 +915,9 @@ static int action_originate(struct mansession *s, struct message *m)
fast->priority = pi;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (ast_pthread_create(&th, &attr, fast_originate, fast))
{
if (ast_pthread_create(&th, &attr, fast_originate, fast)) {
res = -1;
}
else
{
} else {
res = 0;
}
}

View File

@@ -181,11 +181,11 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
*extout = x;
/* Remember what had been dialed, so that if the parking
expires, we try to come back to the same place */
if (strlen(chan->macrocontext))
if (!ast_strlen_zero(chan->macrocontext))
strncpy(pu->context, chan->macrocontext, sizeof(pu->context)-1);
else
strncpy(pu->context, chan->context, sizeof(pu->context)-1);
if (strlen(chan->macroexten))
if (!ast_strlen_zero(chan->macroexten))
strncpy(pu->exten, chan->macroexten, sizeof(pu->exten)-1);
else
strncpy(pu->exten, chan->exten, sizeof(pu->exten)-1);
@@ -303,9 +303,10 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
char *monitor_exec;
if (monitor_ok) {
if(!monitor_app)
if (!monitor_app) {
if (!(monitor_app = pbx_findapp("Monitor")))
monitor_ok=0;
}
if ((monitor_exec = pbx_builtin_getvar_helper(chan, "AUTO_MONITOR")))
pbx_exec(chan, monitor_app, monitor_exec, 1);
else if ((monitor_exec = pbx_builtin_getvar_helper(peer, "AUTO_MONITOR")))
@@ -324,9 +325,9 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
peer->appl = "Bridged Call";
peer->data = chan->name;
/* copy the userfield from the B-leg to A-leg if applicable */
if (chan->cdr && peer->cdr && strlen(peer->cdr->userfield)) {
if (chan->cdr && peer->cdr && !ast_strlen_zero(peer->cdr->userfield)) {
char tmp[256];
if (strlen(chan->cdr->userfield)) {
if (!ast_strlen_zero(chan->cdr->userfield)) {
snprintf(tmp, sizeof(tmp), "%s;%s",chan->cdr->userfield, peer->cdr->userfield);
ast_cdr_appenduserfield(chan, tmp);
} else
@@ -402,15 +403,14 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
if (allowredirect_in && who == peer) {
transferer = peer;
transferee = chan;
}
else {
} else {
transferer = chan;
transferee = peer;
}
if (!(transferer_real_context=pbx_builtin_getvar_helper(transferee, "TRANSFER_CONTEXT")) &&
!(transferer_real_context=pbx_builtin_getvar_helper(transferer, "TRANSFER_CONTEXT"))) {
/* Use the non-macro context to transfer the call */
if(strlen(transferer->macrocontext))
if (!ast_strlen_zero(transferer->macrocontext))
transferer_real_context = transferer->macrocontext;
else
transferer_real_context = transferer->context;

View File

@@ -93,7 +93,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
memset(monitor, 0, sizeof(struct ast_channel_monitor));
/* Determine file names */
if( fname_base && strlen( fname_base ) ) {
if (fname_base && !ast_strlen_zero(fname_base)) {
int directory = strchr(fname_base, '/') ? 1 : 0;
/* try creating the directory just in case it doesn't exist */
if (directory) {
@@ -129,7 +129,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
monitor->stop = ast_monitor_stop;
// Determine file format
if( format_spec && strlen( format_spec ) ) {
if (format_spec && !ast_strlen_zero(format_spec)) {
monitor->format = strdup(format_spec);
} else {
monitor->format = strdup("wav");
@@ -197,7 +197,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
ast_closestream(chan->monitor->write_stream);
}
if (chan->monitor->filename_changed&&strlen(chan->monitor->filename_base)) {
if (chan->monitor->filename_changed && !ast_strlen_zero(chan->monitor->filename_base)) {
if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0) {
snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base);
if (ast_fileexists(filename, NULL, NULL) > 0) {
@@ -219,7 +219,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
}
}
if (chan->monitor->joinfiles && strlen(chan->monitor->filename_base)) {
if (chan->monitor->joinfiles && !ast_strlen_zero(chan->monitor->filename_base)) {
char tmp[1024];
char tmp2[1024];
char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format;
@@ -262,7 +262,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, int need_lock)
{
char tmp[256];
if ((!fname_base) || (!strlen(fname_base))) {
if ((!fname_base) || (ast_strlen_zero(fname_base))) {
ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to null", chan->name);
return -1;
}
@@ -307,7 +307,7 @@ static int start_monitor_exec(struct ast_channel *chan, void *data)
int res = 0;
/* Parse arguments. */
if (data && strlen((char*)data)) {
if (data && !ast_strlen_zero((char*)data)) {
arg = ast_strdupa((char*)data);
format = arg;
fname_base = strchr(arg, '|');
@@ -371,7 +371,7 @@ static int start_monitor_action(struct mansession *s, struct message *m)
char *mix = astman_get_header(m, "Mix");
char *d;
if ((!name)||(!strlen(name))) {
if ((!name) || (ast_strlen_zero(name))) {
astman_send_error(s, m, "No channel specified");
return 0;
}
@@ -388,7 +388,7 @@ static int start_monitor_action(struct mansession *s, struct message *m)
return 0;
}
if ((!fname) || (!strlen(fname))) {
if ((!fname) || (ast_strlen_zero(fname))) {
// No filename base specified, default to channel name as per CLI
fname = malloc (FILENAME_MAX);
memset(fname, 0, FILENAME_MAX);
@@ -419,7 +419,7 @@ static int stop_monitor_action(struct mansession *s, struct message *m)
struct ast_channel *c = NULL;
char *name = astman_get_header(m, "Channel");
int res;
if ((!name)||(!strlen(name))) {
if ((!name) || (ast_strlen_zero(name))) {
astman_send_error(s, m, "No channel specified");
return 0;
}
@@ -450,11 +450,11 @@ static int change_monitor_action(struct mansession *s, struct message *m)
struct ast_channel *c = NULL;
char *name = astman_get_header(m, "Channel");
char *fname = astman_get_header(m, "File");
if ((!name) || (!strlen(name))) {
if ((!name) || (ast_strlen_zero(name))) {
astman_send_error(s, m, "No channel specified");
return 0;
}
if ((!fname)||(!strlen(fname))) {
if ((!fname)||(ast_strlen_zero(fname))) {
astman_send_error(s, m, "No filename specified");
return 0;
}