More ast_strlen_zero changes

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2930 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
James Golovich
2004-05-09 07:51:44 +00:00
parent 3e3642433b
commit 8ef3b1544b
13 changed files with 63 additions and 56 deletions

View File

@@ -19,6 +19,7 @@
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/config.h> #include <asterisk/config.h>
#include <asterisk/say.h> #include <asterisk/say.h>
#include <asterisk/utils.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
@@ -132,7 +133,7 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
char *start, *pos, *conv,*stringp=NULL; char *start, *pos, *conv,*stringp=NULL;
char fn[256]; char fn[256];
char fn2[256]; char fn2[256];
if (!context || !strlen(context)) { if (!context || ast_strlen_zero(context)) {
ast_log(LOG_WARNING, "Directory must be called with an argument (context in which to interpret extensions)\n"); ast_log(LOG_WARNING, "Directory must be called with an argument (context in which to interpret extensions)\n");
return -1; return -1;
} }
@@ -190,7 +191,7 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
res = ast_waitstream(chan, AST_DIGIT_ANY); res = ast_waitstream(chan, AST_DIGIT_ANY);
ast_stopstream(chan); ast_stopstream(chan);
} else { } else {
res = ast_say_character_str(chan, strlen(name) ? name : v->name, AST_DIGIT_ANY, chan->language); res = ast_say_character_str(chan, !ast_strlen_zero(name) ? name : v->name, AST_DIGIT_ANY, chan->language);
} }
ahem: ahem:
if (!res) if (!res)
@@ -260,9 +261,9 @@ top:
} else } else
dialcontext = context; dialcontext = context;
dirintro = ast_variable_retrieve(cfg, context, "directoryintro"); dirintro = ast_variable_retrieve(cfg, context, "directoryintro");
if (!dirintro || !strlen(dirintro)) if (!dirintro || ast_strlen_zero(dirintro))
dirintro = ast_variable_retrieve(cfg, "general", "directoryintro"); dirintro = ast_variable_retrieve(cfg, "general", "directoryintro");
if (!dirintro || !strlen(dirintro)) if (!dirintro || ast_strlen_zero(dirintro))
dirintro = "dir-intro"; dirintro = "dir-intro";
if (chan->_state != AST_STATE_UP) if (chan->_state != AST_STATE_UP)
res = ast_answer(chan); res = ast_answer(chan);

View File

@@ -20,6 +20,7 @@
#include <asterisk/config.h> #include <asterisk/config.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/enum.h> #include <asterisk/enum.h>
#include <asterisk/utils.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
@@ -64,7 +65,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
char tmp[256]; char tmp[256];
char *c,*t; char *c,*t;
struct localuser *u; struct localuser *u;
if (!data || !strlen(data)) { if (!data || ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "EnumLookup requires an argument (extension)\n"); ast_log(LOG_WARNING, "EnumLookup requires an argument (extension)\n");
res = 1; res = 1;
} }
@@ -128,7 +129,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
else else
res = 0; res = 0;
} }
} else if (strlen(tech)) { } else if (!ast_strlen_zero(tech)) {
ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech); ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech);
res = 0; res = 0;
} }

View File

@@ -19,6 +19,7 @@
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/md5.h> #include <asterisk/md5.h>
#include <asterisk/config.h> #include <asterisk/config.h>
#include <asterisk/utils.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
@@ -304,10 +305,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) { if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) {
festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n"; festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n";
} }
if (!vdata || ast_strlen_zero(vdata)) {
if (!vdata || !strlen(vdata)) {
ast_log(LOG_WARNING, "festival requires an argument (text)\n"); ast_log(LOG_WARNING, "festival requires an argument (text)\n");
return -1; return -1;
} }

View File

