diff --git a/apps/app_directory.c b/apps/app_directory.c index 8f0de923605eb12e29172df87e355753556cc211..b267559ba301c74864e67930b0b401491fdf8a4f 100755 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -19,6 +19,7 @@ #include <asterisk/module.h> #include <asterisk/config.h> #include <asterisk/say.h> +#include <asterisk/utils.h> #include <string.h> #include <ctype.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 fn[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"); 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); ast_stopstream(chan); } 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: if (!res) @@ -260,9 +261,9 @@ top: } else dialcontext = context; dirintro = ast_variable_retrieve(cfg, context, "directoryintro"); - if (!dirintro || !strlen(dirintro)) + if (!dirintro || ast_strlen_zero(dirintro)) dirintro = ast_variable_retrieve(cfg, "general", "directoryintro"); - if (!dirintro || !strlen(dirintro)) + if (!dirintro || ast_strlen_zero(dirintro)) dirintro = "dir-intro"; if (chan->_state != AST_STATE_UP) res = ast_answer(chan); diff --git a/apps/app_enumlookup.c b/apps/app_enumlookup.c index c03eb97ac203ffb1c1b0817ac7fe2f0c26015aac..148477e99b6e025d21913e271f9b4be37026f26d 100755 --- a/apps/app_enumlookup.c +++ b/apps/app_enumlookup.c @@ -20,6 +20,7 @@ #include <asterisk/config.h> #include <asterisk/module.h> #include <asterisk/enum.h> +#include <asterisk/utils.h> #include <stdlib.h> #include <unistd.h> #include <string.h> @@ -64,7 +65,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data) char tmp[256]; char *c,*t; struct localuser *u; - if (!data || !strlen(data)) { + if (!data || ast_strlen_zero(data)) { ast_log(LOG_WARNING, "EnumLookup requires an argument (extension)\n"); res = 1; } @@ -128,7 +129,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data) else 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); res = 0; } diff --git a/apps/app_festival.c b/apps/app_festival.c index 99b6226a04fd7357e1af89e6954116be7ad2688d..3076d9a420194bfd7009f5d9a97157400f18b2cf 100755 --- a/apps/app_festival.c +++ b/apps/app_festival.c @@ -19,6 +19,7 @@ #include <asterisk/module.h> #include <asterisk/md5.h> #include <asterisk/config.h> +#include <asterisk/utils.h> #include <stdlib.h> #include <unistd.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"))) { festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n"; } - - - - if (!vdata || !strlen(vdata)) { + if (!vdata || ast_strlen_zero(vdata)) { ast_log(LOG_WARNING, "festival requires an argument (text)\n"); return -1; } diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c index 778a1399b729b5502abc8918bde61c4bf29920d7..ef7b92cd99a519c41646c76aa37b1ea5ad549f25 100755 --- a/apps/app_groupcount.c +++ b/apps/app_groupcount.c @@ -21,6 +21,7 @@ #include <asterisk/channel.h> #include <asterisk/pbx.h> #include <asterisk/module.h> +#include <asterisk/utils.h> static char *tdesc = "Group Management Routines"; @@ -64,7 +65,7 @@ static int group_get_count(char *group) struct ast_channel *chan; int count = 0; char *test; - if (group && strlen(group)) { + if (group && !ast_strlen_zero(group)) { chan = ast_channel_walk(NULL); while(chan) { 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); /* Check and parse arguments */ - if (data && strlen(data)) { + if (data && !ast_strlen_zero(data)) { group = (char *)data; } else { 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); /* Check and parse arguments */ - if (data && strlen(data)) { + if (data && !ast_strlen_zero(data)) { pbx_builtin_setvar_helper(chan, "GROUP", (char *)data); } else ast_log(LOG_WARNING, "GroupSet requires an argument (group name)\n"); diff --git a/apps/app_playback.c b/apps/app_playback.c index aece3e67528f59c046cf7d2082b4a4d0a50f1945..b547547a0eb29d68da15dbce8fda8b23b16e02f2 100755 --- a/apps/app_playback.c +++ b/apps/app_playback.c @@ -18,6 +18,7 @@ #include <asterisk/pbx.h> #include <asterisk/module.h> #include <asterisk/translate.h> +#include <asterisk/utils.h> #include <string.h> #include <stdlib.h> #include <pthread.h> @@ -52,7 +53,7 @@ static int playback_exec(struct ast_channel *chan, void *data) int option_skip=0; int option_noanswer = 0; char *stringp; - if (!data || !strlen((char *)data)) { + if (!data || ast_strlen_zero((char *)data)) { ast_log(LOG_WARNING, "Playback requires an argument (filename)\n"); return -1; } diff --git a/apps/app_queue.c b/apps/app_queue.c index a9f365dd4c97057b588bc9b49d113ba1b2caa24d..7328a02b6358851f7b00b5fc6283b4f1de59fc3f 100755 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -39,9 +39,10 @@ #include <asterisk/parking.h> #include <asterisk/musiconhold.h> #include <asterisk/cli.h> -#include <asterisk/manager.h> /* JDG */ +#include <asterisk/manager.h> #include <asterisk/config.h> #include <asterisk/monitor.h> +#include <asterisk/utils.h> #include <stdlib.h> #include <errno.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) { char tmp[2]; - if (!strlen(qe->context)) + if (ast_strlen_zero(qe->context)) return 0; tmp[0] = digit; 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); time(&now); cur = qe->parent->members; - if (strlen(qe->announce)) + if (!ast_strlen_zero(qe->announce)) announce = qe->announce; - if (announceoverride && strlen(announceoverride)) + if (announceoverride && !ast_strlen_zero(announceoverride)) announce = announceoverride; while(cur) { /* 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 */ leave_queue(qe); - /* JDG: sendurl */ - if( url && strlen(url) && ast_channel_supports_html(peer) ) { + if( url && !ast_strlen_zero(url) && ast_channel_supports_html(peer) ) { ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url); ast_channel_sendurl( peer, url ); - } /* /JDG */ + } 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(oldexten, qe->chan->exten, sizeof(oldexten) - 1); diff --git a/apps/app_read.c b/apps/app_read.c index caf84782804bb7ceae8505770ac1bc1e1b79d2c4..3819afed198e28b290d9b51b57e79e4f4bad1bb7 100755 --- a/apps/app_read.c +++ b/apps/app_read.c @@ -20,6 +20,7 @@ #include <asterisk/module.h> #include <asterisk/translate.h> #include <asterisk/options.h> +#include <asterisk/utils.h> #include <string.h> #include <stdlib.h> #include <pthread.h> @@ -53,7 +54,7 @@ static int read_exec(struct ast_channel *chan, void *data) char *stringp; char *maxdigitstr; 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"); return -1; } @@ -63,17 +64,16 @@ static int read_exec(struct ast_channel *chan, void *data) varname = strsep(&stringp, "|"); filename = strsep(&stringp, "|"); maxdigitstr = strsep(&stringp,"|"); - if (!(filename) || (strlen(filename)==0)) filename = NULL; - if (maxdigitstr) - { + if (!(filename) || ast_strlen_zero(filename)) + filename = NULL; + if (maxdigitstr) { maxdigits = atoi(maxdigitstr); if ((maxdigits<1) || (maxdigits>255)) { maxdigits = 255; - } - else + } else 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"); return -1; } diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c index 58e99b21cb5b0cb0240d5b114b2a3885f39e2557..a8731e5dd063a31ea619518016bdcf88fd9e5642 100755 --- a/apps/app_senddtmf.c +++ b/apps/app_senddtmf.c @@ -19,6 +19,7 @@ #include <asterisk/module.h> #include <asterisk/translate.h> #include <asterisk/options.h> +#include <asterisk/utils.h> #include <string.h> #include <stdlib.h> #include <pthread.h> @@ -44,7 +45,7 @@ static int senddtmf_exec(struct ast_channel *chan, void *data) struct localuser *u; 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"); return -1; } diff --git a/apps/app_setcdruserfield.c b/apps/app_setcdruserfield.c index 7d2a5bb0839e04e38df80a782581071ca370648a..bb1bb339e91eb211f0d71b7266ae299fef315b53 100755 --- a/apps/app_setcdruserfield.c +++ b/apps/app_setcdruserfield.c @@ -19,7 +19,7 @@ #include <asterisk/logger.h> #include <asterisk/config.h> #include <asterisk/manager.h> - +#include <asterisk/utils.h> #include <stdlib.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 *append = astman_get_header(m, "Append"); - if (!strlen(channel)) { + if (ast_strlen_zero(channel)) { astman_send_error(s, m, "No Channel specified"); return 0; } - if (!strlen(userfield)) { + if (ast_strlen_zero(userfield)) { astman_send_error(s, m, "No UserField specified"); return 0; } diff --git a/apps/app_setcidname.c b/apps/app_setcidname.c index d5904429553d6330fe21bed2fe7768171501acc7..089d35f2f4f153cdc43c9632e7c33d23a9c9a49a 100755 --- a/apps/app_setcidname.c +++ b/apps/app_setcidname.c @@ -20,6 +20,7 @@ #include <asterisk/translate.h> #include <asterisk/image.h> #include <asterisk/callerid.h> +#include <asterisk/utils.h> #include <string.h> #include <stdlib.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); ast_callerid_parse(oldcid, &n, &l); n = tmp; - if (strlen(n)) { - if (l && strlen(l)) + if (!ast_strlen_zero(n)) { + if (l && !ast_strlen_zero(l)) snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l); else strncpy(newcid, tmp, sizeof(newcid) - 1); - } else if (l && strlen(l)) { + } else if (l && !ast_strlen_zero(l)) { strncpy(newcid, l, sizeof(newcid) - 1); } } else 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); return res; } diff --git a/apps/app_setcidnum.c b/apps/app_setcidnum.c index 97eb9bba1527d84c5f975336042cd58e10577d60..a4ded6b295f9d954af7f08c6647939e5e26d2b47 100755 --- a/apps/app_setcidnum.c +++ b/apps/app_setcidnum.c @@ -21,6 +21,7 @@ #include <asterisk/translate.h> #include <asterisk/image.h> #include <asterisk/callerid.h> +#include <asterisk/utils.h> #include <string.h> #include <stdlib.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); ast_callerid_parse(oldcid, &n, &l); l = tmp; - if (strlen(l)) { - if (n && strlen(n)) + if (!ast_strlen_zero(l)) { + if (n && !ast_strlen_zero(n)) snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l); else strncpy(newcid, tmp, sizeof(newcid) - 1); - } else if (n && strlen(n)) { + } else if (n && !ast_strlen_zero(n)) { strncpy(newcid, n, sizeof(newcid) - 1); } } else 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); return res; } diff --git a/channels/chan_agent.c b/channels/chan_agent.c index f5c4e3a5112f6669c7b5934bd7f9611245dfbd18..cda4eafb0a482e334a3b9c6c46bd6a3dc5167510 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -34,6 +34,7 @@ #include <asterisk/musiconhold.h> #include <asterisk/manager.h> #include <asterisk/parking.h> +#include <asterisk/utils.h> #include <sys/socket.h> #include <errno.h> #include <unistd.h> @@ -318,7 +319,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast) if (p->chan) { /* 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 */ - if (strlen(p->loginchan)) + if (!ast_strlen_zero(p->loginchan)) ast_hangup(p->chan); p->chan = NULL; p->acknowledged = 0; @@ -437,7 +438,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout) } ast_mutex_unlock(&p->lock); return res; - } else if (strlen(p->loginchan)) { + } else if (!ast_strlen_zero(p->loginchan)) { time(&p->start); /* Call on this agent */ if (option_verbose > 2) @@ -509,7 +510,7 @@ static int agent_hangup(struct ast_channel *ast) time(&p->start); if (p->chan) { /* 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) { /* Recognize the hangup and pass it along immediately */ ast_hangup(p->chan); @@ -975,7 +976,7 @@ static struct ast_channel *agent_request(char *type, int format, void *data) while(p) { ast_mutex_lock(&p->lock); if (!p->pending && ((groupmatch && (p->group & groupmatch)) || !strcmp(data, p->agent)) && - !strlen(p->loginchan)) { + ast_strlen_zero(p->loginchan)) { if (p->chan) hasagent++; if (!p->lastdisc.tv_sec) { @@ -998,14 +999,14 @@ static struct ast_channel *agent_request(char *type, int format, void *data) while(p) { ast_mutex_lock(&p->lock); 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++; if (!p->lastdisc.tv_sec) { /* Agent must be registered, but not have any active call, and not be in a waiting state */ if (!p->owner && p->chan) { /* Could still get a fixed agent */ 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 */ p->chan = ast_request("Local", format, p->loginchan); if (p->chan) @@ -1069,7 +1070,7 @@ static int agents_show(int fd, int argc, char **argv) else ast_cli(fd, "-- Pending call to agent %s\n", p->agent); } else { - if (strlen(p->name)) + if (!ast_strlen_zero(p->name)) snprintf(username, sizeof(username), "(%s) ", p->name); else strcpy(username, ""); @@ -1080,7 +1081,7 @@ static int agents_show(int fd, int argc, char **argv) } else { 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); strcpy(talkingto, ""); if (p->acknowledged) @@ -1089,7 +1090,7 @@ static int agents_show(int fd, int argc, char **argv) strcpy(location, "not logged in"); strcpy(talkingto, ""); } - if (strlen(p->moh)) + if (!ast_strlen_zero(p->moh)) snprintf(moh, sizeof(moh), " (musiconhold is '%s')", p->moh); ast_cli(fd, "%-12.12s %s%s%s%s\n", p->agent, 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) res = ast_answer(chan); if (!res) { - if( opt_user && strlen(opt_user)) + if( opt_user && !ast_strlen_zero(opt_user)) strncpy( user, opt_user, AST_MAX_AGENT ); else 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); if (!res) { - if (strlen(xpass)) + if (!ast_strlen_zero(xpass)) res = ast_app_getdata(chan, "agent-pass", pass, sizeof(pass) - 1, 0); else strcpy(pass, ""); @@ -1205,7 +1206,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode) res = 0; } else 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)) break; if (exten) { @@ -1227,18 +1228,18 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode) } } 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); else strncpy(p->loginchan, tmpchan, sizeof(p->loginchan) - 1); - if (!strlen(p->loginchan)) + if (ast_strlen_zero(p->loginchan)) filename = "agent-loggedoff"; p->acknowledged = 0; /* store/clear the global variable that stores agentid based on the callerid */ if (chan->callerid) { char agentvar[AST_MAX_BUF]; 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); else pbx_builtin_setvar_helper(NULL, agentvar, p->agent); diff --git a/frame.c b/frame.c index b8709eee13dea7cf9548f846bb6465c4f7bc51ec..c127ebcdde8af9312fca64977e6b298ee30327fa 100755 --- a/frame.c +++ b/frame.c @@ -17,6 +17,7 @@ #include <asterisk/options.h> #include <asterisk/cli.h> #include <asterisk/term.h> +#include <asterisk/utils.h> #include <stdlib.h> #include <unistd.h> #include <string.h> @@ -703,7 +704,7 @@ void ast_frame_dump(char *name, struct ast_frame *f, char *prefix) default: 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", term_color(cp, prefix, COLOR_BRMAGENTA, COLOR_BLACK, sizeof(cp)), term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),