@@ -21,6 +21,7 @@
#include <asterisk/channel.h> #include <asterisk/channel.h>
#include <asterisk/pbx.h> #include <asterisk/pbx.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/utils.h>
static char *tdesc = "Group Management Routines"; static char *tdesc = "Group Management Routines";
@@ -64,7 +65,7 @@ static int group_get_count(char *group)
struct ast_channel *chan; struct ast_channel *chan;
int count = 0; int count = 0;
char *test; char *test;
if (group && strlen(group)) { if (group && !ast_strlen_zero(group)) {
chan = ast_channel_walk(NULL); chan = ast_channel_walk(NULL);
while(chan) { while(chan) {
test = pbx_builtin_getvar_helper(chan, "GROUP"); test = pbx_builtin_getvar_helper(chan, "GROUP");
@@ -87,7 +88,7 @@ static int group_count_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u); LOCAL_USER_ADD(u);
/* Check and parse arguments */ /* Check and parse arguments */
if (data && strlen(data)) { if (data && !ast_strlen_zero(data)) {
group = (char *)data; group = (char *)data;
} else { } else {
group = pbx_builtin_getvar_helper(chan, "GROUP"); group = pbx_builtin_getvar_helper(chan, "GROUP");
@@ -106,7 +107,7 @@ static int group_set_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u); LOCAL_USER_ADD(u);
/* Check and parse arguments */ /* Check and parse arguments */
if (data && strlen(data)) { if (data && !ast_strlen_zero(data)) {
pbx_builtin_setvar_helper(chan, "GROUP", (char *)data); pbx_builtin_setvar_helper(chan, "GROUP", (char *)data);
} else } else
ast_log(LOG_WARNING, "GroupSet requires an argument (group name)\n"); ast_log(LOG_WARNING, "GroupSet requires an argument (group name)\n");

View File

@@ -18,6 +18,7 @@
#include <asterisk/pbx.h> #include <asterisk/pbx.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/translate.h> #include <asterisk/translate.h>
#include <asterisk/utils.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
@@ -52,7 +53,7 @@ static int playback_exec(struct ast_channel *chan, void *data)
int option_skip=0; int option_skip=0;
int option_noanswer = 0; int option_noanswer = 0;
char *stringp; char *stringp;
if (!data || !strlen((char *)data)) { if (!data || ast_strlen_zero((char *)data)) {
ast_log(LOG_WARNING, "Playback requires an argument (filename)\n"); ast_log(LOG_WARNING, "Playback requires an argument (filename)\n");
return -1; return -1;
} }

View File

@@ -39,9 +39,10 @@
#include <asterisk/parking.h> #include <asterisk/parking.h>
#include <asterisk/musiconhold.h> #include <asterisk/musiconhold.h>
#include <asterisk/cli.h> #include <asterisk/cli.h>
#include <asterisk/manager.h> /* JDG */ #include <asterisk/manager.h>
#include <asterisk/config.h> #include <asterisk/config.h>
#include <asterisk/monitor.h> #include <asterisk/monitor.h>
#include <asterisk/utils.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -576,7 +577,7 @@ static int ring_one(struct queue_ent *qe, struct localuser *outgoing)
static int valid_exit(struct queue_ent *qe, char digit) static int valid_exit(struct queue_ent *qe, char digit)
{ {
char tmp[2]; char tmp[2];
if (!strlen(qe->context)) if (ast_strlen_zero(qe->context))
return 0; return 0;
tmp[0] = digit; tmp[0] = digit;
tmp[1] = '\0'; tmp[1] = '\0';
@@ -880,9 +881,9 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
strncpy(queuename, qe->parent->name, sizeof(queuename) - 1); strncpy(queuename, qe->parent->name, sizeof(queuename) - 1);
time(&now); time(&now);
cur = qe->parent->members; cur = qe->parent->members;
if (strlen(qe->announce)) if (!ast_strlen_zero(qe->announce))
announce = qe->announce; announce = qe->announce;
if (announceoverride && strlen(announceoverride)) if (announceoverride && !ast_strlen_zero(announceoverride))
announce = announceoverride; announce = announceoverride;
while(cur) { while(cur) {
/* Get a technology/[device:]number pair */ /* Get a technology/[device:]number pair */
@@ -1022,11 +1023,10 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
} }
/* Drop out of the queue at this point, to prepare for next caller */ /* Drop out of the queue at this point, to prepare for next caller */
leave_queue(qe); leave_queue(qe);
/* JDG: sendurl */ if( url && !ast_strlen_zero(url) && ast_channel_supports_html(peer) ) {
if( url && strlen(url) && ast_channel_supports_html(peer) ) {
ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url); ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url);
ast_channel_sendurl( peer, url ); ast_channel_sendurl( peer, url );
} /* /JDG */ }
ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "CONNECT", "%ld", (long)time(NULL) - qe->start); ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "CONNECT", "%ld", (long)time(NULL) - qe->start);
strncpy(oldcontext, qe->chan->context, sizeof(oldcontext) - 1); strncpy(oldcontext, qe->chan->context, sizeof(oldcontext) - 1);
strncpy(oldexten, qe->chan->exten, sizeof(oldexten) - 1); strncpy(oldexten, qe->chan->exten, sizeof(oldexten) - 1);

View File

@@ -20,6 +20,7 @@
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/translate.h> #include <asterisk/translate.h>
#include <asterisk/options.h> #include <asterisk/options.h>
#include <asterisk/utils.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
@@ -53,7 +54,7 @@ static int read_exec(struct ast_channel *chan, void *data)
char *stringp; char *stringp;
char *maxdigitstr; char *maxdigitstr;
int maxdigits=255; int maxdigits=255;
if (!data || !strlen((char *)data)) { if (!data || ast_strlen_zero((char *)data)) {
ast_log(LOG_WARNING, "Read requires an argument (variable)\n"); ast_log(LOG_WARNING, "Read requires an argument (variable)\n");
return -1; return -1;
} }
@@ -63,17 +64,16 @@ static int read_exec(struct ast_channel *chan, void *data)
varname = strsep(&stringp, "|"); varname = strsep(&stringp, "|");
filename = strsep(&stringp, "|"); filename = strsep(&stringp, "|");
maxdigitstr = strsep(&stringp,"|"); maxdigitstr = strsep(&stringp,"|");
if (!(filename) || (strlen(filename)==0)) filename = NULL; if (!(filename) || ast_strlen_zero(filename))
if (maxdigitstr) filename = NULL;
{ if (maxdigitstr) {
maxdigits = atoi(maxdigitstr); maxdigits = atoi(maxdigitstr);
if ((maxdigits<1) || (maxdigits>255)) { if ((maxdigits<1) || (maxdigits>255)) {
maxdigits = 255; maxdigits = 255;
} } else
else
ast_verbose(VERBOSE_PREFIX_3 "Accepting a maximum of %i digits.\n", maxdigits); ast_verbose(VERBOSE_PREFIX_3 "Accepting a maximum of %i digits.\n", maxdigits);
} }
if (!(varname) || (strlen(varname)==0)) { if (!(varname) || ast_strlen_zero(varname)) {
ast_log(LOG_WARNING, "Read requires an variable name\n"); ast_log(LOG_WARNING, "Read requires an variable name\n");
return -1; return -1;
} }

View File

@@ -19,6 +19,7 @@
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/translate.h> #include <asterisk/translate.h>
#include <asterisk/options.h> #include <asterisk/options.h>
#include <asterisk/utils.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
@@ -44,7 +45,7 @@ static int senddtmf_exec(struct ast_channel *chan, void *data)
struct localuser *u; struct localuser *u;
char *digits = data; char *digits = data;
if (!digits || !strlen(digits)) { if (!digits || ast_strlen_zero(digits)) {
ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n"); ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
return -1; return -1;
} }

View File

@@ -19,7 +19,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/config.h> #include <asterisk/config.h>
#include <asterisk/manager.h> #include <asterisk/manager.h>
#include <asterisk/utils.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -68,11 +68,11 @@ static int action_setcdruserfield(struct mansession *s, struct message *m)
char *channel = astman_get_header(m, "Channel"); char *channel = astman_get_header(m, "Channel");
char *append = astman_get_header(m, "Append"); char *append = astman_get_header(m, "Append");
if (!strlen(channel)) { if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No Channel specified"); astman_send_error(s, m, "No Channel specified");
return 0; return 0;
} }
if (!strlen(userfield)) { if (ast_strlen_zero(userfield)) {
astman_send_error(s, m, "No UserField specified"); astman_send_error(s, m, "No UserField specified");
return 0; return 0;
} }

View File

@@ -20,6 +20,7 @@
#include <asterisk/translate.h> #include <asterisk/translate.h>
#include <asterisk/image.h> #include <asterisk/image.h>
#include <asterisk/callerid.h> #include <asterisk/callerid.h>
#include <asterisk/utils.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
@@ -63,17 +64,17 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
strncpy(oldcid, chan->callerid, sizeof(oldcid) - 1); strncpy(oldcid, chan->callerid, sizeof(oldcid) - 1);
ast_callerid_parse(oldcid, &n, &l); ast_callerid_parse(oldcid, &n, &l);
n = tmp; n = tmp;
if (strlen(n)) { if (!ast_strlen_zero(n)) {
if (l && strlen(l)) if (l && !ast_strlen_zero(l))
snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l); snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l);
else else
strncpy(newcid, tmp, sizeof(newcid) - 1); strncpy(newcid, tmp, sizeof(newcid) - 1);
} else if (l && strlen(l)) { } else if (l && !ast_strlen_zero(l)) {
strncpy(newcid, l, sizeof(newcid) - 1); strncpy(newcid, l, sizeof(newcid) - 1);
} }
} else } else
strncpy(newcid, tmp, sizeof(newcid)); strncpy(newcid, tmp, sizeof(newcid));
ast_set_callerid(chan, strlen(newcid) ? newcid : NULL, anitoo); ast_set_callerid(chan, !ast_strlen_zero(newcid) ? newcid : NULL, anitoo);
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
return res; return res;
} }

View File

@@ -21,6 +21,7 @@
#include <asterisk/translate.h> #include <asterisk/translate.h>
#include <asterisk/image.h> #include <asterisk/image.h>
#include <asterisk/callerid.h> #include <asterisk/callerid.h>
#include <asterisk/utils.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
@@ -64,17 +65,17 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
strncpy(oldcid, chan->callerid, sizeof(oldcid) - 1); strncpy(oldcid, chan->callerid, sizeof(oldcid) - 1);
ast_callerid_parse(oldcid, &n, &l); ast_callerid_parse(oldcid, &n, &l);
l = tmp; l = tmp;
if (strlen(l)) { if (!ast_strlen_zero(l)) {
if (n && strlen(n)) if (n && !ast_strlen_zero(n))
snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l); snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l);
else else
strncpy(newcid, tmp, sizeof(newcid) - 1); strncpy(newcid, tmp, sizeof(newcid) - 1);
} else if (n && strlen(n)) { } else if (n && !ast_strlen_zero(n)) {
strncpy(newcid, n, sizeof(newcid) - 1); strncpy(newcid, n, sizeof(newcid) - 1);
} }
} else } else
strncpy(newcid, tmp, sizeof(newcid)); strncpy(newcid, tmp, sizeof(newcid));
ast_set_callerid(chan, strlen(newcid) ? newcid : NULL, anitoo); ast_set_callerid(chan, !ast_strlen_zero(newcid) ? newcid : NULL, anitoo);
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
return res; return res;
} }

View File

@@ -34,6 +34,7 @@
#include <asterisk/musiconhold.h> #include <asterisk/musiconhold.h>
#include <asterisk/manager.h> #include <asterisk/manager.h>
#include <asterisk/parking.h> #include <asterisk/parking.h>
#include <asterisk/utils.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@@ -318,7 +319,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
if (p->chan) { if (p->chan) {
/* Note that we don't hangup if it's not a callback because Asterisk will do it /* Note that we don't hangup if it's not a callback because Asterisk will do it
for us when the PBX instance that called login finishes */ for us when the PBX instance that called login finishes */
if (strlen(p->loginchan)) if (!ast_strlen_zero(p->loginchan))
ast_hangup(p->chan); ast_hangup(p->chan);
p->chan = NULL; p->chan = NULL;
p->acknowledged = 0; p->acknowledged = 0;
@@ -437,7 +438,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
} }
ast_mutex_unlock(&p->lock); ast_mutex_unlock(&p->lock);
return res; return res;
} else if (strlen(p->loginchan)) { } else if (!ast_strlen_zero(p->loginchan)) {
time(&p->start); time(&p->start);
/* Call on this agent */ /* Call on this agent */
if (option_verbose > 2) if (option_verbose > 2)
@@ -509,7 +510,7 @@ static int agent_hangup(struct ast_channel *ast)
time(&p->start); time(&p->start);
if (p->chan) { if (p->chan) {
/* If they're dead, go ahead and hang up on the agent now */ /* If they're dead, go ahead and hang up on the agent now */
if (strlen(p->loginchan)) { if (!ast_strlen_zero(p->loginchan)) {
if (p->chan) { if (p->chan) {
/* Recognize the hangup and pass it along immediately */ /* Recognize the hangup and pass it along immediately */
ast_hangup(p->chan); ast_hangup(p->chan);
@@ -975,7 +976,7 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
while(p) { while(p) {
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) && if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) &&
!strlen(p->loginchan)) { ast_strlen_zero(p->loginchan)) {
if (p->chan) if (p->chan)
hasagent++; hasagent++;
if (!p->lastdisc.tv_sec) { if (!p->lastdisc.tv_sec) {
@@ -998,14 +999,14 @@ static struct ast_channel *agent_request(char *type, int format, void *data)
while(p) { while(p) {
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);
if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent))) { if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent))) {
if (p->chan || strlen(p->loginchan)) if (p->chan || !ast_strlen_zero(p->loginchan))
hasagent++; hasagent++;
if (!p->lastdisc.tv_sec) { if (!p->lastdisc.tv_sec) {
/* Agent must be registered, but not have any active call, and not be in a waiting state */ /* Agent must be registered, but not have any active call, and not be in a waiting state */
if (!p->owner && p->chan) { if (!p->owner && p->chan) {
/* Could still get a fixed agent */ /* Could still get a fixed agent */
chan = agent_new(p, AST_STATE_DOWN); chan = agent_new(p, AST_STATE_DOWN);
} else if (!p->owner && strlen(p->loginchan)) { } else if (!p->owner && !ast_strlen_zero(p->loginchan)) {
/* Adjustable agent */ /* Adjustable agent */
p->chan = ast_request("Local", format, p->loginchan); p->chan = ast_request("Local", format, p->loginchan);
if (p->chan) if (p->chan)
@@ -1069,7 +1070,7 @@ static int agents_show(int fd, int argc, char **argv)
else else
ast_cli(fd, "-- Pending call to agent %s\n", p->agent); ast_cli(fd, "-- Pending call to agent %s\n", p->agent);
} else { } else {
if (strlen(p->name)) if (!ast_strlen_zero(p->name))
snprintf(username, sizeof(username), "(%s) ", p->name); snprintf(username, sizeof(username), "(%s) ", p->name);
else else
strcpy(username, ""); strcpy(username, "");
@@ -1080,7 +1081,7 @@ static int agents_show(int fd, int argc, char **argv)
} else { } else {
strcpy(talkingto, " is idle"); strcpy(talkingto, " is idle");
} }
} else if (strlen(p->loginchan)) { } else if (!ast_strlen_zero(p->loginchan)) {
snprintf(location, sizeof(location) - 20, "available at '%s'", p->loginchan); snprintf(location, sizeof(location) - 20, "available at '%s'", p->loginchan);
strcpy(talkingto, ""); strcpy(talkingto, "");
if (p->acknowledged) if (p->acknowledged)
@@ -1089,7 +1090,7 @@ static int agents_show(int fd, int argc, char **argv)
strcpy(location, "not logged in"); strcpy(location, "not logged in");
strcpy(talkingto, ""); strcpy(talkingto, "");
} }
if (strlen(p->moh)) if (!ast_strlen_zero(p->moh))
snprintf(moh, sizeof(moh), " (musiconhold is '%s')", p->moh); snprintf(moh, sizeof(moh), " (musiconhold is '%s')", p->moh);
ast_cli(fd, "%-12.12s %s%s%s%s\n", p->agent, ast_cli(fd, "%-12.12s %s%s%s%s\n", p->agent,
username, location, talkingto, moh); username, location, talkingto, moh);
@@ -1160,7 +1161,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
if (chan->_state != AST_STATE_UP) if (chan->_state != AST_STATE_UP)
res = ast_answer(chan); res = ast_answer(chan);
if (!res) { if (!res) {
if( opt_user && strlen(opt_user)) if( opt_user && !ast_strlen_zero(opt_user))
strncpy( user, opt_user, AST_MAX_AGENT ); strncpy( user, opt_user, AST_MAX_AGENT );
else else
res = ast_app_getdata(chan, "agent-user", user, sizeof(user) - 1, 0); res = ast_app_getdata(chan, "agent-user", user, sizeof(user) - 1, 0);
@@ -1176,7 +1177,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
} }
ast_mutex_unlock(&agentlock); ast_mutex_unlock(&agentlock);
if (!res) { if (!res) {
if (strlen(xpass)) if (!ast_strlen_zero(xpass))
res = ast_app_getdata(chan, "agent-pass", pass, sizeof(pass) - 1, 0); res = ast_app_getdata(chan, "agent-pass", pass, sizeof(pass) - 1, 0);
else else
strcpy(pass, ""); strcpy(pass, "");
@@ -1205,7 +1206,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
res = 0; res = 0;
} else } else
res = ast_app_getdata(chan, "agent-newlocation", tmpchan+pos, sizeof(tmpchan) - 2, 0); res = ast_app_getdata(chan, "agent-newlocation", tmpchan+pos, sizeof(tmpchan) - 2, 0);
if (!strlen(tmpchan) || ast_exists_extension(chan, context && strlen(context) ? context : "default", tmpchan, if (ast_strlen_zero(tmpchan) || ast_exists_extension(chan, context && !ast_strlen_zero(context) ? context : "default", tmpchan,
1, NULL)) 1, NULL))
break; break;
if (exten) { if (exten) {
@@ -1227,18 +1228,18 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
} }
} }
if (!res) { if (!res) {
if (context && strlen(context) && strlen(tmpchan)) if (context && !ast_strlen_zero(context) && !ast_strlen_zero(tmpchan))
snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", tmpchan, context); snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", tmpchan, context);
else else
strncpy(p->loginchan, tmpchan, sizeof(p->loginchan) - 1); strncpy(p->loginchan, tmpchan, sizeof(p->loginchan) - 1);
if (!strlen(p->loginchan)) if (ast_strlen_zero(p->loginchan))
filename = "agent-loggedoff"; filename = "agent-loggedoff";
p->acknowledged = 0; p->acknowledged = 0;
/* store/clear the global variable that stores agentid based on the callerid */ /* store/clear the global variable that stores agentid based on the callerid */
if (chan->callerid) { if (chan->callerid) {
char agentvar[AST_MAX_BUF]; char agentvar[AST_MAX_BUF];
snprintf(agentvar, sizeof(agentvar), "%s_%s",GETAGENTBYCALLERID, chan->callerid); snprintf(agentvar, sizeof(agentvar), "%s_%s",GETAGENTBYCALLERID, chan->callerid);
if (!strlen(p->loginchan)) if (ast_strlen_zero(p->loginchan))
pbx_builtin_setvar_helper(NULL, agentvar, NULL); pbx_builtin_setvar_helper(NULL, agentvar, NULL);
else else
pbx_builtin_setvar_helper(NULL, agentvar, p->agent); pbx_builtin_setvar_helper(NULL, agentvar, p->agent);

View File

@@ -17,6 +17,7 @@
#include <asterisk/options.h> #include <asterisk/options.h>
#include <asterisk/cli.h> #include <asterisk/cli.h>
#include <asterisk/term.h> #include <asterisk/term.h>
#include <asterisk/utils.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
@@ -703,7 +704,7 @@ void ast_frame_dump(char *name, struct ast_frame *f, char *prefix)
default: default:
snprintf(ftype, sizeof(ftype), "Unknown Frametype '%d'", f->frametype); snprintf(ftype, sizeof(ftype), "Unknown Frametype '%d'", f->frametype);
} }
if (strlen(moreinfo)) if (!ast_strlen_zero(moreinfo))
ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n", ast_verbose("%s [ TYPE: %s (%d) SUBCLASS: %s (%d) '%s' ] [%s]\n",
term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)),
term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)), term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),