From df7637f687ae77d18923d52fabaa7e814c0d4a24 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 23 Oct 2009 16:03:42 +0000 Subject: [PATCH] change switch_strlen_zero to zstr git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15211 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_utils.h | 6 +- .../mod_cidlookup/mod_cidlookup.c | 6 +- .../applications/mod_commands/mod_commands.c | 166 ++++++++--------- .../mod_conference/mod_conference.c | 176 +++++++++--------- src/mod/applications/mod_curl/mod_curl.c | 6 +- .../mod_directory/mod_directory.c | 22 +-- .../applications/mod_dptools/mod_dptools.c | 114 ++++++------ .../mod_easyroute/mod_easyroute.c | 18 +- src/mod/applications/mod_enum/mod_enum.c | 4 +- src/mod/applications/mod_esf/mod_esf.c | 10 +- src/mod/applications/mod_expr/mod_expr.c | 2 +- src/mod/applications/mod_fax/mod_fax.c | 8 +- src/mod/applications/mod_fifo/mod_fifo.c | 30 +-- src/mod/applications/mod_lcr/mod_lcr.c | 60 +++--- src/mod/applications/mod_limit/mod_limit.c | 40 ++-- .../applications/mod_memcache/mod_memcache.c | 2 +- .../mod_nibblebill/mod_nibblebill.c | 18 +- src/mod/applications/mod_rss/mod_rss.c | 4 +- .../mod_soundtouch/mod_soundtouch.cpp | 2 +- src/mod/applications/mod_spy/mod_spy.c | 2 +- .../applications/mod_stress/mod_stress.cpp | 2 +- .../mod_valet_parking/mod_valet_parking.c | 4 +- src/mod/applications/mod_vmd/mod_vmd.c | 2 +- .../mod_voicemail/mod_voicemail.c | 90 ++++----- src/mod/asr_tts/mod_cepstral/mod_cepstral.c | 8 +- .../mod_pocketsphinx/mod_pocketsphinx.c | 4 +- .../mod_tts_commandline/mod_tts_commandline.c | 2 +- src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 60 +++--- .../mod_dialplan_asterisk.c | 6 +- .../mod_dialplan_xml/mod_dialplan_xml.c | 4 +- src/mod/endpoints/mod_alsa/mod_alsa.c | 26 +-- .../endpoints/mod_dingaling/mod_dingaling.c | 34 ++-- src/mod/endpoints/mod_loopback/mod_loopback.c | 8 +- .../endpoints/mod_portaudio/mod_portaudio.c | 28 +-- src/mod/endpoints/mod_skypiax/mod_skypiax.c | 16 +- src/mod/endpoints/mod_sofia/mod_sofia.c | 134 ++++++------- src/mod/endpoints/mod_sofia/mod_sofia.h | 2 +- src/mod/endpoints/mod_sofia/sofia.c | 134 ++++++------- src/mod/endpoints/mod_sofia/sofia_glue.c | 84 ++++----- src/mod/endpoints/mod_sofia/sofia_presence.c | 60 +++--- src/mod/endpoints/mod_sofia/sofia_reg.c | 26 +-- .../event_handlers/mod_cdr_csv/mod_cdr_csv.c | 2 +- .../mod_erlang_event/ei_helpers.c | 2 +- .../mod_erlang_event/handle_msg.c | 4 +- .../mod_erlang_event/mod_erlang_event.c | 16 +- .../mod_event_socket/mod_event_socket.c | 34 ++-- .../mod_local_stream/mod_local_stream.c | 10 +- .../mod_portaudio_stream.c | 2 +- src/mod/languages/mod_lua/freeswitch_lua.cpp | 8 +- src/mod/languages/mod_lua/mod_lua.cpp | 20 +- src/mod/languages/mod_managed/mod_managed.cpp | 8 +- src/mod/languages/mod_perl/mod_perl.c | 26 +-- src/mod/languages/mod_python/mod_python.c | 8 +- .../mod_spidermonkey/mod_spidermonkey.c | 42 ++--- .../mod_spidermonkey_curl.c | 4 +- .../mod_spidermonkey_odbc.c | 4 +- src/mod/languages/mod_yaml/mod_yaml.c | 2 +- src/mod/loggers/mod_console/mod_console.c | 4 +- src/mod/loggers/mod_logfile/mod_logfile.c | 2 +- src/mod/loggers/mod_syslog/mod_syslog.c | 10 +- src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c | 28 +-- src/mod/xml_int/mod_xml_curl/mod_xml_curl.c | 6 +- src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c | 4 +- src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c | 2 +- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 14 +- src/switch_caller.c | 36 ++-- src/switch_channel.c | 32 ++-- src/switch_console.c | 4 +- src/switch_core.c | 18 +- src/switch_core_asr.c | 8 +- src/switch_core_file.c | 2 +- src/switch_core_io.c | 2 +- src/switch_core_memory.c | 6 +- src/switch_core_session.c | 8 +- src/switch_core_speech.c | 10 +- src/switch_core_sqldb.c | 8 +- src/switch_core_state_machine.c | 6 +- src/switch_cpp.cpp | 8 +- src/switch_event.c | 4 +- src/switch_ivr.c | 40 ++-- src/switch_ivr_async.c | 12 +- src/switch_ivr_bridge.c | 18 +- src/switch_ivr_menu.c | 36 ++-- src/switch_ivr_originate.c | 24 +-- src/switch_ivr_play_say.c | 24 +-- src/switch_loadable_module.c | 8 +- src/switch_log.c | 8 +- src/switch_nat.c | 2 +- src/switch_odbc.c | 2 +- src/switch_rtp.c | 16 +- src/switch_scheduler.c | 2 +- src/switch_swig.c | 2 +- src/switch_time.c | 12 +- src/switch_utils.c | 10 +- src/switch_xml.c | 4 +- src/switch_xml_config.c | 2 +- 96 files changed, 1033 insertions(+), 1033 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 966f4e5a47..d75af5b9b9 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -74,11 +74,11 @@ SWITCH_DECLARE(int) switch_isxdigit(int c); \param s the string to test \return true value if the string is NULL or zero length */ -#define switch_strlen_zero(s) (!s || *(s) == '\0') -#define switch_strlen_zero_buf(s) (*(s) == '\0') +#define zstr(s) (!s || *(s) == '\0') +#define zstr_buf(s) (*(s) == '\0') static inline switch_bool_t switch_is_moh(const char *s) { - if (switch_strlen_zero(s) || !strcasecmp(s, "silence") || !strcasecmp(s, "indicate_hold")) { + if (zstr(s) || !strcasecmp(s, "silence") || !strcasecmp(s, "indicate_hold")) { return SWITCH_FALSE; } return SWITCH_TRUE; diff --git a/src/mod/applications/mod_cidlookup/mod_cidlookup.c b/src/mod/applications/mod_cidlookup/mod_cidlookup.c index 57cebd6ffd..349f4f97a2 100755 --- a/src/mod/applications/mod_cidlookup/mod_cidlookup.c +++ b/src/mod/applications/mod_cidlookup/mod_cidlookup.c @@ -98,7 +98,7 @@ static switch_status_t config_callback_dsn(switch_xml_config_item_t *data, const if ((callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD) && changed) { - if(switch_strlen_zero(newvalue)) { + if(zstr(newvalue)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No local database defined.\n"); } else { odbc_dsn = strdup(newvalue); @@ -325,7 +325,7 @@ static char *do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, co curl_easy_cleanup(curl_handle); if ( http_data.stream.data && - !switch_strlen_zero((char *)http_data.stream.data) && + !zstr((char *)http_data.stream.data) && strcmp(" ", http_data.stream.data) ) { name = switch_core_strdup(pool, http_data.stream.data); @@ -564,7 +564,7 @@ SWITCH_STANDARD_API(cidlookup_function) switch_bool_t skipurl = SWITCH_FALSE; switch_bool_t skipcitystate = SWITCH_FALSE; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); } diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index c202878842..75cdef4f93 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -49,7 +49,7 @@ SWITCH_STANDARD_API(host_lookup_function) { char host[256] = ""; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", "parameter missing\n"); } else { if (switch_resolve_host(cmd, host, sizeof(host)) == SWITCH_STATUS_SUCCESS) { @@ -146,7 +146,7 @@ SWITCH_STANDARD_API(time_test_function) int diff; int max = 10; char *p; - if (switch_strlen_zero(cmd)){ + if (zstr(cmd)){ stream->write_function(stream, "parameter missing\n"); return SWITCH_STATUS_SUCCESS; } @@ -189,7 +189,7 @@ SWITCH_STANDARD_API(group_call_function) char *fp = NULL; const char *call_delim = ","; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto end; } @@ -224,7 +224,7 @@ SWITCH_STANDARD_API(group_call_function) domain = switch_core_get_variable("domain"); } - if (!switch_strlen_zero(domain)) { + if (!zstr(domain)) { switch_xml_t xml, x_domain, x_group; switch_event_t *params; switch_stream_handle_t dstream = { 0 }; @@ -377,7 +377,7 @@ SWITCH_STANDARD_API(in_group_function) const char *rval = "false"; char *group; - if (switch_strlen_zero(cmd) || !(mydata = strdup(cmd))) { + if (zstr(cmd) || !(mydata = strdup(cmd))) { goto end; } @@ -427,7 +427,7 @@ SWITCH_STANDARD_API(user_data_function) const char *container = "params", *elem = "param"; switch_event_t *params = NULL; - if (switch_strlen_zero(cmd) || !(mydata = strdup(cmd))) { + if (zstr(cmd) || !(mydata = strdup(cmd))) { goto end; } @@ -580,7 +580,7 @@ SWITCH_STANDARD_API(md5_function) { char digest[SWITCH_MD5_DIGEST_STRING_SIZE] = { 0 }; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", "!err!"); } else { switch_md5_string(digest, (void *) cmd, strlen(cmd)); @@ -595,7 +595,7 @@ SWITCH_STANDARD_API(url_decode_function) char *reply = ""; char *data = NULL; - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { data = strdup(cmd); switch_url_decode(data); reply = data; @@ -627,7 +627,7 @@ SWITCH_STANDARD_API(stun_function) ip = ip_buf; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", "-STUN Failed! NO STUN SERVER\n"); return SWITCH_STATUS_SUCCESS; } @@ -658,7 +658,7 @@ SWITCH_STANDARD_API(stun_function) switch_core_new_memory_pool(&pool); - if (switch_strlen_zero(stun_ip)) { + if (zstr(stun_ip)) { stream->write_function(stream, "%s", "-STUN Failed! NO STUN SERVER\n"); } else { if ((switch_stun_lookup(&ip, &port, stun_ip, stun_port, &error, pool)) == SWITCH_STATUS_SUCCESS && ip && port) { @@ -684,7 +684,7 @@ SWITCH_STANDARD_API(expand_function) switch_core_session_t *xsession; char uuid[80] = ""; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR, no input\n"); return SWITCH_STATUS_SUCCESS; } @@ -699,7 +699,7 @@ SWITCH_STANDARD_API(expand_function) } } - if (switch_strlen_zero(mycmd)) { + if (zstr(mycmd)) { stream->write_function(stream, "-ERR, no input\n"); return SWITCH_STATUS_SUCCESS; } @@ -739,7 +739,7 @@ SWITCH_STANDARD_API(eval_function) char uuid[80] = ""; const char *p, *input = cmd; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", ""); return SWITCH_STATUS_SUCCESS; } @@ -751,7 +751,7 @@ SWITCH_STANDARD_API(eval_function) } } - if (switch_strlen_zero(input)) { + if (zstr(input)) { stream->write_function(stream, "%s", ""); return SWITCH_STATUS_SUCCESS; } @@ -778,7 +778,7 @@ SWITCH_STANDARD_API(eval_function) SWITCH_STANDARD_API(module_exists_function) { - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { if (switch_loadable_module_exists(cmd) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "true"); } else { @@ -793,7 +793,7 @@ SWITCH_STANDARD_API(domain_exists_function) { switch_xml_t root = NULL, domain = NULL; - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { if (switch_xml_locate_domain(cmd, NULL, &root, &domain) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "true"); switch_xml_free(root); @@ -811,7 +811,7 @@ SWITCH_STANDARD_API(url_encode_function) char *data = NULL; int len = 0 ; - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { len = (strlen(cmd) * 3) + 1; switch_zmalloc(data, len); switch_url_encode(cmd, data, len); @@ -1249,7 +1249,7 @@ SWITCH_STANDARD_API(ctl_function) char *mydata, *argv[5]; int32_t arg = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", CTL_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1374,7 +1374,7 @@ SWITCH_STANDARD_API(load_function) { const char *err; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", LOAD_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1395,7 +1395,7 @@ SWITCH_STANDARD_API(unload_function) switch_bool_t force = SWITCH_FALSE; const char *p = cmd; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1419,7 +1419,7 @@ SWITCH_STANDARD_API(unload_function) } end: - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1439,7 +1439,7 @@ SWITCH_STANDARD_API(reload_function) switch_bool_t force = SWITCH_FALSE; const char *p = cmd; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1462,7 +1462,7 @@ SWITCH_STANDARD_API(reload_function) } end: - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1504,7 +1504,7 @@ SWITCH_STANDARD_API(kill_function) char *mycmd = NULL, *kcause = NULL; switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; - if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) { + if (zstr(cmd) || !(mycmd = strdup(cmd))) { stream->write_function(stream, "-USAGE: %s\n", KILL_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1513,11 +1513,11 @@ SWITCH_STANDARD_API(kill_function) *kcause++ = '\0'; } - if (switch_strlen_zero(mycmd) || !(ksession = switch_core_session_locate(mycmd))) { + if (zstr(mycmd) || !(ksession = switch_core_session_locate(mycmd))) { stream->write_function(stream, "-ERR No Such Channel!\n"); } else { switch_channel_t *channel = switch_core_session_get_channel(ksession); - if (!switch_strlen_zero(kcause)){ + if (!zstr(kcause)){ cause = switch_channel_str2cause(kcause); } switch_channel_hangup(channel, cause); @@ -1536,7 +1536,7 @@ SWITCH_STANDARD_API(preprocess_function) char *mycmd = NULL, *argv[3] = { 0 }; int argc = 0; - if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) { + if (zstr(cmd) || !(mycmd = strdup(cmd))) { goto usage; } @@ -1590,7 +1590,7 @@ SWITCH_STANDARD_API(transfer_function) int argc = 0; char *tuuid, *dest, *dp, *context, *arg = NULL; - if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) { + if (zstr(cmd) || !(mycmd = strdup(cmd))) { stream->write_function(stream, "-USAGE: %s\n", TRANSFER_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1606,7 +1606,7 @@ SWITCH_STANDARD_API(transfer_function) dp = argv[2]; context = argv[3]; - if (switch_strlen_zero(tuuid) || !(tsession = switch_core_session_locate(tuuid))) { + if (zstr(tuuid) || !(tsession = switch_core_session_locate(tuuid))) { stream->write_function(stream, "-ERR No Such Channel!\n"); goto done; } @@ -1734,13 +1734,13 @@ SWITCH_STANDARD_API(uuid_chat) switch_core_session_t *tsession = NULL; char *uuid = NULL, *text = NULL; - if (!switch_strlen_zero(cmd) && (uuid = strdup(cmd))) { + if (!zstr(cmd) && (uuid = strdup(cmd))) { if ((text = strchr(uuid, ' '))) { *text++ = '\0'; } } - if (switch_strlen_zero(uuid) || switch_strlen_zero(text)) { + if (zstr(uuid) || zstr(text)) { stream->write_function(stream, "-USAGE: %s\n", UUID_CHAT_SYNTAX); } else { if ((tsession = switch_core_session_locate(uuid))) { @@ -1772,13 +1772,13 @@ SWITCH_STANDARD_API(uuid_deflect) switch_core_session_t *tsession = NULL; char *uuid = NULL, *text = NULL; - if (!switch_strlen_zero(cmd) && (uuid = strdup(cmd))) { + if (!zstr(cmd) && (uuid = strdup(cmd))) { if ((text = strchr(uuid, ' '))) { *text++ = '\0'; } } - if (switch_strlen_zero(uuid) || switch_strlen_zero(text)) { + if (zstr(uuid) || zstr(text)) { stream->write_function(stream, "-USAGE: %s\n", UUID_DEFLECT_SYNTAX); } else { if ((tsession = switch_core_session_locate(uuid))) { @@ -1807,11 +1807,11 @@ SWITCH_STANDARD_API(sched_transfer_function) char *mycmd = NULL, *argv[6] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 2 || argc > 5 || switch_strlen_zero(argv[0])) { + if (zstr(cmd) || argc < 2 || argc > 5 || zstr(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", SCHED_TRANSFER_SYNTAX); } else { char *uuid = argv[1]; @@ -1846,11 +1846,11 @@ SWITCH_STANDARD_API(sched_hangup_function) char *mycmd = NULL, *argv[4] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 1 || switch_strlen_zero(argv[0])) { + if (zstr(cmd) || argc < 1 || zstr(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", SCHED_HANGUP_SYNTAX); } else { char *uuid = argv[1]; @@ -1888,11 +1888,11 @@ SWITCH_STANDARD_API(uuid_media_function) int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 1 || switch_strlen_zero(argv[0])) { + if (zstr(cmd) || argc < 1 || zstr(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", MEDIA_SYNTAX); } else { if (!strcasecmp(argv[0], "off")) { @@ -1919,11 +1919,11 @@ SWITCH_STANDARD_API(uuid_broadcast_function) int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 2) { + if (zstr(cmd) || argc < 2) { stream->write_function(stream, "-USAGE: %s\n", BROADCAST_SYNTAX); } else { switch_media_flag_t flags = SMF_NONE; @@ -1955,11 +1955,11 @@ SWITCH_STANDARD_API(sched_broadcast_function) int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 3 || switch_strlen_zero(argv[0])) { + if (zstr(cmd) || argc < 3 || zstr(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", SCHED_BROADCAST_SYNTAX); } else { switch_media_flag_t flags = SMF_NONE; @@ -1998,11 +1998,11 @@ SWITCH_STANDARD_API(uuid_hold_function) int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 1 || switch_strlen_zero(argv[0])) { + if (zstr(cmd) || argc < 1 || zstr(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", HOLD_SYNTAX); } else { if (!strcasecmp(argv[0], "off")) { @@ -2029,11 +2029,11 @@ SWITCH_STANDARD_API(uuid_display_function) int argc = 0; switch_status_t status = SWITCH_STATUS_FALSE; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 2 || switch_strlen_zero(argv[0]) || switch_strlen_zero(argv[1])) { + if (zstr(cmd) || argc < 2 || zstr(argv[0]) || zstr(argv[1])) { stream->write_function(stream, "-USAGE: %s\n", DISPLAY_SYNTAX); } else { switch_core_session_message_t msg = { 0 }; @@ -2065,11 +2065,11 @@ SWITCH_STANDARD_API(uuid_bridge_function) char *mycmd = NULL, *argv[4] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 2) { + if (zstr(cmd) || argc < 2) { stream->write_function(stream, "-USAGE: %s\n", UUID_SYNTAX); } else { switch_status_t status; @@ -2105,7 +2105,7 @@ SWITCH_STANDARD_API(session_record_function) int argc = 0; uint32_t limit = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -2122,7 +2122,7 @@ SWITCH_STANDARD_API(session_record_function) path = argv[2]; limit = argv[3] ? atoi(argv[3]) : 0; - if (switch_strlen_zero(uuid) || switch_strlen_zero(action) || switch_strlen_zero(path)) { + if (zstr(uuid) || zstr(action) || zstr(path)) { goto usage; } @@ -2171,7 +2171,7 @@ SWITCH_STANDARD_API(session_displace_function) uint32_t limit = 0; char *flags = NULL; - if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) { + if (zstr(cmd) || !(mycmd = strdup(cmd))) { goto usage; } @@ -2185,7 +2185,7 @@ SWITCH_STANDARD_API(session_displace_function) limit = argv[3] ? atoi(argv[3]) : 0; flags = argv[4]; - if (switch_strlen_zero(uuid) || switch_strlen_zero(action) || switch_strlen_zero(path)) { + if (zstr(uuid) || zstr(action) || zstr(path)) { goto usage; } @@ -2232,7 +2232,7 @@ SWITCH_STANDARD_API(break_function) switch_channel_t *channel = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", BREAK_SYNTAX); goto done; } @@ -2277,11 +2277,11 @@ SWITCH_STANDARD_API(pause_function) char *mycmd = NULL, *argv[4] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 2 || switch_strlen_zero(argv[0])) { + if (zstr(cmd) || argc < 2 || zstr(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", PAUSE_SYNTAX); } else { char *uuid = argv[0]; @@ -2320,7 +2320,7 @@ SWITCH_STANDARD_API(originate_function) uint8_t machine = 1; switch_status_t status = SWITCH_STATUS_SUCCESS; - if (session || switch_strlen_zero(cmd)) { + if (session || zstr(cmd)) { stream->write_function(stream, "-USAGE %s\n", ORIGINATE_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -3000,7 +3000,7 @@ SWITCH_STANDARD_API(show_function) /* switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SQL: %s.\n", sql); */ if (!strcasecmp(as, "delim") || !strcasecmp(as, "csv")) { - if (switch_strlen_zero(holder.delim)) { + if (zstr(holder.delim)) { if (!(holder.delim = argv[3])) { holder.delim = ","; } @@ -3075,7 +3075,7 @@ SWITCH_STANDARD_API(help_function) { char showcmd[1024]; int all = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { sprintf(showcmd, "help"); all = 1; } else { @@ -3100,7 +3100,7 @@ SWITCH_STANDARD_API(uuid_session_heartbeat_function) switch_core_session_t *l_session = NULL; int x = 0, sched = 0; - if (switch_strlen_zero(cmd) || !(mycmd = strdup(cmd))) { + if (zstr(cmd) || !(mycmd = strdup(cmd))) { goto error; } @@ -3158,7 +3158,7 @@ SWITCH_STANDARD_API(uuid_flush_dtmf_function) { switch_core_session_t *fsession; - if (!switch_strlen_zero(cmd) && (fsession = switch_core_session_locate(cmd))) { + if (!zstr(cmd) && (fsession = switch_core_session_locate(cmd))) { switch_channel_flush_dtmf(switch_core_session_get_channel(fsession)); switch_core_session_rwunlock(fsession); stream->write_function(stream, "+OK\n"); @@ -3176,9 +3176,9 @@ SWITCH_STANDARD_API(uuid_setvar_function) char *mycmd = NULL, *argv[3] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if ((argc == 2 || argc == 3) && !switch_strlen_zero(argv[0])) { + if ((argc == 2 || argc == 3) && !zstr(argv[0])) { char *uuid = argv[0]; char *var_name = argv[1]; char *var_value = NULL; @@ -3191,7 +3191,7 @@ SWITCH_STANDARD_API(uuid_setvar_function) switch_channel_t *channel; channel = switch_core_session_get_channel(psession); - if (switch_strlen_zero(var_name)) { + if (zstr(var_name)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); stream->write_function(stream, "-ERR No variable specified\n"); } else { @@ -3224,7 +3224,7 @@ SWITCH_STANDARD_API(uuid_setvar_multi_function) int argc = 0; char *var_name, *var_value = NULL; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { char *uuid = mycmd; if (!(vars = strchr(uuid, ' '))) { goto done; @@ -3241,7 +3241,7 @@ SWITCH_STANDARD_API(uuid_setvar_multi_function) if (var_name && (var_value = strchr(var_name, '='))) { *var_value++ = '\0'; } - if (switch_strlen_zero(var_name)) { + if (zstr(var_name)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); stream->write_function(stream, "-ERR No variable specified\n"); } else { @@ -3289,9 +3289,9 @@ SWITCH_STANDARD_API(uuid_getvar_function) char *mycmd = NULL, *argv[4] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc >= 2 && !switch_strlen_zero(argv[0])) { + if (argc >= 2 && !zstr(argv[0])) { char *uuid = argv[0]; char *var_name = argv[1]; const char *var_value = NULL; @@ -3300,7 +3300,7 @@ SWITCH_STANDARD_API(uuid_getvar_function) switch_channel_t *channel; channel = switch_core_session_get_channel(psession); - if (switch_strlen_zero(var_name)) { + if (zstr(var_name)) { stream->write_function(stream, "-ERR No variable name specified!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { @@ -3336,7 +3336,7 @@ SWITCH_STANDARD_API(uuid_send_dtmf_function) char *uuid = NULL, *dtmf_data = NULL; int argc = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -3350,7 +3350,7 @@ SWITCH_STANDARD_API(uuid_send_dtmf_function) uuid = argv[0]; dtmf_data = argv[1]; - if (switch_strlen_zero(uuid) || switch_strlen_zero(dtmf_data)) { + if (zstr(uuid) || zstr(dtmf_data)) { goto usage; } @@ -3381,9 +3381,9 @@ SWITCH_STANDARD_API(uuid_dump_function) char *mycmd = NULL, *argv[4] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc >= 0 && !switch_strlen_zero(argv[0])) { + if (argc >= 0 && !zstr(argv[0])) { char *uuid = argv[0]; char *format = argv[1]; @@ -3445,13 +3445,13 @@ SWITCH_STANDARD_API(global_setvar_function) char *mycmd = NULL, *argv[2] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, '=', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc > 0 && !switch_strlen_zero(argv[0])) { + if (argc > 0 && !zstr(argv[0])) { char *var_name = argv[0]; char *var_value = argv[1]; - if (switch_strlen_zero(var_value)) { + if (zstr(var_value)) { var_value = NULL; } switch_core_set_variable(var_name, var_value); @@ -3470,7 +3470,7 @@ SWITCH_STANDARD_API(global_setvar_function) #define GLOBAL_GETVAR_SYNTAX "" SWITCH_STANDARD_API(global_getvar_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { switch_core_dump_variables(stream); } else { stream->write_function(stream, "%s", switch_str_nil(switch_core_get_variable(cmd))); @@ -3481,7 +3481,7 @@ SWITCH_STANDARD_API(global_getvar_function) #define SYSTEM_SYNTAX "" SWITCH_STANDARD_API(system_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -3498,7 +3498,7 @@ SWITCH_STANDARD_API(system_function) #define SYSTEM_SYNTAX "" SWITCH_STANDARD_API(bg_system_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -3517,7 +3517,7 @@ SWITCH_STANDARD_API(strftime_tz_api_function) const char *tz_name = NULL; char date[80] = ""; - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { format = strchr(cmd, ' '); tz_name = cmd; if (format) { @@ -3542,7 +3542,7 @@ SWITCH_STANDARD_API(hupall_api_function) char *val = NULL; switch_call_cause_t cause = SWITCH_CAUSE_MANAGER_REQUEST; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); switch_assert(argv[0]); if ((cause = switch_channel_str2cause(argv[0])) == SWITCH_CAUSE_NONE) { @@ -3556,13 +3556,13 @@ SWITCH_STANDARD_API(hupall_api_function) var = NULL; } - if (switch_strlen_zero(var)) { + if (zstr(var)) { switch_core_session_hupall(cause); } else { switch_core_session_hupall_matching_var(var, val, cause); } - if (switch_strlen_zero(var)) { + if (zstr(var)) { stream->write_function(stream, "+OK hangup all channels with cause %s\n", switch_channel_cause2str(cause)); } else { stream->write_function(stream, "+OK hangup all channels matching [%s]=[%s] with cause: %s\n", var, val, switch_channel_cause2str(cause)); diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 82c29ca5cb..ad297ca239 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -676,7 +676,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe switch_snprintf(saymsg, sizeof(saymsg), "Auto Calling %d parties", call_list->itteration); conference_member_say(member, saymsg, 0); } else { - if (switch_strlen_zero(conference->special_announce)) { + if (zstr(conference->special_announce)) { /* announce the total number of members in the conference */ if (conference->count >= conference->announce_count && conference->announce_count > 1) { switch_snprintf(msg, sizeof(msg), "There are %d callers", conference->count); @@ -1882,7 +1882,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (switch_test_flag(member, MFLAG_MUTE_DETECT) && !switch_test_flag(member, MFLAG_CAN_SPEAK)) { - if (!switch_strlen_zero(member->conference->mute_detect_sound)) { + if (!zstr(member->conference->mute_detect_sound)) { conference_member_play_file(member, member->conference->mute_detect_sound, 0); } @@ -2782,7 +2782,7 @@ static switch_status_t conference_member_play_file(conference_member_t *member, expanded = NULL; } if (!strncasecmp(file, "say:", 4)) { - if (!switch_strlen_zero(file + 4)) { + if (!zstr(file + 4)) { status = conference_member_say(member, file + 4, leadin); } goto done; @@ -2793,7 +2793,7 @@ static switch_status_t conference_member_play_file(conference_member_t *member, goto done; } file = dfile; - } else if (!switch_strlen_zero(file)) { + } else if (!zstr(file)) { status = conference_member_say(member, file, leadin); goto done; } @@ -2853,7 +2853,7 @@ static switch_status_t conference_member_say(conference_member_t *member, char * switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; switch_status_t status = SWITCH_STATUS_FALSE; - if (member == NULL || switch_strlen_zero(text)) + if (member == NULL || zstr(text)) return SWITCH_STATUS_FALSE; switch_assert(conference != NULL); @@ -2935,7 +2935,7 @@ static switch_status_t conference_say(conference_obj_t *conference, const char * switch_assert(conference != NULL); - if (switch_strlen_zero(text)) { + if (zstr(text)) { return SWITCH_STATUS_GENERR; } @@ -3123,7 +3123,7 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str return SWITCH_STATUS_GENERR; switch_clear_flag_locked(member, MFLAG_CAN_SPEAK); - if (!switch_strlen_zero(member->conference->muted_sound)) { + if (!zstr(member->conference->muted_sound)) { conference_member_play_file(member, member->conference->muted_sound, 0); } else { char msg[512]; @@ -3155,7 +3155,7 @@ static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_s if (stream != NULL) { stream->write_function(stream, "OK unmute %u\n", member->id); } - if (!switch_strlen_zero(member->conference->unmuted_sound)) { + if (!zstr(member->conference->unmuted_sound)) { conference_member_play_file(member, member->conference->unmuted_sound, 0); } else { char msg[512]; @@ -3250,7 +3250,7 @@ static switch_status_t conf_api_sub_dtmf(conference_member_t *member, switch_str return SWITCH_STATUS_GENERR; } - if (switch_strlen_zero(dtmf)) { + if (zstr(dtmf)) { stream->write_function(stream, "Invalid input!\n"); return SWITCH_STATUS_GENERR; } @@ -3620,7 +3620,7 @@ static switch_status_t conf_api_sub_say(conference_obj_t *conference, switch_str { switch_event_t *event; - if (switch_strlen_zero(text)) { + if (zstr(text)) { stream->write_function(stream, "(say) Error! No text.\n"); return SWITCH_STATUS_GENERR; } @@ -3650,7 +3650,7 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t *conference, swit conference_member_t *member; switch_event_t *event; - if (switch_strlen_zero(text)) { + if (zstr(text)) { stream->write_function(stream, "(saymember) No Text!\n"); goto done; } @@ -3667,7 +3667,7 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t *conference, swit id = atoi(workspace); - if (!id || switch_strlen_zero(text)) { + if (!id || zstr(text)) { stream->write_function(stream, "(saymember) No Text!\n"); goto done; } @@ -3910,7 +3910,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc switch_assert(conference != NULL); switch_assert(stream != NULL); - if (argc > 3 && !switch_strlen_zero(argv[2])) { + if (argc > 3 && !zstr(argv[2])) { int x; conf_name = strdup(argv[2]); @@ -4274,7 +4274,7 @@ switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_ha const char *modified_cmdline = cmdline; const char *cmd = conf_api_sub_commands[i].pname; - if (!switch_strlen_zero(modified_cmdline) && (start_text = strstr(modified_cmdline, cmd))) { + if (!zstr(modified_cmdline) && (start_text = strstr(modified_cmdline, cmd))) { modified_cmdline = start_text + strlen(cmd); while (modified_cmdline && (*modified_cmdline == ' ' || *modified_cmdline == '\t')) { modified_cmdline++; @@ -4421,11 +4421,11 @@ static switch_status_t conference_outcall(conference_obj_t *conference, caller_channel = switch_core_session_get_channel(session); } - if (switch_strlen_zero(cid_name)) { + if (zstr(cid_name)) { cid_name = conference->caller_id_name; } - if (switch_strlen_zero(cid_num)) { + if (zstr(cid_num)) { cid_num = conference->caller_id_number; } @@ -4810,7 +4810,7 @@ SWITCH_STANDARD_APP(conference_auto_function) call_list = switch_channel_get_private(channel, "_conference_autocall_list_"); - if (switch_strlen_zero(data)) { + if (zstr(data)) { call_list = NULL; } else { np = switch_core_session_alloc(session, sizeof(*np)); @@ -4964,7 +4964,7 @@ SWITCH_STANDARD_APP(conference_function) } - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Invalid arguments\n"); return; } @@ -5121,11 +5121,11 @@ SWITCH_STANDARD_APP(conference_function) switch_channel_set_variable(channel, "conference_name", conference->name); /* Set MOH from variable if not set */ - if(switch_strlen_zero(conference->moh_sound)) { + if(zstr(conference->moh_sound)) { conference->moh_sound = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "conference_moh_sound")); } /* Set perpetual-sound from variable if not set */ - if(switch_strlen_zero(conference->perpetual_sound)) { + if(zstr(conference->perpetual_sound)) { conference->perpetual_sound = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "conference_perpetual_sound")); } @@ -5155,7 +5155,7 @@ SWITCH_STANDARD_APP(conference_function) /* if this is not an outbound call, deal with conference pins */ - if (enforce_security && !switch_strlen_zero(dpin)) { + if (enforce_security && !zstr(dpin)) { char pin_buf[80] = ""; int pin_retries = 3; /* XXX - this should be configurable - i'm too lazy to do it right now... */ int pin_valid = 0; @@ -5259,7 +5259,7 @@ SWITCH_STANDARD_APP(conference_function) } /* if we're using "bridge:" make an outbound call and bridge it in */ - if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) { + if (!zstr(bridgeto) && strcasecmp(bridgeto, "none")) { switch_call_cause_t cause; if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) != SWITCH_STATUS_SUCCESS) { goto done; @@ -5512,7 +5512,7 @@ static switch_status_t conf_default_controls(conference_obj_t *conference) switch_assert(conference != NULL); for (i = 0, status = SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i < CCFNTBL_QTY; i++) { - if (!switch_strlen_zero(ccfntbl[i].digits)) { + if (!zstr(ccfntbl[i].digits)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing default caller control action '%s' bound to '%s'.\n", ccfntbl[i].key, ccfntbl[i].digits); action = (caller_control_action_t *) switch_core_alloc(conference->pool, sizeof(caller_control_action_t)); @@ -5548,7 +5548,7 @@ static switch_status_t conference_new_install_caller_controls_custom(conference_ char *val = (char *) switch_xml_attr(xml_kvp, "digits"); char *data = (char *) switch_xml_attr_soft(xml_kvp, "data"); - if (!switch_strlen_zero(key) && !switch_strlen_zero(val)) { + if (!zstr(key) && !zstr(val)) { uint32_t i; /* scan through all of the valid actions, and if found, */ @@ -5640,7 +5640,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m char *auto_record = NULL; /* Validate the conference name */ - if (switch_strlen_zero(name)) { + if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Record! no name.\n"); return NULL; } @@ -5665,14 +5665,14 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m var = buf; } - if (!strcasecmp(var, "rate") && !switch_strlen_zero(val)) { + if (!strcasecmp(var, "rate") && !zstr(val)) { uint32_t tmp = atoi(val); if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) { rate = tmp; } - } else if (!strcasecmp(var, "domain") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "domain") && !zstr(val)) { domain = val; - } else if (!strcasecmp(var, "interval") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "interval") && !zstr(val)) { uint32_t tmp = atoi(val); if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) { interval = tmp; @@ -5680,59 +5680,59 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); } - } else if (!strcasecmp(var, "timer-name") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "timer-name") && !zstr(val)) { timer_name = val; - } else if (!strcasecmp(var, "tts-engine") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "tts-engine") && !zstr(val)) { tts_engine = val; - } else if (!strcasecmp(var, "tts-voice") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "tts-voice") && !zstr(val)) { tts_voice = val; - } else if (!strcasecmp(var, "enter-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "enter-sound") && !zstr(val)) { enter_sound = val; - } else if (!strcasecmp(var, "exit-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "exit-sound") && !zstr(val)) { exit_sound = val; - } else if (!strcasecmp(var, "alone-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "alone-sound") && !zstr(val)) { alone_sound = val; - } else if (!strcasecmp(var, "perpetual-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "perpetual-sound") && !zstr(val)) { perpetual_sound = val; - } else if (!strcasecmp(var, "moh-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "moh-sound") && !zstr(val)) { moh_sound = val; - } else if (!strcasecmp(var, "ack-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "ack-sound") && !zstr(val)) { ack_sound = val; - } else if (!strcasecmp(var, "nack-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "nack-sound") && !zstr(val)) { nack_sound = val; - } else if (!strcasecmp(var, "muted-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "muted-sound") && !zstr(val)) { muted_sound = val; - } else if (!strcasecmp(var, "mute-detect-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "mute-detect-sound") && !zstr(val)) { mute_detect_sound = val; - } else if (!strcasecmp(var, "unmuted-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "unmuted-sound") && !zstr(val)) { unmuted_sound = val; - } else if (!strcasecmp(var, "locked-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "locked-sound") && !zstr(val)) { locked_sound = val; - } else if (!strcasecmp(var, "is-locked-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "is-locked-sound") && !zstr(val)) { is_locked_sound = val; - } else if (!strcasecmp(var, "is-unlocked-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "is-unlocked-sound") && !zstr(val)) { is_unlocked_sound = val; - } else if (!strcasecmp(var, "member-flags") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "member-flags") && !zstr(val)) { member_flags = val; - } else if (!strcasecmp(var, "conference-flags") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "conference-flags") && !zstr(val)) { conference_flags = val; - } else if (!strcasecmp(var, "kicked-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "kicked-sound") && !zstr(val)) { kicked_sound = val; - } else if (!strcasecmp(var, "pin") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "pin") && !zstr(val)) { pin = val; - } else if (!strcasecmp(var, "pin-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "pin-sound") && !zstr(val)) { pin_sound = val; - } else if (!strcasecmp(var, "bad-pin-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "bad-pin-sound") && !zstr(val)) { bad_pin_sound = val; - } else if (!strcasecmp(var, "energy-level") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "energy-level") && !zstr(val)) { energy_level = val; - } else if (!strcasecmp(var, "caller-id-name") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "caller-id-name") && !zstr(val)) { caller_id_name = val; - } else if (!strcasecmp(var, "caller-id-number") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "caller-id-number") && !zstr(val)) { caller_id_number = val; - } else if (!strcasecmp(var, "caller-controls") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "caller-controls") && !zstr(val)) { caller_controls = val; - } else if (!strcasecmp(var, "comfort-noise") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "comfort-noise") && !zstr(val)) { int tmp; tmp = atoi(val); if (tmp > 1 && tmp < 10000) { @@ -5740,9 +5740,9 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m } else if (switch_true(val)) { comfort_noise_level = 1400; } - } else if (!strcasecmp(var, "sound-prefix") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "sound-prefix") && !zstr(val)) { sound_prefix = val; - } else if (!strcasecmp(var, "max-members") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "max-members") && !zstr(val)) { errno = 0; /* sanity first */ max_members = strtol(val, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */ if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) { @@ -5752,20 +5752,20 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m max_members = 0; /* set to 0 to disable max counts */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n", val); } - } else if (!strcasecmp(var, "max-members-sound") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "max-members-sound") && !zstr(val)) { maxmember_sound = val; - } else if (!strcasecmp(var, "announce-count") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "announce-count") && !zstr(val)) { errno = 0; /* safety first */ announce_count = strtol(val, NULL, 0); if (errno == ERANGE || errno == EINVAL) { announce_count = 0; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "announce-count is invalid, not anouncing member counts\n"); } - } else if (!strcasecmp(var, "suppress-events") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "suppress-events") && !zstr(val)) { suppress_events = val; - } else if (!strcasecmp(var, "verbose-events") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "verbose-events") && !zstr(val)) { verbose_events = val; - } else if (!strcasecmp(var, "auto-record") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "auto-record") && !zstr(val)) { auto_record = val; } } @@ -5773,17 +5773,17 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m /* Set defaults and various paramaters */ /* Timer module to use */ - if (switch_strlen_zero(timer_name)) { + if (zstr(timer_name)) { timer_name = "soft"; } /* Caller ID Name */ - if (switch_strlen_zero(caller_id_name)) { + if (zstr(caller_id_name)) { caller_id_name = (char *) global_app_name; } /* Caller ID Number */ - if (switch_strlen_zero(caller_id_number)) { + if (zstr(caller_id_number)) { caller_id_number = "0000000000"; } @@ -5823,13 +5823,13 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number); - if (!switch_strlen_zero(perpetual_sound)) { + if (!zstr(perpetual_sound)) { conference->perpetual_sound = switch_core_strdup(conference->pool, perpetual_sound); } conference->mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR; - if (!switch_strlen_zero(moh_sound) && switch_is_moh(moh_sound)) { + if (!zstr(moh_sound) && switch_is_moh(moh_sound)) { conference->moh_sound = switch_core_strdup(conference->pool, moh_sound); } @@ -5845,75 +5845,75 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m conference->sound_prefix = switch_core_strdup(conference->pool, sound_prefix); } - if (!switch_strlen_zero(enter_sound)) { + if (!zstr(enter_sound)) { conference->enter_sound = switch_core_strdup(conference->pool, enter_sound); } - if (!switch_strlen_zero(exit_sound)) { + if (!zstr(exit_sound)) { conference->exit_sound = switch_core_strdup(conference->pool, exit_sound); } - if (!switch_strlen_zero(ack_sound)) { + if (!zstr(ack_sound)) { conference->ack_sound = switch_core_strdup(conference->pool, ack_sound); } - if (!switch_strlen_zero(nack_sound)) { + if (!zstr(nack_sound)) { conference->nack_sound = switch_core_strdup(conference->pool, nack_sound); } - if (!switch_strlen_zero(muted_sound)) { + if (!zstr(muted_sound)) { conference->muted_sound = switch_core_strdup(conference->pool, muted_sound); } - if (switch_strlen_zero(mute_detect_sound)) { - if (!switch_strlen_zero(muted_sound)) { + if (zstr(mute_detect_sound)) { + if (!zstr(muted_sound)) { conference->mute_detect_sound = switch_core_strdup(conference->pool, muted_sound); } } else { conference->mute_detect_sound = switch_core_strdup(conference->pool, mute_detect_sound); } - if (!switch_strlen_zero(unmuted_sound)) { + if (!zstr(unmuted_sound)) { conference->unmuted_sound = switch_core_strdup(conference->pool, unmuted_sound); } - if (!switch_strlen_zero(kicked_sound)) { + if (!zstr(kicked_sound)) { conference->kicked_sound = switch_core_strdup(conference->pool, kicked_sound); } - if (!switch_strlen_zero(pin_sound)) { + if (!zstr(pin_sound)) { conference->pin_sound = switch_core_strdup(conference->pool, pin_sound); } - if (!switch_strlen_zero(bad_pin_sound)) { + if (!zstr(bad_pin_sound)) { conference->bad_pin_sound = switch_core_strdup(conference->pool, bad_pin_sound); } - if (!switch_strlen_zero(pin)) { + if (!zstr(pin)) { conference->pin = switch_core_strdup(conference->pool, pin); } - if (!switch_strlen_zero(alone_sound)) { + if (!zstr(alone_sound)) { conference->alone_sound = switch_core_strdup(conference->pool, alone_sound); } - if (!switch_strlen_zero(locked_sound)) { + if (!zstr(locked_sound)) { conference->locked_sound = switch_core_strdup(conference->pool, locked_sound); } - if (!switch_strlen_zero(is_locked_sound)) { + if (!zstr(is_locked_sound)) { conference->is_locked_sound = switch_core_strdup(conference->pool, is_locked_sound); } - if (!switch_strlen_zero(is_unlocked_sound)) { + if (!zstr(is_unlocked_sound)) { conference->is_unlocked_sound = switch_core_strdup(conference->pool, is_unlocked_sound); } - if (!switch_strlen_zero(energy_level)) { + if (!zstr(energy_level)) { conference->energy_level = atoi(energy_level); } - if (!switch_strlen_zero(maxmember_sound)) { + if (!zstr(maxmember_sound)) { conference->maxmember_sound = switch_core_strdup(conference->pool, maxmember_sound); } /* its going to be 0 by default, set to a value otherwise so this should be safe */ @@ -5931,15 +5931,15 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m conference->dtmf_parser = NULL; conference->eflags = 0xFFFFFFFF; - if (!switch_strlen_zero(suppress_events)) { + if (!zstr(suppress_events)) { clear_eflags(suppress_events, &conference->eflags); } - if (!switch_strlen_zero(auto_record)) { + if (!zstr(auto_record)) { conference->auto_record = switch_core_strdup(conference->pool, auto_record); } - if (!switch_strlen_zero(verbose_events) && switch_true(verbose_events)) { + if (!zstr(verbose_events) && switch_true(verbose_events)) { conference->verbose_events = 1; } diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index 56df40ab28..41f1a7184a 100755 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -151,7 +151,7 @@ static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, c curl_easy_cleanup(curl_handle); if ( http_data->stream.data && - !switch_strlen_zero((char *)http_data->stream.data) && + !zstr((char *)http_data->stream.data) && strcmp(" ", http_data->stream.data) ) { http_data->http_response = switch_core_strdup(pool, http_data->stream.data); @@ -185,7 +185,7 @@ static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data) { *data = '\0'; } - if switch_strlen_zero(header->data) { + if zstr(header->data) { header = header->next; continue; } @@ -336,7 +336,7 @@ SWITCH_STANDARD_API(curl_function) switch_memory_pool_t *pool = NULL; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); } diff --git a/src/mod/applications/mod_directory/mod_directory.c b/src/mod/applications/mod_directory/mod_directory.c index 2001a7cb2e..7db9548c5c 100644 --- a/src/mod/applications/mod_directory/mod_directory.c +++ b/src/mod/applications/mod_directory/mod_directory.c @@ -542,7 +542,7 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro } else { fullName = caller_name; } - if (switch_strlen_zero(fullName)) { + if (zstr(fullName)) { continue; } firstName = switch_core_session_strdup(session, fullName); @@ -649,29 +649,29 @@ static switch_status_t listen_entry(switch_core_session_t *session, dir_profile_ switch_safe_free(stream.data); } - if (switch_strlen_zero_buf(buf)) { + if (zstr_buf(buf)) { switch_snprintf(macro, sizeof(macro), "phrase:%s:%d", DIR_RESULT_ITEM, cbt->want+1); switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile->terminator_key); } - if (!switch_strlen_zero_buf(recorded_name) && switch_strlen_zero_buf(buf)) { + if (!zstr_buf(recorded_name) && zstr_buf(buf)) { switch_ivr_read(session, 0, 1, recorded_name, NULL, buf, sizeof(buf), 1, profile->terminator_key); } - if (switch_strlen_zero_buf(recorded_name) && switch_strlen_zero_buf(buf)) { + if (zstr_buf(recorded_name) && zstr_buf(buf)) { switch_snprintf(macro, sizeof(macro), "phrase:%s:%s", DIR_RESULT_SAY_NAME, cbt->fullname); switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile->terminator_key); } - if (cbt->exten_visible && switch_strlen_zero_buf(buf)) { + if (cbt->exten_visible && zstr_buf(buf)) { switch_snprintf(macro, sizeof(macro), "phrase:%s:%s", DIR_RESULT_AT, cbt->extension); switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile->terminator_key); } - if (switch_strlen_zero_buf(buf)) { + if (zstr_buf(buf)) { switch_snprintf(macro, sizeof(macro), "phrase:%s:%c,%c,%c,%c", DIR_RESULT_MENU, *profile->select_name_key, *profile->next_key, *profile->prev_key, *profile->new_search_key); switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), profile->digit_timeout, profile->terminator_key); } - if (!switch_strlen_zero_buf(buf)) { + if (!zstr_buf(buf)) { if (buf[0] == *profile->select_name_key) { switch_copy_string(cbt->transfer_to, cbt->extension, 255); } @@ -781,7 +781,7 @@ switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *p listing_cbt.move = ENTRY_MOVE_NEXT; directory_execute_sql_callback(profile->mutex, sql, listing_callback, &listing_cbt); status = listen_entry(session, profile, &listing_cbt); - if (!switch_strlen_zero(listing_cbt.transfer_to)) { + if (!zstr(listing_cbt.transfer_to)) { switch_copy_string(params->transfer_to, listing_cbt.transfer_to, 255); break; } @@ -833,7 +833,7 @@ SWITCH_STANDARD_APP(directory_function) int attempts = 3; char macro[255]; - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing profile name\n"); return; } @@ -871,7 +871,7 @@ SWITCH_STANDARD_APP(directory_function) s_param.try_again = 0; gather_name_digit(session, profile, &s_param); - if (switch_strlen_zero(s_param.digits)) { + if (zstr(s_param.digits)) { s_param.try_again = 1; continue; } @@ -886,7 +886,7 @@ SWITCH_STANDARD_APP(directory_function) navigate_entrys(session, profile, &s_param); } - if (!switch_strlen_zero(s_param.transfer_to)) { + if (!zstr(s_param.transfer_to)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Directory transfering call to : %s\n", s_param.transfer_to); switch_ivr_session_transfer(session, s_param.transfer_to, "XML", domain_name); } diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 3d2791a43b..bc7adc6827 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -55,11 +55,11 @@ SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt) abort(); } - if (switch_strlen_zero(target)) { + if (zstr(target)) { target = caller_profile->destination_number; } - if (!switch_strlen_zero(target) && (lbuf = switch_core_session_strdup(session, target)) + if (!zstr(target) && (lbuf = switch_core_session_strdup(session, target)) && (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) { } else { return NULL; @@ -91,7 +91,7 @@ SWITCH_STANDARD_APP(detect_speech_function) int argc; char *lbuf = NULL; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (!strcasecmp(argv[0], "grammar") && argc >= 1) { switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]); @@ -154,7 +154,7 @@ SWITCH_STANDARD_APP(exe_function) int argc; char *lbuf = NULL; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { switch_core_session_execute_exten(session, argv[0], argv[1], argv[2]); } else { @@ -176,7 +176,7 @@ SWITCH_STANDARD_APP(soft_hold_function) int argc; char *lbuf = NULL; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { switch_ivr_soft_hold(session, argv[0], argv[1], argv[2]); } else { @@ -205,7 +205,7 @@ SWITCH_STANDARD_APP(dtmf_bind_function) int argc; char *lbuf = NULL; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) { int kval = atoi(argv[0]); switch_bind_flag_t bind_flags = 0; @@ -283,7 +283,7 @@ SWITCH_STANDARD_APP(intercept_function) char *uuid; switch_bool_t bleg = SWITCH_FALSE; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { if (!strcasecmp(argv[0], "-bleg")) { if (argv[1]) { @@ -327,7 +327,7 @@ static int e_callback(void *pArg, int argc, char **argv, char **columnNames) #define eavesdrop_SYNTAX "[all | ]" SWITCH_STANDARD_APP(eavesdrop_function) { - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", eavesdrop_SYNTAX); } else { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -401,7 +401,7 @@ SWITCH_STANDARD_APP(eavesdrop_function) #define threeway_SYNTAX "" SWITCH_STANDARD_APP(three_way_function) { - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", threeway_SYNTAX); } else { switch_ivr_eavesdrop_session(session, data, NULL, ED_MUX_READ | ED_MUX_WRITE); @@ -458,7 +458,7 @@ SWITCH_STANDARD_APP(check_acl_function) char *mydata; switch_call_cause_t cause = SWITCH_CAUSE_CALL_REJECTED; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) { if (!switch_check_network_list_ip(argv[0], argv[1])) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -486,7 +486,7 @@ SWITCH_STANDARD_APP(transfer_function) int bleg = 0, both = 0; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { bleg = !strcasecmp(argv[0], "-bleg"); both = !strcasecmp(argv[0], "-both"); @@ -521,7 +521,7 @@ SWITCH_STANDARD_APP(sched_transfer_function) char *argv[4] = { 0 }; char *mydata; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) { time_t when; @@ -544,7 +544,7 @@ SWITCH_STANDARD_APP(sched_hangup_function) char *argv[5] = { 0 }; char *mydata; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { time_t when; switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT; @@ -577,7 +577,7 @@ SWITCH_STANDARD_APP(sched_broadcast_function) char *argv[6] = { 0 }; char *mydata; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) { time_t when; switch_media_flag_t flags = SMF_NONE; @@ -611,7 +611,7 @@ SWITCH_STANDARD_APP(delay_function) { uint32_t len = 0; - if (switch_strlen_zero(data)) { + if (zstr(data)) { len = 1000; } else { len = atoi(data); @@ -630,7 +630,7 @@ SWITCH_STANDARD_APP(hangup_function) { switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { cause = switch_channel_str2cause(data); } @@ -640,7 +640,7 @@ SWITCH_STANDARD_APP(hangup_function) SWITCH_STANDARD_APP(set_name_function) { - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { switch_channel_set_name(switch_core_session_get_channel(session), (char *) data); } } @@ -660,7 +660,7 @@ SWITCH_STANDARD_APP(presence_function) char *mydata = NULL; switch_channel_t *channel = switch_core_session_get_channel(session); - if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) { + if (zstr(data) || !(mydata = switch_core_session_strdup(session, data))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID ARGS!\n"); return; } @@ -729,7 +729,7 @@ SWITCH_STANDARD_APP(set_function) { char *var, *val = NULL; - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -740,7 +740,7 @@ SWITCH_STANDARD_APP(set_function) if (val) { *val++ = '\0'; - if (switch_strlen_zero(val)) { + if (zstr(val)) { val = NULL; } } @@ -762,7 +762,7 @@ SWITCH_STANDARD_APP(set_global_function) { char *var, *val = NULL; - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { var = strdup(data); @@ -771,7 +771,7 @@ SWITCH_STANDARD_APP(set_global_function) if (val) { *val++ = '\0'; - if (switch_strlen_zero(val)) { + if (zstr(val)) { val = NULL; } } @@ -786,7 +786,7 @@ SWITCH_STANDARD_APP(set_profile_var_function) { char *name, *val = NULL; - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { name = switch_core_session_strdup(session, data); @@ -794,7 +794,7 @@ SWITCH_STANDARD_APP(set_profile_var_function) if (val) { *val++ = '\0'; - if (switch_strlen_zero(val)) { + if (zstr(val)) { val = NULL; } } @@ -810,7 +810,7 @@ SWITCH_STANDARD_APP(export_function) char *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL, *var_name = NULL; int local = 1; - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE); @@ -827,7 +827,7 @@ SWITCH_STANDARD_APP(export_function) if (val) { *val++ = '\0'; - if (switch_strlen_zero(val)) { + if (zstr(val)) { val = NULL; } } @@ -853,7 +853,7 @@ SWITCH_STANDARD_APP(export_function) SWITCH_STANDARD_APP(unset_function) { - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "UNSET [%s]\n", (char *) data); @@ -889,7 +889,7 @@ SWITCH_STANDARD_APP(info_function) char *buf; int level = SWITCH_LOG_INFO; - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { level = switch_log_str2level(data); } @@ -916,7 +916,7 @@ SWITCH_STANDARD_APP(event_function) char *lbuf; if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_APPLICATION) == SWITCH_STATUS_SUCCESS) { - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) { int x = 0; @@ -966,7 +966,7 @@ SWITCH_STANDARD_APP(privacy_function) { switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session)); - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No privacy mode specified.\n"); } else { switch_set_flag(caller_profile, SWITCH_CPF_SCREEN); @@ -996,7 +996,7 @@ SWITCH_STANDARD_APP(strftime_function) int argc; char *lbuf; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) { switch_size_t retsize; switch_time_exp_t tm; @@ -1013,7 +1013,7 @@ SWITCH_STANDARD_API(strepoch_api_function) { switch_time_t out; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { out = switch_micro_time_now(); } else { out = switch_str_time(cmd); @@ -1031,14 +1031,14 @@ SWITCH_STANDARD_API(strftime_api_function) char date[80] = ""; switch_time_t thetime; char *p; - if (!switch_strlen_zero(cmd) && (p = strchr(cmd, '|'))) { + if (!zstr(cmd) && (p = strchr(cmd, '|'))) { thetime = switch_time_make(atoi(cmd), 0); cmd = p + 1; } else { thetime = switch_micro_time_now(); } switch_time_exp_lt(&tm, thetime); - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); } else { switch_strftime(date, &retsize, sizeof(date), cmd, &tm); @@ -1058,7 +1058,7 @@ SWITCH_STANDARD_API(presence_api_function) switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN; int need = 4; - if (!switch_strlen_zero(cmd) && (lbuf = strdup(cmd)) + if (!zstr(cmd) && (lbuf = strdup(cmd)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) { if (!strcasecmp(argv[0], "out")) { @@ -1111,11 +1111,11 @@ SWITCH_STANDARD_API(chat_api_function) char *lbuf = NULL, *argv[5]; int argc = 0; - if (!switch_strlen_zero(cmd) && (lbuf = strdup(cmd)) + if (!zstr(cmd) && (lbuf = strdup(cmd)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) { if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3], - !switch_strlen_zero(argv[4]) ? argv[4] : NULL , "") == SWITCH_STATUS_SUCCESS) { + !zstr(argv[4]) ? argv[4] : NULL , "") == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "Sent"); } else { stream->write_function(stream, "Error! Message Not Sent"); @@ -1206,7 +1206,7 @@ SWITCH_STANDARD_APP(dtmf_session_generate_function) { switch_bool_t do_read = SWITCH_TRUE; - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { if (!strcasecmp(data, "write")) { do_read = SWITCH_FALSE; } @@ -1240,7 +1240,7 @@ SWITCH_STANDARD_APP(tone_detect_session_function) time_t to = 0; int hits = 1; - if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) { + if (zstr(data) || !(mydata = switch_core_session_strdup(session, data))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID ARGS!\n"); return; } @@ -1362,7 +1362,7 @@ SWITCH_STANDARD_APP(sleep_function) { switch_channel_t *channel = switch_core_session_get_channel(session); - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No timeout specified.\n"); } else { uint32_t ms = atoi(data); @@ -1397,7 +1397,7 @@ SWITCH_STANDARD_APP(speak_function) char *mydata = NULL; switch_input_args_t args = { 0 }; - if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) { + if (zstr(data) || !(mydata = switch_core_session_strdup(session, data))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Params!\n"); return; } @@ -1610,7 +1610,7 @@ SWITCH_STANDARD_APP(read_function) const char *var_name = NULL; const char *valid_terminators = NULL; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No arguments specified.\n"); @@ -1651,7 +1651,7 @@ SWITCH_STANDARD_APP(read_function) timeout = 1000; } - if (switch_strlen_zero(valid_terminators)) { + if (zstr(valid_terminators)) { valid_terminators = "#"; } @@ -1674,7 +1674,7 @@ SWITCH_STANDARD_APP(play_and_get_digits_function) const char *valid_terminators = NULL; const char *digits_regex = NULL; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No arguments specified.\n"); @@ -1727,7 +1727,7 @@ SWITCH_STANDARD_APP(play_and_get_digits_function) timeout = 1000; } - if (switch_strlen_zero(valid_terminators)) { + if (zstr(valid_terminators)) { valid_terminators = "#"; } @@ -1744,7 +1744,7 @@ SWITCH_STANDARD_APP(say_function) switch_input_args_t args = { 0 }; switch_channel_t *channel = switch_core_session_get_channel(session); - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) { args.input_callback = on_dtmf; @@ -1766,7 +1766,7 @@ SWITCH_STANDARD_APP(phrase_function) switch_channel_t *channel = switch_core_session_get_channel(session); switch_status_t status; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { const char *lang; char *macro = mydata; char *mdata = NULL; @@ -1885,7 +1885,7 @@ SWITCH_STANDARD_APP(gentones_function) int32_t loops = 0; switch_channel_t *channel = switch_core_session_get_channel(session); - if (switch_strlen_zero(data) || !(tone_script = switch_core_session_strdup(session, data))) { + if (zstr(data) || !(tone_script = switch_core_session_strdup(session, data))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Params!\n"); return; } @@ -1915,13 +1915,13 @@ SWITCH_STANDARD_APP(displace_session_function) char *lbuf = NULL; char *flags = NULL; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { path = argv[0]; for (x = 1; x < argc; x++) { if (strchr(argv[x], '+')) { limit = atoi(argv[x]); - } else if (!switch_strlen_zero(argv[x])) { + } else if (!zstr(argv[x])) { flags = argv[x]; } } @@ -1948,7 +1948,7 @@ SWITCH_STANDARD_APP(record_function) const char *tmp; int rate; - if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) { + if (!zstr(data) && (mydata = switch_core_session_strdup(session, data))) { argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No file specified.\n"); @@ -2013,7 +2013,7 @@ SWITCH_STANDARD_APP(record_session_function) char *path_end; uint32_t limit = 0; - if (switch_strlen_zero(data)) { + if (zstr(data)) { return; } @@ -2095,7 +2095,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) char *camp_data = NULL; switch_status_t status; - if (switch_strlen_zero(data)) { + if (zstr(data)) { return; } @@ -2214,7 +2214,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) switch_channel_clear_flag(caller_channel, CF_NOT_READY); } - if (do_xfer && !switch_strlen_zero(v_campon_fallback_exten)) { + if (do_xfer && !zstr(v_campon_fallback_exten)) { switch_ivr_session_transfer(session, v_campon_fallback_exten, switch_channel_get_variable(caller_channel, "campon_fallback_dialplan"), @@ -2468,7 +2468,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, char stupid[128] = ""; const char *skip = NULL, *var = NULL; - if (switch_strlen_zero(outbound_profile->destination_number)) { + if (zstr(outbound_profile->destination_number)) { goto done; } @@ -2699,7 +2699,7 @@ SWITCH_STANDARD_APP(wait_for_silence_function) int argc; char *lbuf = NULL; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 3) { thresh = atoi(argv[0]); silence_hits = atoi(argv[1]); @@ -2776,7 +2776,7 @@ static switch_status_t api_chat_send(const char *proto, const char *from, const if (proto) { switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from, - !switch_strlen_zero(type) ? type : NULL, (char *) stream.data, NULL, NULL); + !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL); } switch_safe_free(stream.data); diff --git a/src/mod/applications/mod_easyroute/mod_easyroute.c b/src/mod/applications/mod_easyroute/mod_easyroute.c index 49f3b77be5..24ad56fb15 100644 --- a/src/mod/applications/mod_easyroute/mod_easyroute.c +++ b/src/mod/applications/mod_easyroute/mod_easyroute.c @@ -125,13 +125,13 @@ static switch_status_t load_config(void) } done: - if (switch_strlen_zero(globals.db_username)) { + if (zstr(globals.db_username)) { set_global_db_username("root"); } - if (switch_strlen_zero(globals.db_password)) { + if (zstr(globals.db_password)) { set_global_db_password("password"); } - if (switch_strlen_zero(globals.db_dsn)) { + if (zstr(globals.db_dsn)) { set_global_db_dsn("easyroute"); } @@ -208,25 +208,25 @@ static switch_status_t route_lookup(char *dn, easyroute_results_t *results, int char tmp_profile[129]; char tmp_gateway[129]; - if (switch_strlen_zero(pdata.limit)) { + if (zstr(pdata.limit)) { switch_set_string(results->limit, "9999" ); } else { switch_set_string(results->limit, pdata.limit ); } - if (switch_strlen_zero(pdata.techprofile)){ + if (zstr(pdata.techprofile)){ switch_set_string(tmp_profile, globals.default_techprofile); } else { switch_set_string(tmp_profile, pdata.techprofile); } - if (switch_strlen_zero(pdata.gateway)){ + if (zstr(pdata.gateway)){ switch_set_string(tmp_gateway, globals.default_gateway); } else { switch_set_string(tmp_gateway, pdata.gateway); } - if (switch_strlen_zero(pdata.translated)){ + if (zstr(pdata.translated)){ switch_set_string(results->translated, dn); } else { switch_set_string(results->translated, pdata.translated); @@ -240,13 +240,13 @@ static switch_status_t route_lookup(char *dn, easyroute_results_t *results, int } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "THE ROUTE [%s]\n", results->dialstring); - if (switch_strlen_zero(pdata.group)){ + if (zstr(pdata.group)){ switch_set_string(results->group, ""); } else { switch_set_string(results->group, pdata.group); } - if (switch_strlen_zero(pdata.acctcode)){ + if (zstr(pdata.acctcode)){ switch_set_string(results->acctcode, ""); } else { switch_set_string(results->acctcode, pdata.acctcode); diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index e2d23352f8..341e900711 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -471,7 +471,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results root = mroot; } - if (switch_strlen_zero(root)) { + if (zstr(root)) { root = globals.root; } @@ -675,7 +675,7 @@ SWITCH_STANDARD_API(enum_api) char *last_delim = "|"; int ok = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", "none"); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_esf/mod_esf.c b/src/mod/applications/mod_esf/mod_esf.c index ec1c361e83..34acba5ec2 100644 --- a/src/mod/applications/mod_esf/mod_esf.c +++ b/src/mod/applications/mod_esf/mod_esf.c @@ -83,7 +83,7 @@ SWITCH_STANDARD_APP(bcast_function) switch_core_session_get_read_impl(session, &read_impl); - if (!switch_strlen_zero((char *) data)) { + if (!zstr((char *) data)) { mydata = switch_core_session_strdup(session, data); assert(mydata != NULL); @@ -93,20 +93,20 @@ SWITCH_STANDARD_APP(bcast_function) mcast_ip = switch_core_session_strdup(session, var); } - if (!switch_strlen_zero(argv[0])) { + if (!zstr(argv[0])) { mcast_ip = argv[0]; } - if (!switch_strlen_zero(argv[1])) { + if (!zstr(argv[1])) { mcast_port_str = argv[1]; mcast_port = (switch_port_t) atoi(mcast_port_str); } - if (!switch_strlen_zero(argv[2])) { + if (!zstr(argv[2])) { mcast_control_port = (switch_port_t) atoi(argv[2]); } - if (!switch_strlen_zero(argv[3])) { + if (!zstr(argv[3])) { mcast_ttl = atoi(argv[3]); if (mcast_ttl < 1 || mcast_ttl > 255) { mcast_ttl = 1; diff --git a/src/mod/applications/mod_expr/mod_expr.c b/src/mod/applications/mod_expr/mod_expr.c index 0d910c9f8d..0ca90bed47 100644 --- a/src/mod/applications/mod_expr/mod_expr.c +++ b/src/mod/applications/mod_expr/mod_expr.c @@ -54,7 +54,7 @@ SWITCH_STANDARD_API(expr_function) size_t len; int ec = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto error; } diff --git a/src/mod/applications/mod_fax/mod_fax.c b/src/mod/applications/mod_fax/mod_fax.c index c26514a104..3dd2abbe44 100644 --- a/src/mod/applications/mod_fax/mod_fax.c +++ b/src/mod/applications/mod_fax/mod_fax.c @@ -133,7 +133,7 @@ static void spanfax_log_message(int level, const char *msg) break; } - if (!switch_strlen_zero(msg)) { + if (!zstr(msg)) { switch_log_printf(SWITCH_CHANNEL_LOG, fs_log_level, "%s", msg); } } @@ -511,7 +511,7 @@ void process_fax(switch_core_session_t *session, const char *data, application_m } } - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { pvt->filename = switch_core_session_strdup(session, data); if (pvt->app_mode == FUNCTION_TX) { if ((switch_file_exists(pvt->filename, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS)) { @@ -706,11 +706,11 @@ void load_configuration(switch_bool_t reload) const char *name = switch_xml_attr(x_list, "name"); const char *value = switch_xml_attr(x_list, "value"); - if (switch_strlen_zero(name)) { + if (zstr(name)) { continue; } - if (switch_strlen_zero(value)) { + if (zstr(value)) { continue; } diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index a4a4ca53b3..7e6f0cda53 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -146,7 +146,7 @@ static switch_status_t moh_on_dtmf(switch_core_session_t *session, void *input, return SWITCH_STATUS_SUCCESS; } -#define check_string(s) if (!switch_strlen_zero(s) && !strcasecmp(s, "undef")) { s = NULL; } +#define check_string(s) if (!zstr(s) && !strcasecmp(s, "undef")) { s = NULL; } static int node_consumer_wait_count(fifo_node_t *node) { @@ -297,7 +297,7 @@ static switch_status_t fifo_execute_sql(char *sql, switch_mutex_t *mutex) if (switch_odbc_handle_exec(globals.master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) { err_str = switch_odbc_handle_get_error(globals.master_odbc, stmt); - if (!switch_strlen_zero(err_str)) { + if (!zstr(err_str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str)); } switch_safe_free(err_str); @@ -752,7 +752,7 @@ SWITCH_STANDARD_API(fifo_add_outbound_function) int argc; uint32_t priority = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto fail; } @@ -819,7 +819,7 @@ SWITCH_STANDARD_APP(fifo_function) return; } - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No Args\n"); return; } @@ -1139,7 +1139,7 @@ SWITCH_STANDARD_APP(fifo_function) fifo_strategy_t strat = STRAT_WAITING_LONGER; char *url = NULL; - if (!switch_strlen_zero(strat_str)) { + if (!zstr(strat_str)) { if (!strcasecmp(strat_str, "more_ppl")) { strat = STRAT_MORE_PPL; } else if (!strcasecmp(strat_str, "waiting_longer")) { @@ -1489,7 +1489,7 @@ SWITCH_STANDARD_APP(fifo_function) fifo_consumer_wrapup_sound = switch_channel_get_variable(channel, "fifo_consumer_wrapup_sound"); fifo_consumer_wrapup_key = switch_channel_get_variable(channel, "fifo_consumer_wrapup_key"); sfifo_consumer_wrapup_time = switch_channel_get_variable(channel, "fifo_consumer_wrapup_time"); - if (!switch_strlen_zero(sfifo_consumer_wrapup_time)){ + if (!zstr(sfifo_consumer_wrapup_time)){ fifo_consumer_wrapup_time = atoi(sfifo_consumer_wrapup_time); } else { fifo_consumer_wrapup_time = 5000; @@ -1497,7 +1497,7 @@ SWITCH_STANDARD_APP(fifo_function) memset(buf, 0, sizeof(buf)); - if (fifo_consumer_wrapup_time || !switch_strlen_zero(fifo_consumer_wrapup_key)) { + if (fifo_consumer_wrapup_time || !zstr(fifo_consumer_wrapup_key)) { switch_channel_set_variable(channel, "fifo_status", "WRAPUP"); if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); @@ -1507,7 +1507,7 @@ SWITCH_STANDARD_APP(fifo_function) } } - if (!switch_strlen_zero(fifo_consumer_wrapup_sound)) { + if (!zstr(fifo_consumer_wrapup_sound)) { memset(&args, 0, sizeof(args)); args.buf = buf; args.buflen = sizeof(buf); @@ -1518,7 +1518,7 @@ SWITCH_STANDARD_APP(fifo_function) wrapup_time_started = switch_micro_time_now(); } - if (!switch_strlen_zero(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) { + if (!zstr(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) { while(switch_channel_ready(channel)) { char terminator = 0; @@ -1537,7 +1537,7 @@ SWITCH_STANDARD_APP(fifo_function) } } - } else if (fifo_consumer_wrapup_time && (switch_strlen_zero(fifo_consumer_wrapup_key) || !strcmp(buf, fifo_consumer_wrapup_key))) { + } else if (fifo_consumer_wrapup_time && (zstr(fifo_consumer_wrapup_key) || !strcmp(buf, fifo_consumer_wrapup_key))) { while(switch_channel_ready(channel)) { wrapup_time_elapsed = (switch_micro_time_now() - wrapup_time_started) / 1000; if (wrapup_time_elapsed > fifo_consumer_wrapup_time) { @@ -1761,12 +1761,12 @@ SWITCH_STANDARD_API(fifo_api_function) return SWITCH_STATUS_FALSE; } - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { data = strdup(cmd); switch_assert(data); } - if (switch_strlen_zero(cmd) || (argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 1 || !argv[0]) { + if (zstr(cmd) || (argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 1 || !argv[0]) { stream->write_function(stream, "%s\n", FIFO_API_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -1897,7 +1897,7 @@ static switch_status_t load_config(int reload, int del_all) var = (char *) switch_xml_attr_soft(param, "name"); val = (char *) switch_xml_attr_soft(param, "value"); - if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { + if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { if (switch_odbc_available()) { globals.odbc_dsn = switch_core_strdup(globals.pool, val); if ((odbc_user = strchr(globals.odbc_dsn, ':'))) { @@ -1915,7 +1915,7 @@ static switch_status_t load_config(int reload, int del_all) } } - if (switch_strlen_zero(globals.odbc_dsn) || switch_strlen_zero(odbc_user) || switch_strlen_zero(odbc_pass)) { + if (zstr(globals.odbc_dsn) || zstr(odbc_user) || zstr(odbc_pass)) { globals.dbname = "fifo"; } @@ -2190,7 +2190,7 @@ SWITCH_STANDARD_API(fifo_member_api_function) return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(cmd)){ + if (zstr(cmd)){ stream->write_function(stream, "-USAGE: %s\n", FIFO_MEMBER_API_SYNTAX); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_lcr/mod_lcr.c b/src/mod/applications/mod_lcr/mod_lcr.c index 88e79d6c99..e3182fb6d3 100644 --- a/src/mod/applications/mod_lcr/mod_lcr.c +++ b/src/mod/applications/mod_lcr/mod_lcr.c @@ -174,7 +174,7 @@ static const char *do_cid(switch_memory_pool_t *pool, const char *cid, const cha char *dst_regex = NULL; switch_channel_t *channel = NULL; - if (!switch_strlen_zero(cid)) { + if (!zstr(cid)) { len = strlen(cid); } else { goto done; @@ -275,12 +275,12 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch } } codec = ""; - if (!switch_strlen_zero(cur_route->codec)) { + if (!zstr(cur_route->codec)) { codec = switch_core_sprintf(pool, ",absolute_codec_string=%s", cur_route->codec); } cid = ""; - if (!switch_strlen_zero(cur_route->cid)) { + if (!zstr(cur_route->cid)) { cid = switch_core_sprintf(pool, ",origination_caller_id_number=%s", do_cid(pool, cur_route->cid, caller_id, session)); } @@ -292,7 +292,7 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch cur_route->carrier_name); } - if (switch_strlen_zero(cur_route->user_rate_str)) { + if (zstr(cur_route->user_rate_str)) { user_rate = ""; } else { user_rate = switch_core_sprintf(pool, ",lcr_user_rate=%s", cur_route->user_rate_str); @@ -312,7 +312,7 @@ static profile_t *locate_profile(const char *profile_name) { profile_t *profile = NULL; - if (switch_strlen_zero(profile_name)) { + if (zstr(profile_name)) { profile = globals.default_profile; } else if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name); @@ -555,7 +555,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa return SWITCH_STATUS_GENERR; } - if (switch_strlen_zero(argv[LCR_GW_PREFIX_PLACE]) && switch_strlen_zero(argv[LCR_GW_SUFFIX_PLACE]) ) { + if (zstr(argv[LCR_GW_PREFIX_PLACE]) && zstr(argv[LCR_GW_SUFFIX_PLACE]) ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "There's no way to dial this Gateway: Carrier: \"%s\" Prefix: \"%s\", Suffix \"%s\"\n", switch_str_nil(argv[LCR_CARRIER_PLACE]), @@ -737,7 +737,7 @@ static switch_status_t lcr_do_lookup(callback_t *cb_struct) switch_assert(cb_struct->lookup_number != NULL); digits_copy = string_digitsonly(cb_struct->pool, digits); - if (switch_strlen_zero(digits_copy)) { + if (zstr(digits_copy)) { return SWITCH_STATUS_GENERR; } @@ -862,7 +862,7 @@ static switch_status_t lcr_load_config() char *val = NULL; var = (char *) switch_xml_attr_soft(param, "name"); val = (char *) switch_xml_attr_soft(param, "value"); - if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { + if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "odbc_dsn is %s\n", val); globals.odbc_dsn = switch_core_strdup(globals.pool, val); if ((odbc_user = strchr(globals.odbc_dsn, ':'))) { @@ -922,13 +922,13 @@ static switch_status_t lcr_load_config() var = (char *) switch_xml_attr_soft(param, "name"); val = (char *) switch_xml_attr_soft(param, "value"); - if (!strcasecmp(var, "order_by") && !switch_strlen_zero(val)) { + if (!strcasecmp(var, "order_by") && !zstr(val)) { thisorder = &order_by; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "param val is %s\n", val); if ((argc = switch_separate_string(val, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) { for (x=0; xwrite_function(thisorder, "%s quality DESC", comma); } else if (!strcasecmp(argv[x], "reliability")) { @@ -951,40 +951,40 @@ static switch_status_t lcr_load_config() thisorder->write_function(thisorder, "%s %s", comma, val); } } - } else if (!strcasecmp(var, "id") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "id") && !zstr(val)) { id_s = val; - } else if (!strcasecmp(var, "custom_sql") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "custom_sql") && !zstr(val)) { custom_sql = val; - } else if (!strcasecmp(var, "reorder_by_rate") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "reorder_by_rate") && !zstr(val)) { reorder_by_rate = val; - } else if (!strcasecmp(var, "info_in_headers") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "info_in_headers") && !zstr(val)) { info_in_headers = val; - } else if (!strcasecmp(var, "quote_in_list") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "quote_in_list") && !zstr(val)) { quote_in_list = val; } } - if (switch_strlen_zero(name)) { + if (zstr(name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No name specified.\n"); } else { profile = switch_core_alloc(globals.pool, sizeof(*profile)); memset(profile, 0, sizeof(profile_t)); profile->name = switch_core_strdup(globals.pool, name); - if (!switch_strlen_zero((char *)order_by.data)) { + if (!zstr((char *)order_by.data)) { profile->order_by = switch_core_strdup(globals.pool, (char *)order_by.data); } else { /* default to rate */ profile->order_by = ", ${lcr_rate_field}"; } - if (!switch_strlen_zero(id_s)) { + if (!zstr(id_s)) { profile->id = (uint16_t)atoi(id_s); } /* SWITCH_STANDARD_STREAM doesn't use pools. but we only have to free sql_stream.data */ SWITCH_STANDARD_STREAM(sql_stream); - if (switch_strlen_zero(custom_sql)) { + if (zstr(custom_sql)) { /* use default sql */ sql_stream.write_function(&sql_stream, "SELECT l.digits, c.carrier_name, l.${lcr_rate_field}, cg.prefix AS gw_prefix, cg.suffix AS gw_suffix, l.lead_strip, l.trail_strip, l.prefix, l.suffix " @@ -1046,15 +1046,15 @@ static switch_status_t lcr_load_config() } profile->custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql); - if (!switch_strlen_zero(reorder_by_rate)) { + if (!zstr(reorder_by_rate)) { profile->reorder_by_rate = switch_true(reorder_by_rate); } - if (!switch_strlen_zero(info_in_headers)) { + if (!zstr(info_in_headers)) { profile->info_in_headers = switch_true(info_in_headers); } - if (!switch_strlen_zero(quote_in_list)) { + if (!zstr(quote_in_list)) { profile->quote_in_list = switch_true(quote_in_list); } @@ -1124,10 +1124,10 @@ SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt) intralata = switch_channel_get_variable(channel, "intralata"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "intrastate channel var is [%s]\n", intrastate); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "intralata channel var is [%s]\n", intralata); - if (!switch_strlen_zero(intralata) && !strcasecmp((char *)intralata, "true")) { + if (!zstr(intralata) && !strcasecmp((char *)intralata, "true")) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on intralata rates\n"); routes.intralata = SWITCH_FALSE; - } else if (!switch_strlen_zero(intrastate) && !strcasecmp((char *)intrastate, "true")) { + } else if (!zstr(intrastate) && !strcasecmp((char *)intrastate, "true")) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on intrastate rates\n"); routes.intrastate = SWITCH_TRUE; } else { @@ -1214,8 +1214,8 @@ SWITCH_STANDARD_APP(lcr_app_function) intra = switch_channel_get_variable(channel, "intrastate"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "intrastate channel var is [%s]\n", - switch_strlen_zero(intra) ? "undef" : intra); - if (switch_strlen_zero(intra) || strcasecmp((char *)intra, "true")) { + zstr(intra) ? "undef" : intra); + if (zstr(intra) || strcasecmp((char *)intra, "true")) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on interstate rates\n"); routes.intrastate = SWITCH_FALSE; } else { @@ -1308,7 +1308,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) switch_bool_t as_xml = SWITCH_FALSE; int rowcount=0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -1354,7 +1354,7 @@ SWITCH_STANDARD_API(dialplan_lcr_function) } } } - if (switch_strlen_zero(cb_struct.cid)) { + if (zstr(cb_struct.cid)) { cb_struct.cid = "18005551212"; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING , "Using default CID [%s]\n", cb_struct.cid @@ -1480,7 +1480,7 @@ SWITCH_STANDARD_API(dialplan_lcr_admin_function) void *val; profile_t *profile; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -1497,7 +1497,7 @@ SWITCH_STANDARD_API(dialplan_lcr_admin_function) profile = (profile_t *) val; stream->write_function(stream, "Name:\t\t%s\n", profile->name); - if (switch_strlen_zero(profile->custom_sql)) { + if (zstr(profile->custom_sql)) { stream->write_function(stream, " ID:\t\t%d\n", profile->id); stream->write_function(stream, " order by:\t%s\n", profile->order_by); } else { diff --git a/src/mod/applications/mod_limit/mod_limit.c b/src/mod/applications/mod_limit/mod_limit.c index 68da1c0a7e..88d9cb3266 100644 --- a/src/mod/applications/mod_limit/mod_limit.c +++ b/src/mod/applications/mod_limit/mod_limit.c @@ -102,7 +102,7 @@ static switch_status_t limit_execute_sql(char *sql, switch_mutex_t *mutex) if (switch_odbc_handle_exec(globals.master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) { char *err_str; err_str = switch_odbc_handle_get_error(globals.master_odbc, stmt); - if (!switch_strlen_zero(err_str)) { + if (!zstr(err_str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str)); } switch_safe_free(err_str); @@ -199,7 +199,7 @@ static switch_status_t do_config() } - if (switch_strlen_zero(globals.odbc_dsn) || switch_strlen_zero(odbc_user) || switch_strlen_zero(odbc_pass)) { + if (zstr(globals.odbc_dsn) || zstr(odbc_user) || zstr(odbc_pass)) { globals.dbname = "call_limit"; } @@ -447,7 +447,7 @@ SWITCH_STANDARD_API(db_api_function) switch_mutex_lock(globals.mutex); - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { mydata = strdup(cmd); switch_assert(mydata); argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0]))); @@ -518,7 +518,7 @@ SWITCH_STANDARD_APP(db_function) char *mydata = NULL; char *sql = NULL; - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -567,7 +567,7 @@ SWITCH_STANDARD_APP(hash_function) switch_mutex_lock(globals.db_hash_mutex); - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = strdup(data); switch_assert(mydata); argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0]))); @@ -621,7 +621,7 @@ SWITCH_STANDARD_API(hash_api_function) switch_mutex_lock(globals.db_hash_mutex); - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { mydata = strdup(cmd); switch_assert(mydata); argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0]))); @@ -683,7 +683,7 @@ SWITCH_STANDARD_API(group_api_function) switch_mutex_lock(globals.mutex); - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { mydata = strdup(cmd); argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -766,7 +766,7 @@ SWITCH_STANDARD_APP(group_function) char *mydata = NULL; char *sql; - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -865,7 +865,7 @@ SWITCH_STANDARD_APP(limit_function) int max = 0; switch_channel_t *channel = switch_core_session_get_channel(session); - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -931,7 +931,7 @@ SWITCH_STANDARD_APP(limit_execute_function) int max = -1; /* Parse application data */ - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -958,7 +958,7 @@ SWITCH_STANDARD_APP(limit_execute_function) app = argv[3]; app_arg = argv[4]; - if (switch_strlen_zero(app)) { + if (zstr(app)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing application\n"); return; } @@ -982,7 +982,7 @@ SWITCH_STANDARD_API(limit_usage_function) callback_t cbt = { 0 }; - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { mydata = strdup(cmd); switch_assert(mydata); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); @@ -1158,7 +1158,7 @@ SWITCH_STANDARD_APP(limit_hash_function) switch_channel_t *channel = switch_core_session_get_channel(session); /* Parse application data */ - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -1223,7 +1223,7 @@ SWITCH_STANDARD_APP(limit_hash_execute_function) int interval = 0; /* Parse application data */ - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -1258,7 +1258,7 @@ SWITCH_STANDARD_APP(limit_hash_execute_function) app = argv[3]; app_arg = argv[4]; - if (switch_strlen_zero(app)) { + if (zstr(app)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing application\n"); return; } @@ -1282,7 +1282,7 @@ SWITCH_STANDARD_API(limit_hash_usage_function) switch_mutex_lock(globals.limit_hash_mutex); - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { mydata = strdup(cmd); switch_assert(mydata); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); @@ -1495,7 +1495,7 @@ SWITCH_STANDARD_APP(limit_memcache_function) switch_channel_t *channel = switch_core_session_get_channel(session); /* Parse application data */ - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -1556,7 +1556,7 @@ SWITCH_STANDARD_APP(limit_memcache_execute_function) char *szinterval = NULL; /* Parse application data */ - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -1588,7 +1588,7 @@ SWITCH_STANDARD_APP(limit_memcache_execute_function) app = argv[3]; app_arg = argv[4]; - if (switch_strlen_zero(app)) { + if (zstr(app)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing application\n"); return; } @@ -1619,7 +1619,7 @@ SWITCH_STANDARD_API(limit_memcache_usage_function) goto end; } - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { mydata = strdup(cmd); switch_assert(mydata); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); diff --git a/src/mod/applications/mod_memcache/mod_memcache.c b/src/mod/applications/mod_memcache/mod_memcache.c index a4303df1ce..6d5d628b42 100755 --- a/src/mod/applications/mod_memcache/mod_memcache.c +++ b/src/mod/applications/mod_memcache/mod_memcache.c @@ -160,7 +160,7 @@ SWITCH_STANDARD_API(memcache_function) memcached_stat_st *stat = NULL; memcached_server_st *server_list; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } diff --git a/src/mod/applications/mod_nibblebill/mod_nibblebill.c b/src/mod/applications/mod_nibblebill/mod_nibblebill.c index a72f963dcf..196a29014f 100644 --- a/src/mod/applications/mod_nibblebill/mod_nibblebill.c +++ b/src/mod/applications/mod_nibblebill/mod_nibblebill.c @@ -189,22 +189,22 @@ static switch_status_t load_config(void) /* Set defaults for any variables still not set */ setdefaults: - if (switch_strlen_zero(globals.db_username)) { + if (zstr(globals.db_username)) { set_global_db_username("bandwidth.com"); } - if (switch_strlen_zero(globals.db_password)) { + if (zstr(globals.db_password)) { set_global_db_password("dev"); } - if (switch_strlen_zero(globals.db_dsn)) { + if (zstr(globals.db_dsn)) { set_global_db_dsn("bandwidth.com"); } - if (switch_strlen_zero(globals.percall_action)) { + if (zstr(globals.percall_action)) { set_global_percall_action("hangup"); } - if (switch_strlen_zero(globals.lowbal_action)) { + if (zstr(globals.lowbal_action)) { set_global_lowbal_action("play ding"); } - if (switch_strlen_zero(globals.nobal_action)) { + if (zstr(globals.nobal_action)) { set_global_nobal_action("hangup"); } @@ -722,7 +722,7 @@ SWITCH_STANDARD_APP(nibblebill_app_function) char *lbuf = NULL; char *argv[3] = { 0 }; - if (!switch_strlen_zero(data) && (lbuf = strdup(data)) + if (!zstr(data) && (lbuf = strdup(data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (!strcasecmp(argv[0], "adjust") && argc == 2) { nibblebill_adjust(session, (float)atof(argv[1])); @@ -751,9 +751,9 @@ SWITCH_STANDARD_API(nibblebill_api_function) char *mycmd = NULL, *argv[3] = { 0 }; int argc = 0; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if ((argc == 2 || argc == 3) && !switch_strlen_zero(argv[0])) { + if ((argc == 2 || argc == 3) && !zstr(argv[0])) { char *uuid = argv[0]; if ((psession = switch_core_session_locate(uuid))) { switch_channel_t *channel; diff --git a/src/mod/applications/mod_rss/mod_rss.c b/src/mod/applications/mod_rss/mod_rss.c index 9e4ca9c596..742993517e 100644 --- a/src/mod/applications/mod_rss/mod_rss.c +++ b/src/mod/applications/mod_rss/mod_rss.c @@ -234,7 +234,7 @@ SWITCH_STANDARD_APP(rss_function) switch_channel_answer(channel); - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { if ((mydata = switch_core_session_strdup(session, data))) { argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0])); @@ -394,7 +394,7 @@ SWITCH_STANDARD_APP(rss_function) err = switch_xml_error(xml); - if (!switch_strlen_zero(err)) { + if (!zstr(err)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Error [%s]\n", err); goto finished; } diff --git a/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp b/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp index ad8df70eff..98a16fab19 100644 --- a/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp +++ b/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp @@ -255,7 +255,7 @@ SWITCH_STANDARD_APP(soundtouch_start_function) int x; if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_soundtouch_"))) { - if (!switch_strlen_zero(data) && !strcasecmp(data, "stop")) { + if (!zstr(data) && !strcasecmp(data, "stop")) { switch_channel_set_private(channel, "_soundtouch_", NULL); switch_core_media_bug_remove(session, &bug); } else { diff --git a/src/mod/applications/mod_spy/mod_spy.c b/src/mod/applications/mod_spy/mod_spy.c index d3895dec76..fd00f938d7 100644 --- a/src/mod/applications/mod_spy/mod_spy.c +++ b/src/mod/applications/mod_spy/mod_spy.c @@ -188,7 +188,7 @@ SWITCH_STANDARD_APP(userspy_function) char* argv[2] = {0}; char* params = NULL; - if (!switch_strlen_zero(data) && (params = switch_core_session_strdup(session,data))) { + if (!zstr(data) && (params = switch_core_session_strdup(session,data))) { if ((argc = switch_separate_string(params, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { switch_channel_t *channel = switch_core_session_get_channel(session); diff --git a/src/mod/applications/mod_stress/mod_stress.cpp b/src/mod/applications/mod_stress/mod_stress.cpp index ef89a61b86..41630c07e0 100644 --- a/src/mod/applications/mod_stress/mod_stress.cpp +++ b/src/mod/applications/mod_stress/mod_stress.cpp @@ -206,7 +206,7 @@ SWITCH_STANDARD_APP(stress_start_function) int x = 0; if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_stress_"))) { - if (!switch_strlen_zero(data) && !strcasecmp(data, "stop")) { + if (!zstr(data) && !strcasecmp(data, "stop")) { switch_channel_set_private(channel, "_stress_", NULL); switch_core_media_bug_remove(session, &bug); } else { diff --git a/src/mod/applications/mod_valet_parking/mod_valet_parking.c b/src/mod/applications/mod_valet_parking/mod_valet_parking.c index 70bbcd66e3..dbcc38c905 100644 --- a/src/mod/applications/mod_valet_parking/mod_valet_parking.c +++ b/src/mod/applications/mod_valet_parking/mod_valet_parking.c @@ -115,7 +115,7 @@ SWITCH_STANDARD_APP(valet_parking_function) char dtmf_buf[128] = ""; int is_auto = 0; - if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data)) + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) { char *lot_name = argv[0]; char *ext = argv[1]; @@ -311,7 +311,7 @@ SWITCH_STANDARD_API(valet_info_function) name = (char *) var; lot = (valet_lot_t *) val; - if (!switch_strlen_zero(cmd) && strcasecmp(cmd, name)) continue; + if (!zstr(cmd) && strcasecmp(cmd, name)) continue; stream->write_function(stream, " \n", name); diff --git a/src/mod/applications/mod_vmd/mod_vmd.c b/src/mod/applications/mod_vmd/mod_vmd.c index 2dd14dbac2..aacd49edc0 100644 --- a/src/mod/applications/mod_vmd/mod_vmd.c +++ b/src/mod/applications/mod_vmd/mod_vmd.c @@ -624,7 +624,7 @@ SWITCH_STANDARD_API(vmd_api_main) int i; /* No command? Display usage */ - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 2858a00977..fe3797491c 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -669,7 +669,7 @@ static vm_profile_t * load_profile(const char *profile_name) switch_thread_rwlock_create(&profile->rwlock, pool); profile->name = switch_core_strdup(pool, profile_name); - if (!switch_strlen_zero(profile->odbc_dsn)) { + if (!zstr(profile->odbc_dsn)) { if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) { *(profile->odbc_user++) = '\0'; if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) { @@ -1571,7 +1571,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t char *sql = switch_mprintf("update voicemail_msgs set flags='delete' where uuid='%s'", cbt->uuid); vm_execute_sql(profile, sql, profile->mutex); switch_safe_free(sql); - if (!strcmp(input, profile->email_key) && !switch_strlen_zero(cbt->email)) { + if (!strcmp(input, profile->email_key) && !zstr(cbt->email)) { switch_event_t *event; char *from; char *headers, *header_string; @@ -1631,13 +1631,13 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t switch_channel_set_variable(channel, "voicemail_message_len", duration_str); switch_channel_set_variable(channel, "voicemail_email", cbt->email); - if (switch_strlen_zero(profile->email_headers)) { + if (zstr(profile->email_headers)) { from = switch_core_session_sprintf(session, "%s@%s", cbt->user, cbt->domain); } else { from = switch_channel_expand_variables(channel, profile->email_from); } - if (switch_strlen_zero(profile->email_headers)) { + if (zstr(profile->email_headers)) { headers = switch_core_session_sprintf(session, "From: FreeSWITCH mod_voicemail <%s@%s>\nSubject: Voicemail from %s %s\nX-Priority: %d", cbt->user, cbt->domain, cbt->cid_name, cbt->cid_number, priority); @@ -1818,7 +1818,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p switch_snprintf(msg_count, sizeof(msg_count), "%d:urgent-new", total_new_urgent_messages); TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, &folder_args)); informed++; - if (!switch_strlen_zero_buf(global_buf)) { + if (!zstr_buf(global_buf)) { vm_check_state = VM_CHECK_MENU; continue; } @@ -1827,7 +1827,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p switch_snprintf(msg_count, sizeof(msg_count), "%d:new", total_new_messages); TRY_CODE(switch_ivr_phrase_macro(session, VM_MESSAGE_COUNT_MACRO, msg_count, NULL, &folder_args)); informed++; - if (!switch_strlen_zero_buf(global_buf)) { + if (!zstr_buf(global_buf)) { vm_check_state = VM_CHECK_MENU; continue; } @@ -2047,7 +2047,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p char input[10] = ""; char key_buf[80] = ""; play_msg_type = MSG_NONE; - if (!switch_strlen_zero_buf(global_buf)) { + if (!zstr_buf(global_buf)) { switch_set_string(input, global_buf); *global_buf = '\0'; status = SWITCH_STATUS_SUCCESS; @@ -2157,8 +2157,8 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p } else if (!auth && !thepass && !strcasecmp(var, "password")) { thepass = switch_core_session_strdup(session, val); } else if (!auth && !strcasecmp(var, "vm-password")) { - if (!switch_strlen_zero(val) && !strcasecmp(val, "user-choose")) { - if (switch_strlen_zero(cbt.password)) { + if (!zstr(val) && !strcasecmp(val, "user-choose")) { + if (zstr(cbt.password)) { auth = 1; } else { thepass = switch_core_session_strdup(session, val); @@ -2202,12 +2202,12 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p thehash = vmhash; } - if (!auth && !thepass && !switch_strlen_zero(cbt.password)) { + if (!auth && !thepass && !zstr(cbt.password)) { thepass = cbt.password; } if (!auth) { - if (!switch_strlen_zero(cbt.password) && !strcmp(cbt.password, mypass)) { + if (!zstr(cbt.password) && !strcmp(cbt.password, mypass)) { auth++; } else if (!thepass) { auth++; @@ -2234,9 +2234,9 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p if (auth) { if (!dir_path) { - if (!switch_strlen_zero(vm_storage_dir)) { + if (!zstr(vm_storage_dir)) { dir_path = switch_core_session_sprintf(session, "%s%s%s", vm_storage_dir, SWITCH_PATH_SEPARATOR, myid); - } else if ( !switch_strlen_zero(profile->storage_dir) ) { + } else if ( !zstr(profile->storage_dir) ) { dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid); } else { dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, @@ -2389,9 +2389,9 @@ static switch_status_t deliver_vm(vm_profile_t *profile, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deliver VM to %s@%s\n", myid, domain_name); - if (!switch_strlen_zero(vm_storage_dir)) { + if (!zstr(vm_storage_dir)) { dir_path = switch_mprintf("%s%s%s", vm_storage_dir, SWITCH_PATH_SEPARATOR, myid); - } else if (!switch_strlen_zero(profile->storage_dir)) { + } else if (!zstr(profile->storage_dir)) { dir_path = switch_mprintf("%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid); } else { dir_path = switch_mprintf("%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, @@ -2450,7 +2450,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, update_mwi(profile, myid, domain_name, myfolder); } - if (send_mail && !switch_strlen_zero(vm_email) && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) { + if (send_mail && !zstr(vm_email) && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) { switch_event_t *event; char *from; char *body; @@ -2472,7 +2472,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages, &total_new_urgent_messages, &total_saved_urgent_messages); - if (switch_strlen_zero(vm_timezone) || (switch_strftime_tz(vm_timezone, profile->date_fmt, date, sizeof(date), 0) != SWITCH_STATUS_SUCCESS)) { + if (zstr(vm_timezone) || (switch_strftime_tz(vm_timezone, profile->date_fmt, date, sizeof(date), 0) != SWITCH_STATUS_SUCCESS)) { switch_time_exp_lt(&tm, switch_micro_time_now()); switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm); } @@ -2510,7 +2510,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_message_len", duration_str); - if (switch_strlen_zero(profile->email_from)) { + if (zstr(profile->email_from)) { from = switch_core_sprintf(pool, "%s@%s", myid, domain_name); } else { from = switch_event_expand_headers(params, profile->email_from); @@ -2518,7 +2518,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, if (send_main) { - if (switch_strlen_zero(profile->email_headers)) { + if (zstr(profile->email_headers)) { headers = switch_mprintf( "From: FreeSWITCH mod_voicemail <%s@%s>\n" "Subject: Voicemail from %s %s\nX-Priority: %d", @@ -2570,7 +2570,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, if (send_notify) { - if (switch_strlen_zero(profile->notify_email_headers)) { + if (zstr(profile->notify_email_headers)) { headers = switch_mprintf( "From: FreeSWITCH mod_voicemail <%s@%s>\n" "Subject: Voicemail from %s %s\nX-Priority: %d", @@ -2648,7 +2648,7 @@ static switch_status_t voicemail_inject(const char *data) char *box, *path, *cid_num, *cid_name; switch_memory_pool_t *pool = NULL; - if (switch_strlen_zero(data)) { + if (zstr(data)) { status = SWITCH_STATUS_FALSE; goto end; } @@ -2906,17 +2906,17 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p } } - if (send_main && switch_strlen_zero(vm_email) && !switch_strlen_zero(email_addr)) { + if (send_main && zstr(vm_email) && !zstr(email_addr)) { vm_email = switch_core_session_strdup(session, email_addr); - if (switch_strlen_zero(vm_email)) { + if (zstr(vm_email)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "No email address, not going to send email.\n"); send_main = 0; } } - if (send_notify && switch_strlen_zero(vm_notify_email)) { + if (send_notify && zstr(vm_notify_email)) { vm_notify_email = vm_email; - if (switch_strlen_zero(vm_notify_email)) { + if (zstr(vm_notify_email)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "No notify email address, not going to notify.\n"); send_notify = 0; } @@ -2944,9 +2944,9 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p } } - if (!switch_strlen_zero(vm_storage_dir)) { + if (!zstr(vm_storage_dir)) { dir_path = switch_core_session_sprintf(session, "%s%s%s", vm_storage_dir, SWITCH_PATH_SEPARATOR, id); - } else if (!switch_strlen_zero(profile->storage_dir)) { + } else if (!zstr(profile->storage_dir)) { dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, id); } else { dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, @@ -2987,11 +2987,11 @@ greet: switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL); - if (!switch_strlen_zero(greet_path)) { + if (!zstr(greet_path)) { memset(buf, 0, sizeof(buf)); TRY_CODE(switch_ivr_play_file(session, NULL, greet_path, &args)); } else { - if (!switch_strlen_zero(cbt.name_path)) { + if (!zstr(cbt.name_path)) { memset(buf, 0, sizeof(buf)); TRY_CODE(switch_ivr_play_file(session, NULL, cbt.name_path, &args)); } @@ -3010,12 +3010,12 @@ greet: greet_key_press: if (switch_stristr(buf, profile->login_keys)) { voicemail_check_main(session, profile, domain_name, id, 0); - } else if (!strcasecmp(buf, profile->operator_key) && !switch_strlen_zero(profile->operator_key)) { + } else if (!strcasecmp(buf, profile->operator_key) && !zstr(profile->operator_key)) { int argc; char *argv[4]; char *mycmd; - if (!switch_strlen_zero(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext))) { + if (!zstr(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (argc >= 1 && argc <= 4) { switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]); @@ -3024,12 +3024,12 @@ greet_key_press: goto end; } } - } else if (!strcasecmp(buf, profile->vmain_key) && !switch_strlen_zero(profile->vmain_key)) { + } else if (!strcasecmp(buf, profile->vmain_key) && !zstr(profile->vmain_key)) { int argc; char *argv[4]; char *mycmd; - if (!switch_strlen_zero(profile->vmain_ext) && (mycmd = switch_core_session_strdup(session, profile->vmain_ext))) { + if (!zstr(profile->vmain_ext) && (mycmd = switch_core_session_strdup(session, profile->vmain_ext))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); if (argc >= 1 && argc <= 4) { switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]); @@ -3177,7 +3177,7 @@ SWITCH_STANDARD_APP(voicemail_function) int x = 0, check = 0, auth = 0; switch_channel_t *channel = switch_core_session_get_channel(session); - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { mydata = switch_core_session_strdup(session, data); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -3210,19 +3210,19 @@ SWITCH_STANDARD_APP(voicemail_function) auth = 1; } - if (switch_strlen_zero(profile_name)) { + if (zstr(profile_name)) { profile_name = switch_channel_get_variable(channel, "voicemail_profile_name"); } - if (switch_strlen_zero(domain_name)) { + if (zstr(domain_name)) { domain_name = switch_channel_get_variable(channel, "voicemail_domain_name"); } - if (switch_strlen_zero(id)) { + if (zstr(id)) { id = switch_channel_get_variable(channel, "voicemail_id"); } - if (switch_strlen_zero(profile_name) || switch_strlen_zero(domain_name)) { + if (zstr(profile_name) || zstr(domain_name)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Usage: %s\n", VM_USAGE); return; } @@ -3254,7 +3254,7 @@ SWITCH_STANDARD_API(boxcount_api_function) vm_profile_t *profile; char *id, *domain, *p, *profilename = NULL; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%d", 0); return SWITCH_STATUS_SUCCESS; } @@ -3271,7 +3271,7 @@ SWITCH_STANDARD_API(boxcount_api_function) id += 4; } - if (switch_strlen_zero(id)) { + if (zstr(id)) { stream->write_function(stream, "%d", 0); goto done; } @@ -3283,7 +3283,7 @@ SWITCH_STANDARD_API(boxcount_api_function) how = p; } - if (!switch_strlen_zero(profilename)) { + if (!zstr(profilename)) { if ((profile = get_profile(profilename))) { message_count(profile, id, domain, "inbox", &total_new_messages, &total_saved_messages, &total_new_urgent_messages, &total_saved_urgent_messages); @@ -3334,7 +3334,7 @@ SWITCH_STANDARD_API(prefs_api_function) char sql[256]; prefs_callback_t cbt = {{0}}; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%d", 0); goto done; } @@ -3351,7 +3351,7 @@ SWITCH_STANDARD_API(prefs_api_function) id += 4; } - if (switch_strlen_zero(id)) { + if (zstr(id)) { stream->write_function(stream, "%d", 0); goto done; } @@ -3363,7 +3363,7 @@ SWITCH_STANDARD_API(prefs_api_function) how = p; } - if (!switch_strlen_zero(profilename) && !(profile = get_profile(profilename))) { + if (!zstr(profilename) && !(profile = get_profile(profilename))) { stream->write_function(stream, "-ERR No such profile\n"); goto done; } @@ -3958,7 +3958,7 @@ SWITCH_STANDARD_API(voicemail_api_function) path_info = switch_event_get_header(stream->param_event, "http-path-info"); } - if (!switch_strlen_zero(cmd)) { + if (!zstr(cmd)) { mydata = strdup(cmd); switch_assert(mydata); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); diff --git a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c index 196a0aa029..05d5d59244 100644 --- a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c +++ b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c @@ -146,7 +146,7 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, const ch voice_name = NULL; } - if (switch_strlen_zero(voice_name)) { + if (zstr(voice_name)) { /* Find the first voice on the system */ if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n"); @@ -215,18 +215,18 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char cepstral->tts_stream = NULL; - if (switch_strlen_zero(text)) { + if (zstr(text)) { return SWITCH_STATUS_FALSE; } if (!strncasecmp(text, fp, len)) { text += len; - if (switch_strlen_zero(text)) { + if (zstr(text)) { return SWITCH_STATUS_FALSE; } swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL); } else { char *to_say; - if (switch_strlen_zero(text)) { + if (zstr(text)) { return SWITCH_STATUS_FALSE; } diff --git a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c index 2c2ba6a5c3..b8d24d76e1 100644 --- a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c +++ b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c @@ -282,11 +282,11 @@ static switch_status_t pocketsphinx_asr_feed(switch_asr_handle_t *ah, void *data switch_mutex_lock(ps->flag_mutex); if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) { - if (!switch_strlen_zero(hyp)) { + if (!zstr(hyp)) { ps_end_utt(ps->ps); switch_clear_flag(ps, PSFLAG_READY); if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) { - if (switch_strlen_zero(hyp)) { + if (zstr(hyp)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost the text, never mind....\n"); ps_start_utt(ps->ps, NULL); switch_set_flag(ps, PSFLAG_READY); diff --git a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c index 28e1433353..3fb7aad516 100644 --- a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c +++ b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c @@ -75,7 +75,7 @@ static int load_tts_commandline_config(void) switch_xml_free(xml); } - if (switch_strlen_zero(globals.command)) { + if (zstr(globals.command)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No command set, please edit %s\n", cf); } diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c index c3c6e705c8..e8ac75961d 100644 --- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c +++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c @@ -490,7 +490,7 @@ static int text_starts_with(const char *text, const char *match) { int result = 0; - if (!switch_strlen_zero(text)) { + if (!zstr(text)) { size_t textlen, matchlen; /* find first non-space character */ @@ -524,7 +524,7 @@ static switch_status_t audio_queue_create(audio_queue_t **audio_queue, const cha char *lname = ""; *audio_queue = NULL; - if (switch_strlen_zero(name)) { + if (zstr(name)) { lname = ""; } else { lname = switch_core_strdup(pool, name); @@ -704,7 +704,7 @@ static switch_status_t audio_queue_destroy(audio_queue_t *queue) { if (queue) { char *name = queue->name; - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = ""; } if (queue->buffer) { @@ -779,7 +779,7 @@ static switch_status_t speech_channel_create(speech_channel_t **schannel, const } switch_core_hash_init(&schan->params, pool); schan->data = NULL; - if (switch_strlen_zero(name)) { + if (zstr(name)) { schan->name = ""; } else { schan->name = switch_core_strdup(pool, name); @@ -1017,7 +1017,7 @@ static switch_status_t synth_channel_set_params(speech_channel_t *schannel, mrcp switch_hash_this(hi, &key, NULL, &val); param_name = (char *)key; param_val = (char *)val; - if (!switch_strlen_zero(param_name) && !switch_strlen_zero(param_val)) { + if (!zstr(param_name) && !zstr(param_val)) { unimrcp_param_id_t *id = (unimrcp_param_id_t *)switch_core_hash_find(schannel->application->param_id_map, param_name); if (id) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s: %s\n", schannel->name, param_name, param_val); @@ -1272,11 +1272,11 @@ static const char *speech_channel_type_to_string(speech_channel_type_t type) static switch_status_t speech_channel_set_param(speech_channel_t *schannel, const char *param, const char *val) { switch_mutex_lock(schannel->mutex); - if (!switch_strlen_zero(param) && val != NULL) { + if (!zstr(param) && val != NULL) { /* check if this is a FreeSWITCH param that needs to be translated to an MRCP param: e.g. voice ==> voice-name */ char *mrcp_param = (char *)switch_core_hash_find(schannel->application->fs_param_map, param); char *lcparam = NULL; - if (switch_strlen_zero(mrcp_param)) { + if (zstr(mrcp_param)) { lcparam = switch_lc_strdup(param); mrcp_param = lcparam; } @@ -1422,7 +1422,7 @@ static switch_status_t synth_speech_open(switch_speech_handle_t *sh, const char sh->private_info = schannel; /* try to open an MRCP channel */ - if (switch_strlen_zero(profile_name)) { + if (zstr(profile_name)) { profile_name = globals.unimrcp_default_synth_profile; } profile = (profile_t *)switch_core_hash_find(globals.profiles, profile_name); @@ -1437,7 +1437,7 @@ static switch_status_t synth_speech_open(switch_speech_handle_t *sh, const char } /* Set session TTS params */ - if (!switch_strlen_zero(voice_name)) { + if (!zstr(voice_name)) { speech_channel_set_param(schannel, "Voice-Name", voice_name); } @@ -1476,7 +1476,7 @@ static switch_status_t synth_speech_feed_tts(switch_speech_handle_t *sh, char *t switch_status_t status = SWITCH_STATUS_SUCCESS; speech_channel_t *schannel = (speech_channel_t *)sh->private_info; - if (switch_strlen_zero(text)) { + if (zstr(text)) { status = SWITCH_STATUS_FALSE; } else { status = synth_channel_speak(schannel, text); @@ -1900,10 +1900,10 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel, const cha /* input timers are started by default unless the start-input-timers=false param is set */ start_input_timers = (char *)switch_core_hash_find(schannel->params, "start-input-timers"); - r->timers_started = switch_strlen_zero(start_input_timers) || strcasecmp(start_input_timers, "false"); + r->timers_started = zstr(start_input_timers) || strcasecmp(start_input_timers, "false"); /* get the cached grammar */ - if (switch_strlen_zero(name)) { + if (zstr(name)) { grammar = r->last_grammar; } else { grammar = (grammar_t *)switch_core_hash_find(r->grammars, name); @@ -1935,7 +1935,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel, const cha /* set Content-Type */ mime_type = grammar_type_to_mime(grammar->type, schannel->profile); - if (switch_strlen_zero(mime_type)) { + if (zstr(mime_type)) { status = SWITCH_STATUS_FALSE; goto done; } @@ -2029,7 +2029,7 @@ static switch_status_t recog_channel_load_grammar(speech_channel_t *schannel, co goto done; } mime_type = grammar_type_to_mime(type, schannel->profile); - if (switch_strlen_zero(mime_type)) { + if (zstr(mime_type)) { status = SWITCH_STATUS_FALSE; goto done; } @@ -2084,7 +2084,7 @@ static switch_status_t recog_channel_unload_grammar(speech_channel_t *schannel, { switch_status_t status = SWITCH_STATUS_SUCCESS; - if (switch_strlen_zero(grammar_name)) { + if (zstr(grammar_name)) { status = SWITCH_STATUS_FALSE; } else { recognizer_data_t *r = (recognizer_data_t *)schannel->data; @@ -2106,7 +2106,7 @@ static switch_status_t recog_channel_check_results(speech_channel_t *schannel) recognizer_data_t *r; switch_mutex_lock(schannel->mutex); r = (recognizer_data_t *)schannel->data; - if (!switch_strlen_zero(r->result)) { + if (!zstr(r->result)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SUCCESS, have result\n", schannel->name); } else if (r->start_of_input) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SUCCESS, start of input\n", schannel->name); @@ -2180,12 +2180,12 @@ static switch_status_t recog_channel_set_results(speech_channel_t *schannel, con recognizer_data_t *r; switch_mutex_lock(schannel->mutex); r = (recognizer_data_t *)schannel->data; - if (!switch_strlen_zero(r->result)) { + if (!zstr(r->result)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result is already set\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; } - if (switch_strlen_zero(result)) { + if (zstr(result)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result is NULL\n", schannel->name); status = SWITCH_STATUS_FALSE; goto done; @@ -2211,7 +2211,7 @@ static switch_status_t recog_channel_get_results(speech_channel_t *schannel, cha switch_status_t status = SWITCH_STATUS_SUCCESS; recognizer_data_t *r = (recognizer_data_t *)schannel->data; switch_mutex_lock(schannel->mutex); - if (!switch_strlen_zero(r->result)) { + if (!zstr(r->result)) { *result = strdup(r->result); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result:\n\n%s\n", schannel->name, *result); r->result = NULL; @@ -2248,7 +2248,7 @@ static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp switch_hash_this(hi, &key, NULL, &val); param_name = (char *)key; param_val = (char *)val; - if (!switch_strlen_zero(param_name) && !switch_strlen_zero(param_val)) { + if (!zstr(param_name) && !zstr(param_val)) { unimrcp_param_id_t *id = (unimrcp_param_id_t *)switch_core_hash_find(schannel->application->param_id_map, param_name); if (id) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) \"%s\": \"%s\"\n", schannel->name, param_name, param_val); @@ -2572,7 +2572,7 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha char *filename = NULL; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar = %s, name = %s\n", schannel->name, grammar, name); - if (switch_strlen_zero(grammar) || switch_strlen_zero(name)) { + if (zstr(grammar) || zstr(name)) { status = SWITCH_STATUS_FALSE; goto done; } @@ -2673,7 +2673,7 @@ static switch_status_t recog_asr_unload_grammar(switch_asr_handle_t *ah, const c { switch_status_t status = SWITCH_STATUS_SUCCESS; speech_channel_t *schannel = (speech_channel_t *)ah->private_info; - if (switch_strlen_zero(name) || speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS || + if (zstr(name) || speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS || recog_channel_unload_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) { status = SWITCH_STATUS_FALSE; } @@ -3316,13 +3316,13 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) } /* set up MRCPv2 connection agent that will be shared with all profiles */ - if (!switch_strlen_zero(globals.unimrcp_max_connection_count)) { + if (!zstr(globals.unimrcp_max_connection_count)) { max_connection_count = atoi(globals.unimrcp_max_connection_count); } if (max_connection_count <= 0) { max_connection_count = 100; } - if (!switch_strlen_zero(globals.unimrcp_offer_new_connection)) { + if (!zstr(globals.unimrcp_offer_new_connection)) { offer_new_connection = strcasecmp("true", globals.unimrcp_offer_new_connection); } connection_agent = mrcp_client_connection_agent_create(max_connection_count, offer_new_connection, pool); @@ -3354,7 +3354,7 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) /* get profile attributes */ const char *name = apr_pstrdup(pool, switch_xml_attr(profile, "name")); const char *version = switch_xml_attr(profile, "version"); - if (switch_strlen_zero(name) || switch_strlen_zero(version)) { + if (zstr(name) || zstr(version)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " missing name or version attribute\n"); client = NULL; goto done; @@ -3381,7 +3381,7 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) for (param = switch_xml_child(profile, "param"); param; param = switch_xml_next(param)) { const char *param_name = switch_xml_attr(param, "name"); const char *param_value = switch_xml_attr(param, "value"); - if (switch_strlen_zero(param_name)) { + if (zstr(param_name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing param name\n"); client = NULL; goto done; @@ -3409,7 +3409,7 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) for (param = switch_xml_child(profile, "param"); param; param = switch_xml_next(param)) { const char *param_name = switch_xml_attr(param, "name"); const char *param_value = switch_xml_attr(param, "value"); - if (switch_strlen_zero(param_name)) { + if (zstr(param_name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing param name\n"); client = NULL; goto done; @@ -3468,11 +3468,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_unimrcp_load) /* get MRCP module configuration */ mod_unimrcp_do_config(); - if (switch_strlen_zero(globals.unimrcp_default_synth_profile)) { + if (zstr(globals.unimrcp_default_synth_profile)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing default-tts-profile\n"); return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(globals.unimrcp_default_recog_profile)) { + if (zstr(globals.unimrcp_default_recog_profile)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing default-asr-profile\n"); return SWITCH_STATUS_FALSE; } @@ -3575,7 +3575,7 @@ static apt_bool_t unimrcp_log(const char *file, int line, const char *id, apt_lo char log_message[4096] = { 0 }; /* same size as MAX_LOG_ENTRY_SIZE in UniMRCP apt_log.c */ size_t msglen; - if (switch_strlen_zero(format)) { + if (zstr(format)) { return TRUE; } diff --git a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c index 67fbd967b8..5fff1b2cea 100644 --- a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c +++ b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c @@ -141,7 +141,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt) caller_profile = switch_channel_get_caller_profile(channel); } - if (!caller_profile || switch_strlen_zero(caller_profile->destination_number)) { + if (!caller_profile || zstr(caller_profile->destination_number)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n"); return NULL; } @@ -271,7 +271,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt) switch_regex_safe_free(re); if (!extension) { - if (switch_strlen_zero(field_data)) { + if (zstr(field_data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No extension!\n"); break; } @@ -313,7 +313,7 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session, } else { profile = switch_core_get_variable("sip_profile"); } - if (switch_strlen_zero(profile)) { + if (zstr(profile)) { profile = "default"; } diff --git a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c index 6efbbbd54e..1d24123895 100644 --- a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c +++ b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c @@ -295,7 +295,7 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t * const char *inline_ = switch_xml_attr_soft(xaction, "inline"); int xinline = switch_true(inline_); - if (!switch_strlen_zero(xaction->txt)) { + if (!zstr(xaction->txt)) { data = xaction->txt; } else { data = (char *) switch_xml_attr_soft(xaction, "data"); @@ -393,7 +393,7 @@ SWITCH_STANDARD_DIALPLAN(dialplan_hunt) /* get our handle to the "dialplan" section of the config */ - if (!switch_strlen_zero(alt_path)) { + if (!zstr(alt_path)) { switch_xml_t conf = NULL, tag = NULL; if (!(alt_root = switch_xml_parse_file_simple(alt_path))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Open of [%s] failed\n", alt_path); diff --git a/src/mod/endpoints/mod_alsa/mod_alsa.c b/src/mod/endpoints/mod_alsa/mod_alsa.c index 14d1ed2392..f544857ee7 100644 --- a/src/mod/endpoints/mod_alsa/mod_alsa.c +++ b/src/mod/endpoints/mod_alsa/mod_alsa.c @@ -366,7 +366,7 @@ static void add_pvt(private_t *tech_pvt, int master) switch_mutex_lock(globals.pvt_lock); - if (switch_strlen_zero(tech_pvt->call_id)) { + if (zstr(tech_pvt->call_id)) { snprintf(tech_pvt->call_id, sizeof(tech_pvt->call_id), "%d", ++globals.call_id); switch_core_hash_insert(globals.call_hash, tech_pvt->call_id, tech_pvt); switch_core_session_set_read_codec(tech_pvt->session, &globals.read_codec); @@ -785,7 +785,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (outbound_profile) { char name[128]; - const char *id = !switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na"; + const char *id = !zstr(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na"; snprintf(name, sizeof(name), "alsa/%s", id); switch_channel_set_name(channel, name); @@ -1186,7 +1186,7 @@ static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t * char *dtmf_str = argv[0]; switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) }; - if (switch_strlen_zero(dtmf_str)) { + if (zstr(dtmf_str)) { stream->write_function(stream, "No DTMF Supplied!\n"); } else { switch_mutex_lock(globals.pvt_lock); @@ -1212,7 +1212,7 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t uint8_t one_call = 0; switch_mutex_lock(globals.pvt_lock); - if (switch_strlen_zero(callid)) { + if (zstr(callid)) { if (globals.call_list) { if (globals.call_list->next) { tech_pvt = globals.call_list->next; @@ -1258,7 +1258,7 @@ static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t char *callid = argv[0]; switch_mutex_lock(globals.pvt_lock); - if (switch_strlen_zero(callid)) { + if (zstr(callid)) { tech_pvt = globals.call_list; } else { tech_pvt = switch_core_hash_find(globals.call_hash, callid); @@ -1285,7 +1285,7 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t switch_mutex_lock(globals.pvt_lock); - if (!switch_strlen_zero(callid)) { + if (!zstr(callid)) { if ((tp = switch_core_hash_find(globals.call_hash, callid))) { if (switch_test_flag(tp, TFLAG_ANSWER)) { stream->write_function(stream, "CALL ALREADY ANSWERED\n"); @@ -1458,23 +1458,23 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t return SWITCH_STATUS_MEMERR; } - if (!switch_strlen_zero(argv[1])) { + if (!zstr(argv[1])) { dialplan = argv[1]; } - if (!switch_strlen_zero(argv[2])) { + if (!zstr(argv[2])) { cid_num = argv[2]; } - if (!switch_strlen_zero(argv[3])) { + if (!zstr(argv[3])) { cid_name = argv[3]; } - if (!switch_strlen_zero(argv[4])) { + if (!zstr(argv[4])) { tech_pvt->sample_rate = atoi(argv[4]); } - if (!switch_strlen_zero(argv[5])) { + if (!zstr(argv[5])) { tech_pvt->codec_ms = atoi(argv[5]); } @@ -1576,13 +1576,13 @@ SWITCH_STANDARD_API(pa_cmd) } } - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto done; } } else { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", usage_string); goto done; } diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index c3ce666516..2aafac723b 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -344,7 +344,7 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames) char *status = argv[4]; //char *proto = argv[5]; - if (switch_strlen_zero(type)) { + if (zstr(type)) { type = NULL; } else if (!strcasecmp(type, "unavailable")) { status = NULL; @@ -550,7 +550,7 @@ static void roster_event_handler(switch_event_t *event) status = NULL; } - if (switch_strlen_zero(event_type)) { + if (zstr(event_type)) { event_type = "presence"; } @@ -1993,7 +1993,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val) profile->password = switch_core_strdup(module_pool, val); } else if (!strcasecmp(var, "avatar")) { profile->avatar = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { if (switch_odbc_available()) { profile->odbc_dsn = switch_core_strdup(module_pool, val); if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) { @@ -2007,17 +2007,17 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val) } } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) { switch_set_flag(profile, TFLAG_TIMER); - } else if (!strcasecmp(var, "dialplan") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "dialplan") && !zstr(val)) { profile->dialplan = switch_core_strdup(module_pool, val); #ifdef AUTO_REPLY // gotta fix looping on this } else if (!strcasecmp(var, "auto-reply")) { profile->auto_reply = switch_core_strdup(module_pool, val); #endif - } else if (!strcasecmp(var, "name") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "name") && !zstr(val)) { profile->name = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "message") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "message") && !zstr(val)) { profile->message = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "local-network-acl") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "local-network-acl") && !zstr(val)) { profile->local_network = switch_core_strdup(module_pool, val); } else if (!strcasecmp(var, "rtp-ip")) { profile->ip = switch_core_strdup(module_pool, strcasecmp(switch_str_nil(val), "auto") ? switch_str_nil(val) : globals.guess_ip); @@ -2030,14 +2030,14 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val) ip = globals.guess_ip; } else { globals.auto_nat = 0; - ip = switch_strlen_zero(val) ? globals.guess_ip : val; + ip = zstr(val) ? globals.guess_ip : val; } profile->extip = switch_core_strdup(module_pool, ip); - } else if (!strcasecmp(var, "server") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "server") && !zstr(val)) { profile->server = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "rtp-timer-name") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "rtp-timer-name") && !zstr(val)) { profile->timer_name = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "lanaddr") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "lanaddr") && !zstr(val)) { profile->lanaddr = switch_core_strdup(module_pool, val); } else if (!strcasecmp(var, "candidate-acl")) { if (profile->acl_count < MAX_ACL) { @@ -2055,11 +2055,11 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val) } else if (val && !strcasecmp(val, "md5")) { profile->user_flags |= LDL_FLAG_SASL_MD5; } - } else if (!strcasecmp(var, "exten") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "exten") && !zstr(val)) { profile->exten = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "context") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "context") && !zstr(val)) { profile->context = switch_core_strdup(module_pool, val); - } else if (!strcasecmp(var, "auto-login") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "auto-login") && !zstr(val)) { if (switch_true(val)) { switch_set_flag(profile, TFLAG_AUTO); } @@ -2162,7 +2162,7 @@ SWITCH_STANDARD_API(dingaling) if (session) return status; - if (switch_strlen_zero(cmd) || !(myarg = strdup(cmd))) { + if (zstr(cmd) || !(myarg = strdup(cmd))) { stream->write_function(stream, "USAGE: %s\n", DINGALING_SYNTAX); return SWITCH_STATUS_FALSE; } @@ -2214,7 +2214,7 @@ SWITCH_STANDARD_API(dl_login) goto done; } - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "USAGE: %s\n", LOGIN_SYNTAX); status = SWITCH_STATUS_SUCCESS; goto done; @@ -2224,7 +2224,7 @@ SWITCH_STANDARD_API(dl_login) argc = switch_separate_string(myarg, ';', argv, (sizeof(argv) / sizeof(argv[0]))); - if (switch_strlen_zero(cmd) || argc != 1) { + if (zstr(cmd) || argc != 1) { stream->write_function(stream, "USAGE: %s\n", LOGIN_SYNTAX); status = SWITCH_STATUS_SUCCESS; goto done; diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c index a61052d62a..30a95dc6d4 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -839,20 +839,20 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi *dialplan++ = '\0'; } - if (!switch_strlen_zero(context)) { + if (!zstr(context)) { caller_profile->context = switch_core_strdup(caller_profile->pool, context); } - if (!switch_strlen_zero(dialplan)) { + if (!zstr(dialplan)) { caller_profile->dialplan = switch_core_strdup(caller_profile->pool, dialplan); } } - if (switch_strlen_zero(caller_profile->context)) { + if (zstr(caller_profile->context)) { caller_profile->context = switch_core_strdup(caller_profile->pool, "default"); } - if (switch_strlen_zero(caller_profile->dialplan)) { + if (zstr(caller_profile->dialplan)) { caller_profile->dialplan = switch_core_strdup(caller_profile->pool, "xml"); } diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 7bef7485d4..8b3a79f151 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -749,7 +749,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (outbound_profile) { char name[128]; - const char *id = !switch_strlen_zero(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na"; + const char *id = !zstr(outbound_profile->caller_id_number) ? outbound_profile->caller_id_number : "na"; switch_snprintf(name, sizeof(name), "portaudio/%s", id); switch_channel_set_name(channel, name); @@ -1051,7 +1051,7 @@ static int get_dev_by_name(char *name, int in) int match = 0; pdi = Pa_GetDeviceInfo(i); - if (switch_strlen_zero(name)) { + if (zstr(name)) { match = 1; } else if (pdi && pdi->name && strstr(pdi->name, name)) { match = 1; @@ -1476,7 +1476,7 @@ static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t * char *dtmf_str = argv[0]; switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) }; - if (switch_strlen_zero(dtmf_str)) { + if (zstr(dtmf_str)) { stream->write_function(stream, "No DTMF Supplied!\n"); } else { switch_mutex_lock(globals.pvt_lock); @@ -1503,7 +1503,7 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t switch_mutex_lock(globals.pvt_lock); - if (switch_strlen_zero(callid)) { + if (zstr(callid)) { if (globals.call_list) { if (globals.call_list->next) { tech_pvt = globals.call_list->next; @@ -1548,7 +1548,7 @@ static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t char *callid = argv[0]; switch_mutex_lock(globals.pvt_lock); - if (switch_strlen_zero(callid)) { + if (zstr(callid)) { tech_pvt = globals.call_list; } else { tech_pvt = switch_core_hash_find(globals.call_hash, callid); @@ -1573,7 +1573,7 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t switch_mutex_lock(globals.pvt_lock); - if (!switch_strlen_zero(callid)) { + if (!zstr(callid)) { if ((tp = switch_core_hash_find(globals.call_hash, callid))) { if (switch_test_flag(tp, TFLAG_ANSWER)) { stream->write_function(stream, "CALL ALREADY ANSWERED\n"); @@ -1716,7 +1716,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t switch_status_t status = SWITCH_STATUS_SUCCESS; char *dest = NULL; - if (switch_strlen_zero(argv[0])) { + if (zstr(argv[0])) { stream->write_function(stream, "FAIL:Usage: call \n"); return SWITCH_STATUS_SUCCESS; } @@ -1745,23 +1745,23 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t return SWITCH_STATUS_MEMERR; } - if (!switch_strlen_zero(argv[1])) { + if (!zstr(argv[1])) { dialplan = argv[1]; } - if (!switch_strlen_zero(argv[2])) { + if (!zstr(argv[2])) { cid_num = argv[2]; } - if (!switch_strlen_zero(argv[3])) { + if (!zstr(argv[3])) { cid_name = argv[3]; } - if (!switch_strlen_zero(argv[4])) { + if (!zstr(argv[4])) { tech_pvt->sample_rate = atoi(argv[4]); } - if (!switch_strlen_zero(argv[5])) { + if (!zstr(argv[5])) { tech_pvt->codec_ms = atoi(argv[5]); } @@ -1862,13 +1862,13 @@ SWITCH_STANDARD_API(pa_cmd) } } - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto done; } } else { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", usage_string); goto done; } diff --git a/src/mod/endpoints/mod_skypiax/mod_skypiax.c b/src/mod/endpoints/mod_skypiax/mod_skypiax.c index 4cba1a7f74..e3fe59f3ff 100644 --- a/src/mod/endpoints/mod_skypiax/mod_skypiax.c +++ b/src/mod/endpoints/mod_skypiax/mod_skypiax.c @@ -866,7 +866,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi switch_core_session_add_stream(*new_session, NULL); - if (!switch_strlen_zero(outbound_profile->destination_number)) { + if (!zstr(outbound_profile->destination_number)) { int i; char *slash; @@ -1767,7 +1767,7 @@ int remote_party_is_ringing(private_t * tech_pvt) switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if (!switch_strlen_zero(tech_pvt->session_uuid_str)) { + if (!zstr(tech_pvt->session_uuid_str)) { session = switch_core_session_locate(tech_pvt->session_uuid_str); } else { ERRORA("No session???\n", SKYPIAX_P_LOG); @@ -1797,7 +1797,7 @@ int remote_party_is_early_media(private_t * tech_pvt) switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if (!switch_strlen_zero(tech_pvt->session_uuid_str)) { + if (!zstr(tech_pvt->session_uuid_str)) { session = switch_core_session_locate(tech_pvt->session_uuid_str); } else { ERRORA("No session???\n\n\n", SKYPIAX_P_LOG); @@ -1831,7 +1831,7 @@ int outbound_channel_answered(private_t * tech_pvt) switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if (!switch_strlen_zero(tech_pvt->session_uuid_str)) { + if (!zstr(tech_pvt->session_uuid_str)) { session = switch_core_session_locate(tech_pvt->session_uuid_str); } else { ERRORA("No session???\n", SKYPIAX_P_LOG); @@ -1917,7 +1917,7 @@ SWITCH_STANDARD_API(sk_function) else stream->write_function(stream, "sk console is NOT yet assigned\n"); - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -2031,7 +2031,7 @@ SWITCH_STANDARD_API(skypiax_function) int argc = 0; private_t *tech_pvt = NULL; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } @@ -2280,7 +2280,7 @@ int incoming_chatmessage(private_t * tech_pvt, int which) DEBUGA_SKYPE("received CHATMESSAGE on interface %s\n", SKYPIAX_P_LOG, tech_pvt->name); - if (!switch_strlen_zero(tech_pvt->session_uuid_str)) { + if (!zstr(tech_pvt->session_uuid_str)) { session = switch_core_session_locate(tech_pvt->session_uuid_str); } if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { @@ -2348,7 +2348,7 @@ SWITCH_STANDARD_API(skypiax_chat_function) int found = 0; //char skype_msg[1024]; - if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { + if (!zstr(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 2f2cca3788..51f5a690a3 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -88,7 +88,7 @@ static switch_status_t sofia_on_init(switch_core_session_t *session) if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND)) { const char *var; - if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && !switch_strlen_zero(var)) { + if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && !zstr(var)) { if (switch_true(var) || !strcasecmp(var, SWITCH_RTP_CRYPTO_KEY_32)) { sofia_set_flag_locked(tech_pvt, TFLAG_SECURE); sofia_glue_build_crypto(tech_pvt, 1, AES_CM_128_HMAC_SHA1_32, SWITCH_RTP_CRYPTO_SEND); @@ -185,17 +185,17 @@ char *generate_pai_str(switch_core_session_t *session) callee_name = switch_channel_get_variable(tech_pvt->channel, "callee_id_name"); } - if (switch_strlen_zero((callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number")))) { - if (switch_strlen_zero((callee_number = switch_channel_get_variable(tech_pvt->channel, "callee_id_number")))) { + if (zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number")))) { + if (zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "callee_id_number")))) { callee_number = tech_pvt->caller_profile->destination_number; } } - if (switch_strlen_zero(callee_name) && !switch_strlen_zero(callee_number)) { + if (zstr(callee_name) && !zstr(callee_number)) { callee_name = callee_number; } - if (!switch_strlen_zero(callee_name) && !switch_strlen_zero(callee_number)) { + if (!zstr(callee_name) && !zstr(callee_number)) { pai = switch_core_session_sprintf(tech_pvt->session, "P-Asserted-Identity: \"%s\" <%s>\nX-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", callee_name, callee_number, callee_name, callee_number); } @@ -312,7 +312,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) ps_cause = switch_channel_get_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE); } - if (!switch_strlen_zero(ps_cause) && (!strncasecmp(ps_cause, "sip:", 4) || !strncasecmp(ps_cause, "sips:", 5))) { + if (!zstr(ps_cause) && (!strncasecmp(ps_cause, "sip:", 4) || !strncasecmp(ps_cause, "sips:", 5))) { int new_cause = atoi(sofia_glue_strip_proto(ps_cause)); if (new_cause) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Overriding SIP cause %d with %d from the other leg\n", @@ -389,8 +389,8 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { nua_bye(tech_pvt->nh, SIPTAG_REASON_STR(reason), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), - TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END()); } } else { @@ -402,7 +402,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { nua_cancel(tech_pvt->nh, SIPTAG_REASON_STR(reason), - TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END()); } } else { @@ -413,7 +413,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), SIPTAG_REASON_STR(reason), - TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END()); } } @@ -488,7 +488,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), - TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT), TAG_END()); @@ -577,7 +577,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), - TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT), TAG_END()); switch_safe_free(extra_headers); @@ -1276,7 +1276,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi char *argv[2] = { 0 }; int argc; - if (switch_strlen_zero(name) && !switch_strlen_zero(msg->string_arg)) { + if (zstr(name) && !zstr(msg->string_arg)) { arg = strdup(msg->string_arg); switch_assert(arg); @@ -1286,37 +1286,37 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } - if (!switch_strlen_zero(name)) { + if (!zstr(name)) { char message[256] = ""; const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent"); switch_event_t *event; - if (switch_strlen_zero(number)) { + if (zstr(number)) { number = tech_pvt->caller_profile->destination_number; } if (!sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY)) { - if (switch_strlen_zero(tech_pvt->last_sent_callee_id_name) || strcmp(tech_pvt->last_sent_callee_id_name, name) || - switch_strlen_zero(tech_pvt->last_sent_callee_id_number) || strcmp(tech_pvt->last_sent_callee_id_number, number)) { + if (zstr(tech_pvt->last_sent_callee_id_name) || strcmp(tech_pvt->last_sent_callee_id_name, name) || + zstr(tech_pvt->last_sent_callee_id_number) || strcmp(tech_pvt->last_sent_callee_id_number, number)) { if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) { snprintf(message, sizeof(message), "X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", name, number); nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/update_display"), - TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END()); } else if (ua && switch_stristr("snom", ua)) { snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", name, number); nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END()); } else if ((ua && (switch_stristr("polycom", ua)))) { snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number); sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY); nua_update(tech_pvt->nh, - TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END()); } @@ -1348,20 +1348,20 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi { sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD); sofia_glue_do_invite(session); - if (!switch_strlen_zero(msg->string_arg)) { + if (!zstr(msg->string_arg)) { char message[256] = ""; const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent"); if (ua && switch_stristr("snom", ua)) { snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", msg->string_arg, tech_pvt->caller_profile->destination_number); nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END()); } else if (ua && switch_stristr("polycom", ua)) { snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", msg->string_arg, tech_pvt->caller_profile->destination_number); nua_update(tech_pvt->nh, - TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END()); } } @@ -1375,7 +1375,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } break; case SWITCH_MESSAGE_INDICATE_REDIRECT: - if (!switch_strlen_zero(msg->string_arg)) { + if (!zstr(msg->string_arg)) { if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { char *dest = (char *) msg->string_arg; @@ -1423,7 +1423,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (code) { reason = msg->string_arg; } else { - if (!switch_strlen_zero(msg->string_arg)) { + if (!zstr(msg->string_arg)) { if ((code = atoi(msg->string_arg))) { if ((reason = strchr(msg->string_arg, ' '))) { reason++; @@ -1442,9 +1442,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } } - if (switch_strlen_zero(reason) && code != 407 && code != 302) { + if (zstr(reason) && code != 407 && code != 302) { reason = sip_status_phrase(code); - if (switch_strlen_zero(reason)) { + if (zstr(reason)) { reason = "Because"; } } @@ -1455,7 +1455,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri"); const char *to_host = reason; - if (switch_strlen_zero(to_host)) { + if (zstr(to_host)) { to_host = switch_channel_get_variable(channel, "sip_to_host"); } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri); @@ -1479,12 +1479,12 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason); nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)), SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL), - TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), - TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), + TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); sofia_set_flag_locked(tech_pvt, TFLAG_BYE); } - } else if (code == 302 && !switch_strlen_zero(msg->string_arg)) { + } else if (code == 302 && !zstr(msg->string_arg)) { char *p; if ((p = strchr(msg->string_arg, ' '))) { @@ -1498,7 +1498,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } else { if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason); - if (!switch_strlen_zero(((char *) msg->pointer_arg))) { + if (!zstr(((char *) msg->pointer_arg))) { sofia_glue_tech_set_local_sdp(tech_pvt, (char *) msg->pointer_arg, SWITCH_TRUE); if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { @@ -1509,11 +1509,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), - TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); } else { nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), - TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); } } @@ -1528,7 +1528,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SIPTAG_HEADER_STR(generate_pai_str(session)), - TAG_IF(!switch_strlen_zero(extra_header), SIPTAG_HEADER_STR(extra_header)), + TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT), TAG_END()); switch_safe_free(extra_header); @@ -1614,7 +1614,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi SOATAG_ORDERED_USER(1), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), - TAG_IF(!switch_strlen_zero(extra_header), SIPTAG_HEADER_STR(extra_header)), + TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT), TAG_END()); switch_safe_free(extra_header); @@ -1795,7 +1795,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "Scheme \t%s\n", switch_str_nil(gp->register_scheme)); stream->write_function(stream, "Realm \t%s\n", switch_str_nil(gp->register_realm)); stream->write_function(stream, "Username\t%s\n", switch_str_nil(gp->register_username)); - stream->write_function(stream, "Password\t%s\n", switch_strlen_zero(gp->register_password) ? "no" : "yes"); + stream->write_function(stream, "Password\t%s\n", zstr(gp->register_password) ? "no" : "yes"); stream->write_function(stream, "From \t%s\n", switch_str_nil(gp->register_from)); stream->write_function(stream, "Contact \t%s\n", switch_str_nil(gp->register_contact)); stream->write_function(stream, "Exten \t%s\n", switch_str_nil(gp->extension)); @@ -1832,7 +1832,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "Dialplan \t%s\n", switch_str_nil(profile->dialplan)); stream->write_function(stream, "Context \t%s\n", switch_str_nil(profile->context)); stream->write_function(stream, "Challenge Realm \t%s\n", - switch_strlen_zero(profile->challenge_realm) ? "auto_to" : profile->challenge_realm); + zstr(profile->challenge_realm) ? "auto_to" : profile->challenge_realm); stream->write_function(stream, "RTP-IP \t%s\n", switch_str_nil(profile->rtpip)); if (profile->extrtpip) { stream->write_function(stream, "Ext-RTP-IP \t%s\n", profile->extrtpip); @@ -1848,8 +1848,8 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "TLS-URL \t%s\n", switch_str_nil(profile->tls_url)); stream->write_function(stream, "TLS-BIND-URL \t%s\n", switch_str_nil(profile->tls_bindurl)); } - stream->write_function(stream, "HOLD-MUSIC \t%s\n", switch_strlen_zero(profile->hold_music) ? "N/A" : profile->hold_music); - stream->write_function(stream, "OUTBOUND-PROXY \t%s\n", switch_strlen_zero(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); + stream->write_function(stream, "HOLD-MUSIC \t%s\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music); + stream->write_function(stream, "OUTBOUND-PROXY \t%s\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); stream->write_function(stream, "CODECS \t%s\n", switch_str_nil(profile->codec_string)); stream->write_function(stream, "TEL-EVENT \t%d\n", profile->te); if (profile->dtmf_type == DTMF_2833) { @@ -1906,9 +1906,9 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t host = dup; } - if (switch_strlen_zero(user) ) { + if (zstr(user) ) { sqlextra = switch_mprintf("(sip_host='%q')", host); - } else if (switch_strlen_zero(host)) { + } else if (zstr(host)) { sqlextra = switch_mprintf("(sip_user='%q')", user); } else { sqlextra = switch_mprintf("(sip_user='%q' and sip_host='%q')", user, host); @@ -2019,7 +2019,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl stream->write_function(stream, " %s\n", switch_str_nil(gp->register_scheme)); stream->write_function(stream, " %s\n", switch_str_nil(gp->register_realm)); stream->write_function(stream, " %s\n", switch_str_nil(gp->register_username)); - stream->write_function(stream, " %s\n", switch_strlen_zero(gp->register_password) ? "no" : "yes"); + stream->write_function(stream, " %s\n", zstr(gp->register_password) ? "no" : "yes"); stream->write_function(stream, " %s\n", switch_amp_encode(switch_str_nil(gp->register_from),xmlbuf,buflen)); stream->write_function(stream, " %s\n", switch_amp_encode(switch_str_nil(gp->register_contact),xmlbuf,buflen)); stream->write_function(stream, " %s\n", switch_amp_encode(switch_str_nil(gp->extension),xmlbuf,buflen)); @@ -2059,7 +2059,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl stream->write_function(stream, " %s\n", switch_str_nil(profile->dialplan)); stream->write_function(stream, " %s\n", switch_str_nil(profile->context)); stream->write_function(stream, " %s\n", - switch_strlen_zero(profile->challenge_realm) ? "auto_to" : profile->challenge_realm); + zstr(profile->challenge_realm) ? "auto_to" : profile->challenge_realm); stream->write_function(stream, " %s\n", switch_str_nil(profile->rtpip)); stream->write_function(stream, " %s\n", profile->extrtpip); stream->write_function(stream, " %s\n", switch_str_nil(profile->sipip)); @@ -2068,8 +2068,8 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl stream->write_function(stream, " %s\n", switch_str_nil(profile->bindurl)); stream->write_function(stream, " %s\n", switch_str_nil(profile->tls_url)); stream->write_function(stream, " %s\n", switch_str_nil(profile->tls_bindurl)); - stream->write_function(stream, " %s\n", switch_strlen_zero(profile->hold_music) ? "N/A" : profile->hold_music); - stream->write_function(stream, " %s\n", switch_strlen_zero(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); + stream->write_function(stream, " %s\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music); + stream->write_function(stream, " %s\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy); stream->write_function(stream, " %s\n", switch_str_nil(profile->codec_string)); stream->write_function(stream, " %d\n", profile->te); stream->write_function(stream, " rfc2833\n"); @@ -2127,9 +2127,9 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl host = dup; } - if (switch_strlen_zero(user)) { + if (zstr(user)) { sqlextra = switch_mprintf("(sip_host='%q')", host); - } else if (switch_strlen_zero(host)) { + } else if (zstr(host)) { sqlextra = switch_mprintf("(sip_user='%q')", user); } else { sqlextra = switch_mprintf("(sip_user='%q' and sip_host='%q')", user, host); @@ -2244,7 +2244,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t return SWITCH_STATUS_SUCCESS; } - if (switch_strlen_zero(profile_name) || !(profile = sofia_glue_find_profile(profile_name))) { + if (zstr(profile_name) || !(profile = sofia_glue_find_profile(profile_name))) { stream->write_function(stream, "Invalid Profile [%s]", switch_str_nil(profile_name)); return SWITCH_STATUS_SUCCESS; } @@ -2344,7 +2344,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t char *gname = argv[2]; sofia_gateway_t *gateway_ptr; - if (switch_strlen_zero(gname)) { + if (zstr(gname)) { stream->write_function(stream, "No gateway name provided!\n"); goto done; } @@ -2371,7 +2371,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t char *gname = argv[2]; sofia_gateway_t *gateway_ptr; - if (switch_strlen_zero(gname)) { + if (zstr(gname)) { stream->write_function(stream, "No gateway name provided!\n"); goto done; } @@ -2447,7 +2447,7 @@ static int contact_callback(void *pArg, int argc, char **argv, char **columnName struct cb_helper *cb = (struct cb_helper *) pArg; char *contact; - if (!switch_strlen_zero(argv[0]) && (contact = sofia_glue_get_url_from_contact(argv[0], 1)) ) { + if (!zstr(argv[0]) && (contact = sofia_glue_get_url_from_contact(argv[0], 1)) ) { cb->stream->write_function(cb->stream, "%ssofia/%s/sip:%s,", argv[2], argv[1], sofia_glue_strip_proto(contact)); free(contact); } @@ -2545,11 +2545,11 @@ SWITCH_STANDARD_API(sofia_contact_function) sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, contact_callback, &cb); switch_safe_free(sql); reply = (char *) mystream.data; - if (!switch_strlen_zero(reply) && end_of(reply) == ',') { + if (!zstr(reply) && end_of(reply) == ',') { end_of(reply) = '\0'; } - if (switch_strlen_zero(reply)) { + if (zstr(reply)) { reply = "error/user_not_registered"; } @@ -2583,7 +2583,7 @@ SWITCH_STANDARD_API(sofia_gateway_data_function) char *gwname, *param, *varname; const char *val = NULL; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR Parameter missing\n"); return SWITCH_STATUS_SUCCESS; } @@ -2599,7 +2599,7 @@ SWITCH_STANDARD_API(sofia_gateway_data_function) param = argv[1]; varname = argv[2]; - if (switch_strlen_zero(gwname) || switch_strlen_zero(param) || switch_strlen_zero(varname)) { + if (zstr(gwname) || zstr(param) || zstr(varname)) { goto end; } @@ -2647,7 +2647,7 @@ SWITCH_STANDARD_API(sofia_function) return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", usage_string); goto done; } @@ -2880,11 +2880,11 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session gateway_ptr->ob_calls++; - if (!switch_strlen_zero(gateway_ptr->from_domain) && !switch_channel_get_variable(nchannel, "sip_invite_domain")) { + if (!zstr(gateway_ptr->from_domain) && !switch_channel_get_variable(nchannel, "sip_invite_domain")) { switch_channel_set_variable(nchannel, "sip_invite_domain", gateway_ptr->from_domain); } - if (!switch_strlen_zero(gateway_ptr->outbound_sticky_proxy) && !switch_channel_get_variable(nchannel, "sip_route_uri")) { + if (!zstr(gateway_ptr->outbound_sticky_proxy) && !switch_channel_get_variable(nchannel, "sip_route_uri")) { switch_channel_set_variable(nchannel, "sip_route_uri", gateway_ptr->outbound_sticky_proxy); } @@ -3115,7 +3115,7 @@ static int notify_callback(void *pArg, int argc, char **argv, char **columnNames NUTAG_NEWSUB(1), SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), - TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)), + TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END()); @@ -3193,7 +3193,7 @@ static void general_event_handler(switch_event_t *event) NUTAG_WITH_THIS(profile->nua), SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), - TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)), + TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END()); sofia_glue_release_profile(profile); @@ -3212,7 +3212,7 @@ static void general_event_handler(switch_event_t *event) NUTAG_NEWSUB(1), SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), - TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)), + TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END()); } switch_core_session_rwunlock(session); @@ -3296,7 +3296,7 @@ static void general_event_handler(switch_event_t *event) nua_message(nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(ct), - TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)), + TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END()); @@ -3392,7 +3392,7 @@ static void general_event_handler(switch_event_t *event) TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(alert_info, SIPTAG_ALERT_INFO_STR(alert_info)), TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), - TAG_IF(!switch_strlen_zero(body), SIPTAG_PAYLOAD_STR(body)), + TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END()); if (call_id && nh) { diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index a915c2e4ea..660de3da34 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -818,7 +818,7 @@ void sofia_reg_release_gateway__(const char *file, const char *func, int line, s #define check_decode(_var, _session) do { \ assert(_session); \ - if (!switch_strlen_zero(_var)) { \ + if (!zstr(_var)) { \ int d = 0; \ char *p; \ if (strchr(_var, '%')) { \ diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index a0434b72d6..5d5832dce8 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -327,7 +327,7 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, switch_channel_hangup(channel, cause); nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), - TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); switch_safe_free(extra_headers); @@ -338,9 +338,9 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, #endif - if (sip->sip_user_agent && !switch_strlen_zero(sip->sip_user_agent->g_string)) { + if (sip->sip_user_agent && !zstr(sip->sip_user_agent->g_string)) { switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string); - } else if (sip->sip_server && !switch_strlen_zero(sip->sip_server->g_string)) { + } else if (sip->sip_server && !zstr(sip->sip_server->g_string)) { switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string); } @@ -384,19 +384,19 @@ void sofia_send_callee_id(switch_core_session_t *session, const char *name, cons switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(channel); - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = caller_profile->callee_id_name; } - if (switch_strlen_zero(number)) { + if (zstr(number)) { number = caller_profile->callee_id_number; } - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = number; } - if (switch_strlen_zero(number)) { + if (zstr(number)) { number = caller_profile->destination_number; } @@ -449,7 +449,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro if (passerted->paid_url && passerted->paid_url->url_user) { number = passerted->paid_url->url_user; } - if (!switch_strlen_zero(passerted->paid_display)) { + if (!zstr(passerted->paid_display)) { dup = strdup(passerted->paid_display); if (*dup == '"') { name = dup + 1; @@ -539,7 +539,7 @@ void sofia_event_callback(nua_event_t event, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile %s is locked\n", gateway->profile->name); return; } - } else if (!switch_strlen_zero(sofia_private->uuid)) { + } else if (!zstr(sofia_private->uuid)) { if ((session = switch_core_session_locate(sofia_private->uuid))) { tech_pvt = switch_core_session_get_private(session); channel = switch_core_session_get_channel(session); @@ -553,7 +553,7 @@ void sofia_event_callback(nua_event_t event, if (status >= 180 && !*sofia_private->auth_gateway_name) { const char *gwname = switch_channel_get_variable(channel, "sip_use_gateway"); - if (!switch_strlen_zero(gwname)) { + if (!zstr(gwname)) { switch_set_string(sofia_private->auth_gateway_name, gwname); } } @@ -1381,7 +1381,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) char *name = (char *) switch_xml_attr_soft(gateway_tag, "name"); sofia_gateway_t *gateway; - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = "anonymous"; } @@ -1545,33 +1545,33 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) parse_gateway_subscriptions(profile, gateway, gw_subs_tag); } - if (switch_strlen_zero(realm)) { - if (switch_strlen_zero(proxy)) { + if (zstr(realm)) { + if (zstr(proxy)) { realm = name; } else { realm = proxy; } } - if (switch_strlen_zero(username)) { + if (zstr(username)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: username param is REQUIRED!\n"); goto skip; } - if (switch_strlen_zero(password)) { + if (zstr(password)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: password param is REQUIRED!\n"); goto skip; } - if (switch_strlen_zero(from_user)) { + if (zstr(from_user)) { from_user = username; } - if (switch_strlen_zero(extension)) { + if (zstr(extension)) { extension = username; } - if (switch_strlen_zero(proxy)) { + if (zstr(proxy)) { proxy = realm; } @@ -1580,11 +1580,11 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) gateway->status = SOFIA_GATEWAY_UP; } - if (switch_strlen_zero(auth_username)) { + if (zstr(auth_username)) { auth_username = username; } - if (!switch_strlen_zero(register_proxy)) { + if (!zstr(register_proxy)) { if (strncasecmp(register_proxy, "sip:", 4) && strncasecmp(register_proxy, "sips:", 5)) { gateway->register_sticky_proxy = switch_core_sprintf(gateway->pool, "sip:%s", register_proxy); } else { @@ -1592,7 +1592,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) } } - if (!switch_strlen_zero(outbound_proxy)) { + if (!zstr(outbound_proxy)) { if (strncasecmp(outbound_proxy, "sip:", 4) && strncasecmp(outbound_proxy, "sips:", 5)) { gateway->outbound_sticky_proxy = switch_core_sprintf(gateway->pool, "sip:%s", outbound_proxy); } else { @@ -1631,13 +1631,13 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) params = switch_core_sprintf(gateway->pool, ";transport=%s;gw=%s", register_transport, gateway->name); } - if (!switch_strlen_zero(from_domain)) { + if (!zstr(from_domain)) { gateway->from_domain = switch_core_strdup(gateway->pool, from_domain); } gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s", proxy); gateway->register_from = switch_core_sprintf(gateway->pool, "", - from_user, !switch_strlen_zero(from_domain) ? from_domain : proxy, register_transport); + from_user, !zstr(from_domain) ? from_domain : proxy, register_transport); sipip = contact_host ? contact_host : profile->extsipip ? profile->extsipip : profile->sipip; @@ -2157,7 +2157,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) const char *parse = switch_xml_attr_soft(domain_tag, "parse"); const char *alias = switch_xml_attr_soft(domain_tag, "alias"); - if (!switch_strlen_zero(dname)) { + if (!zstr(dname)) { if (!strcasecmp(dname, "all")) { switch_xml_t xml_root, x_domains; if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { @@ -2180,7 +2180,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile) if ((aliases_tag = switch_xml_child(xprofile, "aliases"))) { for (alias_tag = switch_xml_child(aliases_tag, "alias"); alias_tag; alias_tag = alias_tag->next) { char *aname = (char *) switch_xml_attr_soft(alias_tag, "name"); - if (!switch_strlen_zero(aname)) { + if (!zstr(aname)) { if (sofia_glue_add_profile(switch_core_strdup(profile->pool, aname), profile) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", aname, profile->name); @@ -2236,7 +2236,7 @@ switch_status_t config_sofia(int reload, char *profile_name) su_log_redirect(stun_log, logger, NULL); } - if (!switch_strlen_zero(profile_name) && (profile = sofia_glue_find_profile(profile_name))) { + if (!zstr(profile_name) && (profile = sofia_glue_find_profile(profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Profile [%s] Already exists.\n", switch_str_nil(profile_name)); status = SWITCH_STATUS_FALSE; sofia_glue_release_profile(profile); @@ -2342,7 +2342,7 @@ switch_status_t config_sofia(int reload, char *profile_name) profile->debug = atoi(val); } else if (!strcasecmp(var, "sip-trace") && switch_true(val)) { sofia_set_flag(profile, TFLAG_TPORT_LOG); - } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) { if (switch_odbc_available()) { profile->odbc_dsn = switch_core_strdup(profile->pool, val); if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) { @@ -2467,7 +2467,7 @@ switch_status_t config_sofia(int reload, char *profile_name) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid option %s for VAD\n", val); } } else if (!strcasecmp(var, "ext-rtp-ip")) { - if (!switch_strlen_zero(val)) { + if (!zstr(val)) { char *ip = mod_sofia_globals.guess_ip; if (!strcmp(val, "0.0.0.0")) { @@ -2501,7 +2501,7 @@ switch_status_t config_sofia(int reload, char *profile_name) } profile->sipip = switch_core_strdup(profile->pool, ip); } else if (!strcasecmp(var, "ext-sip-ip")) { - if (!switch_strlen_zero(val)) { + if (!zstr(val)) { char *ip = mod_sofia_globals.guess_ip; char stun_ip[50] = ""; char *myip = stun_ip; @@ -3007,7 +3007,7 @@ switch_status_t config_sofia(int reload, char *profile_name) const char *parse = switch_xml_attr_soft(domain_tag, "parse"); const char *alias = switch_xml_attr_soft(domain_tag, "alias"); - if (!switch_strlen_zero(dname)) { + if (!zstr(dname)) { if (!strcasecmp(dname, "all")) { switch_xml_t xml_root, x_domains; if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) { @@ -3030,7 +3030,7 @@ switch_status_t config_sofia(int reload, char *profile_name) if ((aliases_tag = switch_xml_child(xprofile, "aliases"))) { for (alias_tag = switch_xml_child(aliases_tag, "alias"); alias_tag; alias_tag = alias_tag->next) { char *aname = (char *) switch_xml_attr_soft(alias_tag, "name"); - if (!switch_strlen_zero(aname)) { + if (!zstr(aname)) { if (sofia_glue_add_profile(switch_core_strdup(profile->pool, aname), profile) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", aname, profile->name); @@ -3083,7 +3083,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu { sofia_gateway_t *gateway = NULL; - if (sofia_private && !switch_strlen_zero(sofia_private->gateway_name)) { + if (sofia_private && !zstr(sofia_private->gateway_name)) { gateway = sofia_reg_find_gateway(sofia_private->gateway_name); sofia_private->destroy_me = 1; } @@ -3526,7 +3526,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, sdp_parser_t *parser; sdp_session_t *sdp; - if (!switch_strlen_zero(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp)) { + if (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Duplicate SDP\n%s\n", r_sdp); is_dup_sdp = 1; } else { @@ -4369,7 +4369,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t sofia_set_flag_locked(b_tech_pvt, TFLAG_BYE); nua_bye(b_tech_pvt->nh, SIPTAG_REASON_STR("Q.850;cause=16;text=\"normal_clearing\""), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END()); } } else { @@ -4429,11 +4429,11 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t const char *idest = switch_channel_get_variable(hup_channel, "inline_destination"); ext = switch_channel_get_variable(hup_channel, "destination_number"); - if (!switch_strlen_zero(full_ref_by)) { + if (!zstr(full_ref_by)) { switch_channel_set_variable(t_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by); } - if (!switch_strlen_zero(full_ref_to)) { + if (!zstr(full_ref_to)) { switch_channel_set_variable(t_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to); } @@ -4477,7 +4477,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t port = refer_to->r_url->url_port; } - if (switch_strlen_zero(port)) { + if (zstr(port)) { port = "5060"; } @@ -4517,11 +4517,11 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, rep); - if (!switch_strlen_zero(full_ref_by)) { + if (!zstr(full_ref_by)) { switch_channel_set_variable(channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by); } - if (!switch_strlen_zero(full_ref_to)) { + if (!zstr(full_ref_to)) { switch_channel_set_variable(channel, SOFIA_REFER_TO_VARIABLE, full_ref_to); } @@ -4564,10 +4564,10 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t if ((b_session = switch_core_session_locate(br))) { switch_channel_t *b_channel = switch_core_session_get_channel(b_session); switch_channel_set_variable(channel, "transfer_fallback_extension", from->a_user); - if (!switch_strlen_zero(full_ref_by)) { + if (!zstr(full_ref_by)) { switch_channel_set_variable(b_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by); } - if (!switch_strlen_zero(full_ref_to)) { + if (!zstr(full_ref_to)) { switch_channel_set_variable(b_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to); } @@ -4688,7 +4688,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t } if ((clientcode_header = sofia_glue_get_unknown_header(sip, "x-clientcode"))) { - if (!switch_strlen_zero(clientcode_header)) { + if (!zstr(clientcode_header)) { switch_channel_set_variable(channel, "call_clientcode", clientcode_header); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Setting CMC to %s\n", clientcode_header); nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END()); @@ -4697,7 +4697,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t } if ((rec_header = sofia_glue_get_unknown_header(sip, "record"))) { - if (switch_strlen_zero(profile->record_template)) { + if (zstr(profile->record_template)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Record attempted but no template defined.\n"); nua_respond(nh, 488, "Recording not enabled", NUTAG_WITH_THIS(nua), TAG_END()); } else { @@ -4810,16 +4810,16 @@ const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const user = url->url_user; host = url->url_host; port = url->url_port; - if (!switch_strlen_zero(url->url_params)) { + if (!zstr(url->url_params)) { switch_channel_set_variable(channel, params_var, url->url_params); } } - if (switch_strlen_zero(user)) { + if (zstr(user)) { user = "nobody"; } - if (switch_strlen_zero(host)) { + if (zstr(host)) { host = "nowhere"; } @@ -4926,7 +4926,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ contact_host = sip->sip_contact->m_url->url_host; } - if (!switch_strlen_zero(contact_host)) { + if (!zstr(contact_host)) { for (x = 0; x < profile->nat_acl_count; x++) { last_acl = profile->nat_acl[x]; if (!(ok = switch_check_network_list_ip(contact_host, last_acl))) { @@ -4992,7 +4992,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ "found auth ip [%s] header of [%s]\n", un->un_name, un->un_value ); - if (!switch_strlen_zero(un->un_value)) { + if (!zstr(un->un_value)) { for (x = 0; x < profile->acl_count; x++) { last_acl = profile->acl[x]; if ((ok = switch_check_network_list_ip_token(un->un_value, last_acl, &token))) { @@ -5139,7 +5139,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ from_host = sip->sip_from->a_url->url_host; channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from); - if (!switch_strlen_zero(from_user)) { + if (!zstr(from_user)) { if (*from_user == '+') { switch_channel_set_variable(channel, "sip_from_user_stripped", (const char *) (from_user + 1)); } else { @@ -5156,10 +5156,10 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ switch_channel_set_variable(channel, "sofia_profile_name", profile->name); switch_channel_set_variable(channel, "sofia_profile_domain_name", profile->domain_name); - if (!switch_strlen_zero(sip->sip_from->a_display)) { + if (!zstr(sip->sip_from->a_display)) { displayname = sip->sip_from->a_display; } else { - displayname = switch_strlen_zero(from_user) ? "unknown" : from_user; + displayname = zstr(from_user) ? "unknown" : from_user; } } @@ -5167,12 +5167,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if (rpid->rpid_url && rpid->rpid_url->url_user) { char *full_rpid_header = sip_header_as_string(nh->nh_home, (void *) rpid); from_user = rpid->rpid_url->url_user; - if (!switch_strlen_zero(full_rpid_header)) { + if (!zstr(full_rpid_header)) { switch_channel_set_variable(channel, "sip_Remote-Party-ID", full_rpid_header); } } - if (!switch_strlen_zero(rpid->rpid_display)) { + if (!zstr(rpid->rpid_display)) { displayname = rpid->rpid_display; } switch_channel_set_variable(channel, "sip_cid_type", "rpid"); @@ -5182,11 +5182,11 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if (passerted->paid_url && passerted->paid_url->url_user) { char *full_paid_header = sip_header_as_string(nh->nh_home, (void *) passerted); from_user = passerted->paid_url->url_user; - if (!switch_strlen_zero(full_paid_header)) { + if (!zstr(full_paid_header)) { switch_channel_set_variable(channel, "sip_P-Asserted-Identity", from_user); } } - if (!switch_strlen_zero(passerted->paid_display)) { + if (!zstr(passerted->paid_display)) { displayname = passerted->paid_display; } switch_channel_set_variable(channel, "sip_cid_type", "pid"); @@ -5196,12 +5196,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if (ppreferred->ppid_url && ppreferred->ppid_url->url_user) { char *full_ppid_header = sip_header_as_string(nh->nh_home, (void *) ppreferred); from_user = ppreferred->ppid_url->url_user; - if (!switch_strlen_zero(full_ppid_header)) { + if (!zstr(full_ppid_header)) { switch_channel_set_variable(channel, "sip_P-Preferred-Identity", full_ppid_header); } } - if (!switch_strlen_zero(ppreferred->ppid_display)) { + if (!zstr(ppreferred->ppid_display)) { displayname = ppreferred->ppid_display; } switch_channel_set_variable(channel, "sip_cid_type", "pid"); @@ -5346,7 +5346,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ check_decode(referred_by_user, session); - if (!switch_strlen_zero(referred_by_user)) { + if (!zstr(referred_by_user)) { if (*referred_by_user == '+') { switch_channel_set_variable(channel, "sip_referred_by_user_stripped", (const char *) (referred_by_user + 1)); } else { @@ -5383,7 +5383,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ switch_channel_set_variable(channel, "sip_subject", sip->sip_subject->g_string); } - if (sip->sip_user_agent && !switch_strlen_zero(sip->sip_user_agent->g_string)) { + if (sip->sip_user_agent && !zstr(sip->sip_user_agent->g_string)) { switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string); } @@ -5590,7 +5590,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if ((privacy = sip_privacy(sip))) { char *full_priv_header = sip_header_as_string(nh->nh_home, (void *) privacy); - if (!switch_strlen_zero(full_priv_header)) { + if (!zstr(full_priv_header)) { switch_channel_set_variable(channel, "sip_Privacy", full_priv_header); } if (msg_params_find(privacy->priv_values, "id")) { @@ -5603,7 +5603,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if (!strncasecmp(un->un_name, "Diversion", 9)) { /* Basic Diversion Support for Diversion Indication in SIP */ /* draft-levy-sip-diversion-08 */ - if (!switch_strlen_zero(un->un_value)) { + if (!zstr(un->un_value)) { char *tmp_name; if ((tmp_name = switch_mprintf("%s%s", SOFIA_SIP_HEADER_PREFIX, un->un_name))) { switch_channel_set_variable(channel, tmp_name, un->un_value); @@ -5615,7 +5615,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } else if (!strcasecmp(un->un_name, "X-FS-Support")) { tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, un->un_value); } else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) { - if (!switch_strlen_zero(un->un_value)) { + if (!zstr(un->un_value)) { char new_name[512] = ""; int reps = 0; for(;;) { @@ -5768,24 +5768,24 @@ void sofia_info_send_sipfrag(switch_core_session_t *aleg, switch_core_session_t switch_caller_profile_t *acp = a_tech_pvt->caller_profile; if (ua && switch_stristr("snom", ua)) { - if (switch_strlen_zero(acp->caller_id_name)) { + if (zstr(acp->caller_id_name)) { snprintf(message, sizeof(message), "From:\r\nTo: %s\r\n", acp->caller_id_number); } else { snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", acp->caller_id_name, acp->caller_id_number); } nua_info(b_tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), - TAG_IF(!switch_strlen_zero(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)), + TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END()); } else if (ua && switch_stristr("polycom", ua)) { - if (switch_strlen_zero(acp->caller_id_name)) { + if (zstr(acp->caller_id_name)) { snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", acp->caller_id_number, acp->caller_id_number); } else { snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", acp->caller_id_name, acp->caller_id_number); } nua_update(b_tech_pvt->nh, - TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)), - TAG_IF(!switch_strlen_zero(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)), + TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)), + TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)), TAG_END()); } diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index d6100e28ab..fda5df79e2 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -178,7 +178,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 tech_pvt->owner_id, tech_pvt->session_id, family, ip, username, family, ip, srbuf, port, - (!switch_strlen_zero(tech_pvt->local_crypto_key) + (!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt,TFLAG_SECURE)) ? "S" : ""); if (tech_pvt->rm_encoding) { @@ -276,7 +276,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=%s\n", sr); } - if (!switch_strlen_zero(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) { + if (!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) { switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=crypto:%s\n", tech_pvt->local_crypto_key); //switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=encryption:optional\n"); #if 0 @@ -571,7 +571,7 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_ } } - if (switch_strlen_zero(stun_ip)) { + if (zstr(stun_ip)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STUN Failed! NO STUN SERVER\n"); goto out; } @@ -632,7 +632,7 @@ const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name) sip_unknown_t *un; for (un = sip->sip_unknown; un; un = un->un_next) { if (!strcasecmp(un->un_name, name)) { - if (!switch_strlen_zero(un->un_value)) { + if (!zstr(un->un_value)) { return un->un_value; } } @@ -670,7 +670,7 @@ switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int forc sdp_port = tech_pvt->local_sdp_audio_port; if (!(use_ip = switch_channel_get_variable(tech_pvt->channel, "rtp_adv_audio_ip")) - && !switch_strlen_zero(tech_pvt->profile->extrtpip)) { + && !zstr(tech_pvt->profile->extrtpip)) { use_ip = tech_pvt->profile->extrtpip; } @@ -738,7 +738,7 @@ switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt, in sdp_port = tech_pvt->local_sdp_video_port; if (!(use_ip = switch_channel_get_variable(tech_pvt->channel, "rtp_adv_video_ip")) - && !switch_strlen_zero(tech_pvt->profile->extrtpip)) { + && !zstr(tech_pvt->profile->extrtpip)) { use_ip = tech_pvt->profile->extrtpip; } @@ -1005,7 +1005,7 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt) int x; const char *val; - if (switch_strlen_zero(tech_pvt->remote_sdp_str)) { + if (zstr(tech_pvt->remote_sdp_str)) { return SWITCH_STATUS_FALSE; } @@ -1137,7 +1137,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt) char *new_sdp; int bad = 0; - if (switch_strlen_zero(tech_pvt->local_sdp_str)) { + if (zstr(tech_pvt->local_sdp_str)) { return; } @@ -1148,7 +1148,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt) return; } - if (switch_strlen_zero(tech_pvt->adv_sdp_audio_ip) || !tech_pvt->adv_sdp_audio_port) { + if (zstr(tech_pvt->adv_sdp_audio_ip) || !tech_pvt->adv_sdp_audio_port) { if (sofia_glue_tech_choose_port(tech_pvt, 1) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "%s I/O Error\n", switch_channel_get_name(tech_pvt->channel)); return; @@ -1360,7 +1360,7 @@ char* sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix switch_channel_variable_last(channel); } - if (!switch_strlen_zero((char*)stream.data)) { + if (!zstr((char*)stream.data)) { extra_headers = stream.data; } else { switch_safe_free(stream.data); @@ -1380,7 +1380,7 @@ void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, c for (un = sip->sip_unknown; un; un = un->un_next) { if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) { - if (!switch_strlen_zero(un->un_value)) { + if (!zstr(un->un_value)) { switch_snprintf(name, sizeof(name), "%s%s", prefix, un->un_name); switch_channel_set_variable(channel, name, un->un_value); } @@ -1448,7 +1448,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) format, cid_name, cid_num, - !switch_strlen_zero(cid_num) ? "@" : "", + !zstr(cid_num) ? "@" : "", sipip); } @@ -1482,7 +1482,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri"); const char *from_display = switch_channel_get_variable(tech_pvt->channel, "sip_from_display"); - if (switch_strlen_zero(tech_pvt->dest)) { + if (zstr(tech_pvt->dest)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "URL Error!\n"); return SWITCH_STATUS_FALSE; } @@ -1501,15 +1501,15 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) } else { use_from_str = switch_core_session_sprintf(tech_pvt->session, "sip:%s", from_var); } - } else if (!switch_strlen_zero(tech_pvt->gateway_from_str)) { + } else if (!zstr(tech_pvt->gateway_from_str)) { use_from_str = tech_pvt->gateway_from_str; } else { use_from_str = tech_pvt->from_str; } - if (!switch_strlen_zero(tech_pvt->gateway_from_str)) { + if (!zstr(tech_pvt->gateway_from_str)) { rpid_domain = switch_core_session_strdup(session, tech_pvt->gateway_from_str); - } else if (!switch_strlen_zero(tech_pvt->from_str)) { + } else if (!zstr(tech_pvt->from_str)) { rpid_domain = switch_core_session_strdup(session, tech_pvt->from_str); } @@ -1529,7 +1529,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) * Ignore transport chanvar and uri parameter for gateway connections * since all of them have been already taken care of in mod_sofia.c:sofia_outgoing_channel() */ - if (tech_pvt->transport == SOFIA_TRANSPORT_UNKNOWN && switch_strlen_zero(tech_pvt->gateway_name)) { + if (tech_pvt->transport == SOFIA_TRANSPORT_UNKNOWN && zstr(tech_pvt->gateway_name)) { if ((p = (char *) switch_stristr("port=", url))) { p += 5; tech_pvt->transport = sofia_glue_str2transport(p); @@ -1553,7 +1553,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(tech_pvt->invite_contact)) { + if (zstr(tech_pvt->invite_contact)) { const char * contact; if ((contact = switch_channel_get_variable(channel, "sip_contact_user"))) { char *ip_addr; @@ -1740,7 +1740,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) sofia_glue_tech_patch_sdp(tech_pvt); } - if (!switch_strlen_zero(tech_pvt->dest)) { + if (!zstr(tech_pvt->dest)) { dst = sofia_glue_get_destination(tech_pvt->dest); if (dst->route_uri) { @@ -1766,17 +1766,17 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) NUTAG_AUTOANSWER(0), NUTAG_SESSION_TIMER(session_timeout), TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), - TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)), - TAG_IF(!switch_strlen_zero(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)), - TAG_IF(!switch_strlen_zero(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)), - TAG_IF(!switch_strlen_zero(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->privacy)), - TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)), - TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)), + TAG_IF(!zstr(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)), + TAG_IF(!zstr(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)), + TAG_IF(!zstr(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->privacy)), + TAG_IF(!zstr(alert_info), SIPTAG_HEADER_STR(alert_info)), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT), - TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), - TAG_IF(!switch_strlen_zero(route_uri), NUTAG_PROXY(route_uri)), - TAG_IF(!switch_strlen_zero(route), SIPTAG_ROUTE_STR(route)), + TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), + TAG_IF(!zstr(route_uri), NUTAG_PROXY(route_uri)), + TAG_IF(!zstr(route), SIPTAG_ROUTE_STR(route)), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), @@ -1828,7 +1828,7 @@ void sofia_glue_do_xfer_invite(switch_core_session_t *session) nua_invite(tech_pvt->nh2, SIPTAG_CONTACT_STR(contact_url), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_REUSE_REJECTED(1), @@ -2606,7 +2606,7 @@ void sofia_glue_set_r_sdp_codec_string(switch_channel_t *channel,const char *cod char *codec_order[SWITCH_MAX_CODECS]; const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS] = { 0 }; - if (!switch_strlen_zero(codec_string)) { + if (!zstr(codec_string)) { char *tmp_codec_string; if ((tmp_codec_string = strdup(codec_string))) { num_codecs = switch_separate_string(tmp_codec_string, ',', codec_order, SWITCH_MAX_CODECS); @@ -2622,7 +2622,7 @@ void sofia_glue_set_r_sdp_codec_string(switch_channel_t *channel,const char *cod } for (attr = sdp->sdp_attributes; attr; attr = attr->a_next) { - if (switch_strlen_zero(attr->a_name)) { + if (zstr(attr->a_name)) { continue; } @@ -2638,7 +2638,7 @@ void sofia_glue_set_r_sdp_codec_string(switch_channel_t *channel,const char *cod switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",t38"); } else if (m->m_type == sdp_media_audio && m->m_port) { for (attr = m->m_attributes; attr; attr = attr->a_next) { - if (switch_strlen_zero(attr->a_name)) { + if (zstr(attr->a_name)) { continue; } if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) { @@ -2744,7 +2744,7 @@ switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_ switch_assert(tech_pvt != NULL); switch_assert(r_sdp != NULL); - if (switch_strlen_zero(r_sdp)) { + if (zstr(r_sdp)) { return SWITCH_STATUS_FALSE; } @@ -2903,7 +2903,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * } for (attr = sdp->sdp_attributes; attr; attr = attr->a_next) { - if (switch_strlen_zero(attr->a_name)) { + if (zstr(attr->a_name)) { continue; } @@ -2975,7 +2975,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * ptime = atoi(attr->a_value); } else if (!strcasecmp(attr->a_name, "maxptime") && attr->a_value) { maxptime = atoi(attr->a_value); - } else if (!got_crypto && !strcasecmp(attr->a_name, "crypto") && !switch_strlen_zero(attr->a_value)) { + } else if (!got_crypto && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) { int crypto_tag; if (m->m_proto != sdp_proto_srtp) { @@ -3030,7 +3030,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * tech_pvt->crypto_tag = crypto_tag; got_crypto++; - if (switch_strlen_zero(tech_pvt->local_crypto_key)) { + if (zstr(tech_pvt->local_crypto_key)) { if (switch_stristr(SWITCH_RTP_CRYPTO_KEY_32, crypto)) { switch_channel_set_variable(tech_pvt->channel, SOFIA_HAS_CRYPTO_VARIABLE, SWITCH_RTP_CRYPTO_KEY_32); sofia_glue_build_crypto(tech_pvt, atoi(crypto), AES_CM_128_HMAC_SHA1_32, SWITCH_RTP_CRYPTO_SEND); @@ -3075,7 +3075,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * } for (map = m->m_rtpmaps; map; map = map->rm_next) { - if (switch_strlen_zero(map->rm_encoding) && map->rm_pt < 96) { + if (zstr(map->rm_encoding) && map->rm_pt < 96) { match = (map->rm_pt == tech_pvt->pt) ? 1 : 0; } else { match = strcasecmp(switch_str_nil(map->rm_encoding), tech_pvt->iananame) ? 0 : 1; @@ -3160,7 +3160,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d]/[%s:%d:%u:%d]\n", rm_encoding, map->rm_pt, (int) map->rm_rate, ptime, imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000); - if (switch_strlen_zero(map->rm_encoding) && map->rm_pt < 96) { + if (zstr(map->rm_encoding) && map->rm_pt < 96) { match = (map->rm_pt == imp->ianacode) ? 1 : 0; } else { match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1; @@ -3226,7 +3226,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * tech_pvt->iananame = switch_core_session_strdup(session, (char *) mimp->iananame); tech_pvt->pt = (switch_payload_t) map->rm_pt; tech_pvt->rm_rate = map->rm_rate; - if (!strcasecmp((char *) mimp->iananame, "ilbc") && switch_strlen_zero((char*)map->rm_fmtp)) { + if (!strcasecmp((char *) mimp->iananame, "ilbc") && zstr((char*)map->rm_fmtp)) { /* default to 30 when no mode is defined for ilbc ONLY */ tech_pvt->codec_ms = 30; } else { @@ -3994,7 +3994,7 @@ void sofia_glue_actually_execute_sql(sofia_profile_t *profile, switch_bool_t mas if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) { char *err_str; err_str = switch_odbc_handle_get_error(profile->master_odbc, stmt); - if (!switch_strlen_zero(err_str)) { + if (!zstr(err_str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, err_str); } switch_safe_free(err_str); @@ -4225,7 +4225,7 @@ sofia_destination_t* sofia_glue_get_destination(char *data) char *eoc = NULL; char *p = NULL; - if (switch_strlen_zero(data)) { + if (zstr(data)) { return NULL; } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 4ceb9d6554..5093c1adc3 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -68,7 +68,7 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co goto end; } - if (!switch_strlen_zero(type)) { + if (!zstr(type)) { ct = type; } @@ -96,9 +96,9 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co goto end; } - if (switch_strlen_zero(host)) { + if (zstr(host)) { host = profile->domain_name; - if (switch_strlen_zero(host)) { + if (zstr(host)) { host = prof; } } @@ -123,9 +123,9 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co *p++ = '\0'; } - if (switch_strlen_zero(p)) { + if (zstr(p)) { p = profile->domain_name; - if (switch_strlen_zero(p)) { + if (zstr(p)) { p = host; } } @@ -463,11 +463,11 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) return; } - if (switch_strlen_zero(event_type)) { + if (zstr(event_type)) { event_type = "presence"; } - if (switch_strlen_zero(alt_event_type)) { + if (zstr(alt_event_type)) { alt_event_type = "presence"; } @@ -625,7 +625,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) switch_safe_free(sql); - if (!switch_strlen_zero((char *) helper.stream.data)) { + if (!zstr((char *) helper.stream.data)) { char *this_sql = (char *) helper.stream.data; char *next = NULL; char *last = NULL; @@ -638,7 +638,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) } } - if (!switch_strlen_zero(this_sql) && (!last || strcmp(last, this_sql))) { + if (!zstr(this_sql) && (!last || strcmp(last, this_sql))) { sofia_glue_execute_sql(profile, &this_sql, SWITCH_FALSE); last = this_sql; } @@ -839,13 +839,13 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char switch_url_decode(to_buf); to_user = to_buf; } - if (argc > 10 && !switch_strlen_zero(argv[9]) && !switch_strlen_zero(argv[10])) { + if (argc > 10 && !zstr(argv[9]) && !zstr(argv[10])) { status = argv[9]; rpid = argv[10]; } } - if (switch_strlen_zero(proto)) { + if (zstr(proto)) { proto = NULL; } @@ -863,11 +863,11 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", 0); - if (!switch_strlen_zero(to_user)) { + if (!zstr(to_user)) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to-user", to_user); } - if (switch_strlen_zero(state)) { + if (zstr(state)) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", SOFIA_CHAT_PROTO); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "resubscribe"); @@ -1004,7 +1004,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * int kill_handle = 0; char expires_str[10] = ""; - if (argc > 18 && !switch_strlen_zero(argv[17]) && !switch_strlen_zero(argv[18])) { + if (argc > 18 && !zstr(argv[17]) && !zstr(argv[18])) { status = argv[17]; rpid = argv[18]; } @@ -1012,11 +1012,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * in = helper->event && helper->event->event_id == SWITCH_EVENT_PRESENCE_IN; - if (switch_strlen_zero(rpid)) { + if (zstr(rpid)) { rpid = "unknown"; } - if (switch_strlen_zero(status)) { + if (zstr(status)) { if (!strcasecmp(rpid, "busy")) { status = "Busy"; } else if (!strcasecmp(rpid, "unavailable")) { @@ -1135,9 +1135,9 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * if (!strcasecmp(state, "cs_hangup")) { astate = "terminated"; - } else if (switch_strlen_zero(astate)) { + } else if (zstr(astate)) { astate = switch_str_nil(switch_event_get_header(helper->event, "answer-state")); - if (switch_strlen_zero(astate)) { + if (zstr(astate)) { if (is_dialog) { astate = dft_state; } else { @@ -1171,7 +1171,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * clean_from_user = switch_mprintf("%s", from_id ? from_id : from_user); if (is_dialog) { - if (!switch_strlen_zero(clean_to_user) && !switch_strlen_zero(clean_from_user)) { + if (!zstr(clean_to_user) && !zstr(clean_from_user)) { stream.write_function(&stream, "\nsip:%s@%s\n", clean_to_user, clean_to_user, host); stream.write_function(&stream, "\n", clean_to_user, host); stream.write_function(&stream, "\n", @@ -1183,7 +1183,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * stream.write_function(&stream, "\n"); } else if (!strcasecmp(proto, "park")) { stream.write_function(&stream, "\nsip:parking@%s;fifo=%s\n", - host, !switch_strlen_zero(clean_to_user) ? clean_to_user : "unknown"); + host, !zstr(clean_to_user) ? clean_to_user : "unknown"); stream.write_function(&stream, "\n", host); stream.write_function(&stream, "\n\n\n"); stream.write_function(&stream, "\nsip:%s\n", uuid); @@ -1191,7 +1191,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * stream.write_function(&stream, "\n"); } else if (!strcasecmp(proto, "conf")) { stream.write_function(&stream, "\nsip:conference@%s;conference=%s\n", - host, !switch_strlen_zero(clean_to_user) ? clean_to_user : "unknown"); + host, !zstr(clean_to_user) ? clean_to_user : "unknown"); stream.write_function(&stream, "\n", host); stream.write_function(&stream, "\n\n\n"); stream.write_function(&stream, "\nsip:%s@%s\n", uuid, host); @@ -1214,7 +1214,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * ct = "application/dialog-info+xml"; } - if (!switch_strlen_zero(astate) && !switch_strlen_zero(uuid) && helper && helper->stream.data && strcmp(helper->last_uuid, uuid)) { + if (!zstr(astate) && !zstr(uuid) && helper && helper->stream.data && strcmp(helper->last_uuid, uuid)) { helper->stream.write_function(&helper->stream, "update sip_dialogs set state='%s' where uuid='%s';", astate, uuid); switch_copy_string(helper->last_uuid, uuid, sizeof(helper->last_uuid)); @@ -1231,15 +1231,15 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * rpid = "on-the-phone"; } else if (!strcmp(astate, "confirmed")) { char *dest = switch_event_get_header(helper->event, "Caller-Destination-Number"); - if (switch_strlen_zero(from_id) && !switch_strlen_zero(dest)) { + if (zstr(from_id) && !zstr(dest)) { from_id = dest; } - if (switch_strlen_zero(from_id)) { + if (zstr(from_id)) { from_id = p_to_user; } - if (switch_strlen_zero(from_id)) { + if (zstr(from_id)) { switch_snprintf(status_line, sizeof(status_line), "On The Phone %s", status); } else { switch_snprintf(status_line, sizeof(status_line), "Talk %s", switch_str_nil(from_id)); @@ -1450,10 +1450,10 @@ void sofia_presence_handle_sip_i_subscribe(int status, display = contact->m_display; - if (switch_strlen_zero(display)) { + if (zstr(display)) { if (from) { display = from->a_display; - if (switch_strlen_zero(display)) { + if (zstr(display)) { display = "\"user\""; } } @@ -1481,7 +1481,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, int ok = 1; char *last_acl = NULL; - if (!switch_strlen_zero(contact_host)) { + if (!zstr(contact_host)) { for (x = 0; x < profile->nat_acl_count; x++) { last_acl = profile->nat_acl[x]; if (!(ok = switch_check_network_list_ip(contact_host, last_acl))) { @@ -1922,12 +1922,12 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n } if (!strcasecmp(status_txt, "open")) { - if (switch_strlen_zero(note_txt)) { + if (zstr(note_txt)) { note_txt = "Available"; } in = 1; } else if (!strcasecmp(status_txt, "closed")) { - if (switch_strlen_zero(note_txt)) { + if (zstr(note_txt)) { note_txt = "Unavailable"; } } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index a6f52c651e..33c81fbe3b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -508,7 +508,7 @@ void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int host = "none"; } - if (switch_strlen_zero(user)) { + if (zstr(user)) { sqlextra = switch_mprintf(" or (sip_host='%q')", host); } else { sqlextra = switch_mprintf(" or (sip_user='%q' and sip_host='%q')", user, host); @@ -822,10 +822,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand } } - if (switch_strlen_zero(display)) { + if (zstr(display)) { if (to) { display = to->a_display; - if (switch_strlen_zero(display)) { + if (zstr(display)) { display = "\"user\""; } } @@ -991,7 +991,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand if (!authorization || stale) { const char *realm = profile->challenge_realm; - if (switch_strlen_zero(realm) || !strcasecmp(realm, "auto_to")) { + if (zstr(realm) || !strcasecmp(realm, "auto_to")) { realm = to_host; } else if (!strcasecmp(realm, "auto_from")) { realm = from_host; @@ -1320,7 +1320,7 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h contact_host = sip->sip_contact->m_url->url_host; } - if (!switch_strlen_zero(contact_host)) { + if (!zstr(contact_host)) { for (x = 0; x < profile->nat_acl_count; x++) { last_acl = profile->nat_acl[x]; if (!(ok = switch_check_network_list_ip(contact_host, last_acl))) { @@ -1649,14 +1649,14 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, /* Optional check that auth name == SIP username */ if ((regtype == REG_REGISTER) && sofia_test_pflag(profile, PFLAG_CHECKUSER)) { - if (switch_strlen_zero(username) || switch_strlen_zero(to_user) || strcasecmp(to_user, username)) { + if (zstr(username) || zstr(to_user) || strcasecmp(to_user, username)) { /* Names don't match, so fail */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SIP username %s does not match auth username\n", switch_str_nil(to_user)); goto end; } } - if (switch_strlen_zero(np)) { + if (zstr(np)) { first = 1; sql = switch_mprintf("select nonce from sip_authentication where nonce='%q'", nonce); switch_assert(sql != NULL); @@ -1726,13 +1726,13 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, } - if (!switch_strlen_zero(profile->reg_domain)) { + if (!zstr(profile->reg_domain)) { domain_name = profile->reg_domain; } else { domain_name = realm; } - if (switch_xml_locate_user("id", switch_strlen_zero(username) ? "nobody" : username, + if (switch_xml_locate_user("id", zstr(username) ? "nobody" : username, domain_name, ip, &xml, &domain, &user, &group, params) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n" "You must define a domain called '%s' in your directory and add a user with the id=\"%s\" attribute\n" @@ -1751,7 +1751,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, } if (!(number_alias = (char *) switch_xml_attr(user, "number-alias"))) { - number_alias = switch_strlen_zero(username) ? "nobody" : username; + number_alias = zstr(username) ? "nobody" : username; } dparams = switch_xml_child(domain, "params"); @@ -1854,7 +1854,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, } } - if (switch_strlen_zero(passwd) && switch_strlen_zero(a1_hash)) { + if (zstr(passwd) && zstr(a1_hash)) { ret = AUTH_OK; goto skip_auth; } @@ -1973,7 +1973,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, const char *val = switch_xml_attr_soft(param, "value"); sofia_gateway_t *gateway_ptr = NULL; - if (!switch_strlen_zero(var) && !switch_strlen_zero(val) && (xparams_type[j] == 1 || !strncasecmp(var, "sip-",4) || !strcasecmp(var, "register-gateway")) ) { + if (!zstr(var) && !zstr(val) && (xparams_type[j] == 1 || !strncasecmp(var, "sip-",4) || !strcasecmp(var, "register-gateway")) ) { if (!switch_event_get_header(*v_event, var)) { if (profile->debug) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event_add_header -> '%s' = '%s'\n",var, val); @@ -1989,7 +1989,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, if ((gateways_tag = switch_xml_child(user, "gateways"))) { for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) { char *name = (char *) switch_xml_attr_soft(gateway_tag, "name"); - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = "anonymous"; } diff --git a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c index 11cb43880b..4423a9cfe6 100644 --- a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c +++ b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c @@ -372,7 +372,7 @@ static switch_status_t load_config(switch_memory_pool_t *pool) } - if (switch_strlen_zero(globals.default_template)) { + if (zstr(globals.default_template)) { globals.default_template = switch_core_strdup(pool, "default"); } diff --git a/src/mod/event_handlers/mod_erlang_event/ei_helpers.c b/src/mod/event_handlers/mod_erlang_event/ei_helpers.c index 319cb55b81..e5ce923d5a 100644 --- a/src/mod/event_handlers/mod_erlang_event/ei_helpers.c +++ b/src/mod/event_handlers/mod_erlang_event/ei_helpers.c @@ -347,7 +347,7 @@ switch_status_t initialise_ei(struct ei_cnode_s *ec) #endif memcpy(thishostname, nodehost->h_name, EI_MAXHOSTNAMELEN); - if (switch_strlen_zero_buf(thishostname)) { + if (zstr_buf(thishostname)) { gethostname(thishostname, EI_MAXHOSTNAMELEN); } diff --git a/src/mod/event_handlers/mod_erlang_event/handle_msg.c b/src/mod/event_handlers/mod_erlang_event/handle_msg.c index dfe899d5b7..4167ecff55 100644 --- a/src/mod/event_handlers/mod_erlang_event/handle_msg.c +++ b/src/mod/event_handlers/mod_erlang_event/handle_msg.c @@ -465,7 +465,7 @@ static switch_status_t handle_msg_sendmsg(listener_t *listener, int arity, ei_x_ } else { switch_core_session_t *session; - if (!switch_strlen_zero_buf(uuid) && (session = switch_core_session_locate(uuid))) { + if (!zstr_buf(uuid) && (session = switch_core_session_locate(uuid))) { switch_event_t *event; if (switch_event_create(&event, SWITCH_EVENT_SEND_MESSAGE) == SWITCH_STATUS_SUCCESS) { @@ -577,7 +577,7 @@ static switch_status_t handle_msg_handlecall(listener_t *listener, erlang_msg *m ei_x_encode_atom(rbuf, "badarg"); } else { switch_core_session_t *session; - if (!switch_strlen_zero_buf(uuid_str)) { + if (!zstr_buf(uuid_str)) { if ((session = switch_core_session_locate(uuid_str))) { /* create a new session list element and attach it to this listener */ if ((arity==2 && attach_call_to_pid(listener, &msg->from, session)) || diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index 9f7667324a..42d8f3c8dc 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -451,7 +451,7 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got data %s after %d milliseconds!\n", xmlstr, i*10); - if (switch_strlen_zero(xmlstr)) { + if (zstr(xmlstr)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n"); } else if (!(xml = switch_xml_parse_str_dynamic(xmlstr, SWITCH_FALSE))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing XML Result!\n"); @@ -848,7 +848,7 @@ static void listener_main_loop(listener_t *listener) static switch_bool_t check_inbound_acl(listener_t* listener) { /* check acl to see if inbound connection is allowed */ - if (prefs.acl_count && !switch_strlen_zero(listener->remote_ip)) { + if (prefs.acl_count && !zstr(listener->remote_ip)) { uint32_t x = 0; for (x = 0; x < prefs.acl_count; x++) { if (!switch_check_network_list_ip(listener->remote_ip, prefs.acl[x])) { @@ -904,7 +904,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) switch_assert(listener != NULL); if (check_inbound_acl(listener)) { - if (switch_strlen_zero(listener->remote_ip)) { + if (zstr(listener->remote_ip)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open\n"); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open from %s\n", listener->remote_ip);/*, listener->remote_port);*/ @@ -1027,11 +1027,11 @@ static int config(void) switch_xml_free(xml); } - if (switch_strlen_zero(prefs.ip)) { + if (zstr(prefs.ip)) { set_pref_ip("0.0.0.0"); } - if (switch_strlen_zero(prefs.cookie)) { + if (zstr(prefs.cookie)) { set_pref_cookie("ClueCon"); } @@ -1319,7 +1319,7 @@ SWITCH_STANDARD_APP(erlang_outbound_function) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error - need registered name and node!\n"); return; } - if (switch_strlen_zero(argv[0])) { + if (zstr(argv[0])) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing registered name or module:function!\n"); return; } @@ -1339,7 +1339,7 @@ SWITCH_STANDARD_APP(erlang_outbound_function) node = argv[1]; - if (switch_strlen_zero(node)) { + if (zstr(node)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing node name!\n"); return; } @@ -1451,7 +1451,7 @@ SWITCH_STANDARD_API(erlang_cmd) "erlang sessions \n" "--------------------------------------------------------------------------------\n"; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", usage_string); goto done; } diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index b5d23afe9f..e7ab4eddda 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -356,7 +356,7 @@ SWITCH_STANDARD_APP(socket_function) host = argv[0]; - if (switch_strlen_zero(host)) { + if (zstr(host)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing Host!\n"); return; } @@ -617,7 +617,7 @@ SWITCH_STANDARD_API(event_sink_function) goto end; } - if (switch_strlen_zero(action)) { + if (zstr(action)) { stream->write_function(stream, "Invalid Syntax\n"); goto end; } @@ -628,7 +628,7 @@ SWITCH_STANDARD_API(event_sink_function) } if (!strcasecmp(action, "delete")) { - if (switch_strlen_zero(header_val)) { + if (zstr(header_val)) { stream->write_function(stream, "Invalid Syntax\n"); goto filter_end; } @@ -641,7 +641,7 @@ SWITCH_STANDARD_API(event_sink_function) } stream->write_function(stream, "\n filter deleted.\n\n"); } else if (!strcasecmp(action, "add")) { - if (switch_strlen_zero(header_name) || switch_strlen_zero(header_val)) { + if (zstr(header_name) || zstr(header_val)) { stream->write_function(stream, "Invalid Syntax\n"); goto filter_end; } @@ -715,7 +715,7 @@ SWITCH_STANDARD_API(event_sink_function) uint8_t custom = 0; char *edup; - if (switch_strlen_zero(events) && switch_strlen_zero(loglevel)) { + if (zstr(events) && zstr(loglevel)) { stream->write_function(stream, "Missing parameter!\n"); goto end; } @@ -1068,7 +1068,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event, char *var, *val; var = cur; strip_cr(var); - if (!switch_strlen_zero(var)) { + if (!zstr(var)) { if ((val = strchr(var, ':'))) { *val++ = '\0'; while (*val == ' ') { @@ -1583,7 +1583,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even } } - if (switch_strlen_zero(onoff)) { + if (zstr(onoff)) { switch_snprintf(reply, reply_len, "-ERR missing value."); goto done; } @@ -1623,7 +1623,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even } } - if (switch_strlen_zero(uuid)) { + if (zstr(uuid)) { uuid = switch_event_get_header(*event, "session-id"); } @@ -1631,7 +1631,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even uuid = NULL; } - if (switch_strlen_zero(uuid) && listener->session) { + if (zstr(uuid) && listener->session) { if (async) { if ((status = switch_core_session_queue_private_event(listener->session, event)) == SWITCH_STATUS_SUCCESS) { switch_snprintf(reply, reply_len, "+OK"); @@ -1643,7 +1643,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even switch_snprintf(reply, reply_len, "+OK"); } } else { - if (!switch_strlen_zero(uuid) && (session = switch_core_session_locate(uuid))) { + if (!zstr(uuid) && (session = switch_core_session_locate(uuid))) { if ((status = switch_core_session_queue_private_event(session, event)) == SWITCH_STATUS_SUCCESS) { switch_snprintf(reply, reply_len, "+OK"); } else { @@ -1789,12 +1789,12 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even level_s = cmd + 3; //see if we got an argument - if (!switch_strlen_zero(level_s)) { + if (!zstr(level_s)) { //if so move to the argument level_s++; } //see if we lined up on an argument or not - if (!switch_strlen_zero(level_s)) { + if (!zstr(level_s)) { ltype = switch_log_str2level(level_s); } @@ -1961,7 +1961,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even done: - if (switch_strlen_zero(reply)) { + if (zstr(reply)) { switch_snprintf(reply, reply_len, "-ERR command not found"); } @@ -2003,7 +2003,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) switch_socket_opt_set(listener->sock, SWITCH_SO_TCP_NODELAY, TRUE); switch_socket_opt_set(listener->sock, SWITCH_SO_NONBLOCK, TRUE); - if (prefs.acl_count && listener->sa && !switch_strlen_zero(listener->remote_ip)) { + if (prefs.acl_count && listener->sa && !zstr(listener->remote_ip)) { uint32_t x = 0; for (x = 0; x < prefs.acl_count; x++) { @@ -2024,7 +2024,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) } if (globals.debug > 0) { - if (switch_strlen_zero(listener->remote_ip)) { + if (zstr(listener->remote_ip)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Connection Open\n"); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Connection Open from %s:%d\n", listener->remote_ip, listener->remote_port); @@ -2243,11 +2243,11 @@ static int config(void) switch_xml_free(xml); } - if (switch_strlen_zero(prefs.ip)) { + if (zstr(prefs.ip)) { set_pref_ip("127.0.0.1"); } - if (switch_strlen_zero(prefs.password)) { + if (zstr(prefs.password)) { set_pref_pass("ClueCon"); } diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index 2c897b0278..b9a99901a4 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -608,7 +608,7 @@ SWITCH_STANDARD_API(stop_local_stream_function) int argc = 0; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -621,7 +621,7 @@ SWITCH_STANDARD_API(stop_local_stream_function) } local_stream_name = argv[0]; - if (switch_strlen_zero(local_stream_name)) { + if (zstr(local_stream_name)) { goto usage; } @@ -662,7 +662,7 @@ SWITCH_STANDARD_API(show_local_stream_function) switch_mutex_lock(globals.mutex); - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { for (hi = switch_hash_first(NULL, globals.source_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, &var, NULL, &val); if ((source = (local_stream_source_t *) val)) { @@ -751,7 +751,7 @@ SWITCH_STANDARD_API(start_local_stream_function) switch_xml_t cfg, xml, directory, param; int tmp; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -855,7 +855,7 @@ SWITCH_STANDARD_API(start_local_stream_function) switch_xml_free(xml); } - if (switch_strlen_zero(local_stream_name) || switch_strlen_zero(path)) { + if (zstr(local_stream_name) || zstr(path)) { goto usage; } diff --git a/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c b/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c index fb15ba976c..3285074c55 100644 --- a/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c +++ b/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c @@ -136,7 +136,7 @@ static int get_dev_by_name(char *name, int in) int match = 0; pdi = Pa_GetDeviceInfo(i); - if (switch_strlen_zero(name)) { + if (zstr(name)) { match = 1; } else if (pdi && pdi->name && strstr(pdi->name, name)) { match = 1; diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index 510210a820..6d1ba9fcf3 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -140,7 +140,7 @@ void Session::do_hangup_hook() lua_call(L, arg_count, 1); err = lua_tostring(L, -1); - if (!switch_strlen_zero(err)) { + if (!zstr(err)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err); } @@ -198,7 +198,7 @@ void Session::setHangupHook(char *func, char *arg) if (func) { hangup_func_str = strdup(func); - if (!switch_strlen_zero(arg)) { + if (!zstr(arg)) { hangup_func_arg = strdup(arg); } switch_channel_set_private(channel, "CoreSession", this); @@ -269,7 +269,7 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp lua_pushnumber(L, dtmf->duration); lua_rawset(L, -3); - if (!switch_strlen_zero(cb_arg)) { + if (!zstr(cb_arg)) { lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_arg); arg_count++; } @@ -293,7 +293,7 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp mod_lua_conjure_event(L, event, "__Input_Event__", 1); lua_getfield(L, LUA_GLOBALSINDEX, "__Input_Event__"); - if (!switch_strlen_zero(cb_arg)) { + if (!zstr(cb_arg)) { lua_getfield(L, LUA_GLOBALSINDEX, (char *) cb_arg); arg_count++; } diff --git a/src/mod/languages/mod_lua/mod_lua.cpp b/src/mod/languages/mod_lua/mod_lua.cpp index 4b3c5c1e18..daeacf79f5 100644 --- a/src/mod/languages/mod_lua/mod_lua.cpp +++ b/src/mod/languages/mod_lua/mod_lua.cpp @@ -121,7 +121,7 @@ static int lua_parse_and_execute(lua_State * L, char *input_code) { int error = 0; - if (switch_strlen_zero(input_code)) { + if (zstr(input_code)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No code to execute!\n"); return 1; } @@ -178,7 +178,7 @@ static int lua_parse_and_execute(lua_State * L, char *input_code) if (error) { const char *err = lua_tostring(L, -1); - if (!switch_strlen_zero(err)) { + if (!zstr(err)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err); } lua_pop(L, 1); /* pop error message from the stack */ @@ -216,7 +216,7 @@ static switch_xml_t lua_fetch(const char *section, switch_xml_t xml = NULL; - if (!switch_strlen_zero(globals.xml_handler)) { + if (!zstr(globals.xml_handler)) { lua_State *L = lua_init(); char *mycmd = strdup(globals.xml_handler); const char *str; @@ -253,7 +253,7 @@ static switch_xml_t lua_fetch(const char *section, str = lua_tostring(L, 1); if (str) { - if (switch_strlen_zero(str)) { + if (zstr(str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n"); } else if (!(xml = switch_xml_parse_str_dynamic((char *)str, SWITCH_TRUE))) { /* const char -> char conversion was OK because switch_xml_parse_str_dynamic makes a duplicate of str @@ -293,17 +293,17 @@ static switch_status_t do_config(void) if (!strcmp(var, "xml-handler-script")) { globals.xml_handler = switch_core_strdup(globals.pool, val); } else if (!strcmp(var, "xml-handler-bindings")) { - if (!switch_strlen_zero(globals.xml_handler)) { + if (!zstr(globals.xml_handler)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "binding '%s' to '%s'\n", globals.xml_handler, val); switch_xml_bind_search_function(lua_fetch, switch_xml_parse_section_string(val), NULL); } - } else if (!strcmp(var, "module-directory") && !switch_strlen_zero(val)) { + } else if (!strcmp(var, "module-directory") && !zstr(val)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "lua: appending module directory: '%s'\n", val); if (cpath_stream.data_len) { cpath_stream.write_function(&cpath_stream, ";"); } cpath_stream.write_function(&cpath_stream, "%s", val); - } else if (!strcmp(var, "script-directory") && !switch_strlen_zero(val)) { + } else if (!strcmp(var, "script-directory") && !zstr(val)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "lua: appending script directory: '%s'\n", val); if (path_stream.data_len) { path_stream.write_function(&path_stream, ";"); @@ -394,7 +394,7 @@ SWITCH_STANDARD_APP(lua_function) char *mycmd; int error; - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no args specified!\n"); return; } @@ -413,7 +413,7 @@ SWITCH_STANDARD_APP(lua_function) SWITCH_STANDARD_API(luarun_api_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR no args specified!\n"); } else { lua_thread(cmd); @@ -431,7 +431,7 @@ SWITCH_STANDARD_API(lua_api_function) char *mycmd; int error; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, ""); } else { diff --git a/src/mod/languages/mod_managed/mod_managed.cpp b/src/mod/languages/mod_managed/mod_managed.cpp index a74b8c9991..3062147025 100644 --- a/src/mod/languages/mod_managed/mod_managed.cpp +++ b/src/mod/languages/mod_managed/mod_managed.cpp @@ -371,7 +371,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load) #endif SWITCH_STANDARD_API(managedrun_api_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR no args specified!\n"); return SWITCH_STATUS_SUCCESS; } @@ -391,7 +391,7 @@ SWITCH_STANDARD_API(managedrun_api_function) SWITCH_STANDARD_API(managed_api_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR no args specified!\n"); return SWITCH_STATUS_SUCCESS; } @@ -409,7 +409,7 @@ SWITCH_STANDARD_API(managed_api_function) SWITCH_STANDARD_APP(managed_app_function) { - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No args specified!\n"); return; } @@ -426,7 +426,7 @@ SWITCH_STANDARD_APP(managed_app_function) SWITCH_STANDARD_API(managedreload_api_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR no args specified!\n"); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/languages/mod_perl/mod_perl.c b/src/mod/languages/mod_perl/mod_perl.c index 16bcaccea6..c7dbcbc1c5 100644 --- a/src/mod/languages/mod_perl/mod_perl.c +++ b/src/mod/languages/mod_perl/mod_perl.c @@ -64,7 +64,7 @@ static int Perl_safe_eval(PerlInterpreter * my_perl, const char *string) Perl_eval_pv(my_perl, string, FALSE); - if ((err = SvPV(get_sv("@", TRUE), n_a)) && !switch_strlen_zero(err)) { + if ((err = SvPV(get_sv("@", TRUE), n_a)) && !zstr(err)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[%s]\n%s\n", string, err); return -1; } @@ -77,7 +77,7 @@ static int perl_parse_and_execute(PerlInterpreter * my_perl, char *input_code, c { int error = 0; - if (switch_strlen_zero(input_code)) { + if (zstr(input_code)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No code to execute!\n"); return -1; } @@ -183,7 +183,7 @@ static perl_parse_and_execute(PerlInterpreter * my_perl, char *input_code, char } } - if ((err = SvPV(get_sv("@", TRUE), n_a)) && !switch_strlen_zero(err)) { + if ((err = SvPV(get_sv("@", TRUE), n_a)) && !zstr(err)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err); } @@ -304,7 +304,7 @@ int perl_thread(const char *text) SWITCH_STANDARD_API(perlrun_api_function) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR Missing args.\n"); return SWITCH_STATUS_SUCCESS; } @@ -319,7 +319,7 @@ SWITCH_STANDARD_API(perl_api_function) struct perl_o po = { 0 }; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "-ERR Missing args.\n"); return SWITCH_STATUS_SUCCESS; } @@ -338,7 +338,7 @@ static switch_xml_t perl_fetch(const char *section, int argc = 0; switch_xml_t xml = NULL; - if (!switch_strlen_zero(globals.xml_handler)) { + if (!zstr(globals.xml_handler)) { PerlInterpreter *my_perl = clone_perl(); HV *hash; char *str; @@ -360,7 +360,7 @@ static switch_xml_t perl_fetch(const char *section, abort(); } - if (switch_strlen_zero(section)) { + if (zstr(section)) { section = ""; } @@ -368,7 +368,7 @@ static switch_xml_t perl_fetch(const char *section, sv_setpv(this, section); hv_store(hash, "section", 7, this, 0); - if (switch_strlen_zero(tag_name)) { + if (zstr(tag_name)) { tag_name = ""; } @@ -376,7 +376,7 @@ static switch_xml_t perl_fetch(const char *section, sv_setpv(this, tag_name); hv_store(hash, "tag_name", 8, this, 0); - if (switch_strlen_zero(key_name)) { + if (zstr(key_name)) { key_name = ""; } @@ -384,7 +384,7 @@ static switch_xml_t perl_fetch(const char *section, sv_setpv(this, key_name); hv_store(hash, "key_name", 8, this, 0); - if (switch_strlen_zero(key_value)) { + if (zstr(key_value)) { key_value = ""; } @@ -414,8 +414,8 @@ static switch_xml_t perl_fetch(const char *section, perl_run(my_perl); str = SvPV(get_sv("XML_STRING", TRUE), n_a); - if (!switch_strlen_zero(str)) { - if (switch_strlen_zero(str)) { + if (!zstr(str)) { + if (zstr(str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n"); } else if (!(xml = switch_xml_parse_str(str, strlen(str)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing XML Result!\n"); @@ -446,7 +446,7 @@ static switch_status_t do_config(void) if (!strcmp(var, "xml-handler-script")) { globals.xml_handler = switch_core_strdup(globals.pool, val); } else if (!strcmp(var, "xml-handler-bindings")) { - if (!switch_strlen_zero(globals.xml_handler)) { + if (!zstr(globals.xml_handler)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "binding '%s' to '%s'\n", globals.xml_handler, var); switch_xml_bind_search_function(perl_fetch, switch_xml_parse_section_string(val), NULL); } diff --git a/src/mod/languages/mod_python/mod_python.c b/src/mod/languages/mod_python/mod_python.c index 2581d992f5..554ca70477 100644 --- a/src/mod/languages/mod_python/mod_python.c +++ b/src/mod/languages/mod_python/mod_python.c @@ -236,7 +236,7 @@ static switch_xml_t python_fetch(const char *section, switch_xml_t xml = NULL; char *str = NULL; - if (!switch_strlen_zero(globals.xml_handler)) { + if (!zstr(globals.xml_handler)) { char *mycmd = strdup(globals.xml_handler); switch_assert(mycmd); @@ -244,7 +244,7 @@ static switch_xml_t python_fetch(const char *section, eval_some_python("xml_fetch", mycmd, NULL, NULL, params, &str, NULL); if (str) { - if (switch_strlen_zero(str)) { + if (zstr(str)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n"); } else if (!(xml = switch_xml_parse_str((char *) str, strlen(str)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing XML Result!\n"); @@ -276,7 +276,7 @@ static switch_status_t do_config(void) if (!strcmp(var, "xml-handler-script")) { globals.xml_handler = switch_core_strdup(globals.pool, val); } else if (!strcmp(var, "xml-handler-bindings")) { - if (!switch_strlen_zero(globals.xml_handler)) { + if (!zstr(globals.xml_handler)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "binding '%s' to '%s'\n", globals.xml_handler, val); switch_xml_bind_search_function(python_fetch, switch_xml_parse_section_string(val), NULL); } @@ -397,7 +397,7 @@ int py_thread(const char *text) SWITCH_STANDARD_API(launch_python) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index ee02cfd7d4..7281e0f573 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -1015,7 +1015,7 @@ static switch_status_t load_modules(void) if ((mods = switch_xml_child(cfg, "modules"))) { for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) { const char *val = switch_xml_attr_soft(ld, "module"); - if (!switch_strlen_zero(val) && strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) { + if (!zstr(val) && strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val); continue; } @@ -1405,7 +1405,7 @@ static JSBool session_recordfile(JSContext * cx, JSObject * obj, uintN argc, jsv if (argc > 0) { file_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); - if (switch_strlen_zero(file_name)) { + if (zstr(file_name)) { return JS_FALSE; } } @@ -1542,7 +1542,7 @@ static JSBool session_sayphrase(JSContext * cx, JSObject * obj, uintN argc, jsva if (argc > 0) { phrase_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); - if (switch_strlen_zero(phrase_name)) { + if (zstr(phrase_name)) { return JS_FALSE; } } else { @@ -1555,7 +1555,7 @@ static JSBool session_sayphrase(JSContext * cx, JSObject * obj, uintN argc, jsva if (argc > 2) { tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[2])); - if (!switch_strlen_zero(tmp)) { + if (!zstr(tmp)) { phrase_lang = tmp; } } @@ -1609,7 +1609,7 @@ static jsval check_hangup_hook(struct js_session *jss, jsval *rp) } JS_CallFunction(jss->cx, jss->obj, jss->on_hangup, argc, argv, &ret); resp = JS_GetStringBytes(JS_ValueToString(jss->cx, ret)); - if (!switch_strlen_zero(resp)) { + if (!zstr(resp)) { ret = !strcasecmp(resp, "exit") ? JS_FALSE : JS_TRUE; } } @@ -1683,7 +1683,7 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv if (argc > 0) { file_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); - if (switch_strlen_zero(file_name)) { + if (zstr(file_name)) { return JS_FALSE; } } @@ -1927,12 +1927,12 @@ static JSBool session_speak(JSContext * cx, JSObject * obj, uintN argc, jsval * voice_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); text = JS_GetStringBytes(JS_ValueToString(cx, argv[2])); - if (switch_strlen_zero(tts_name)) { + if (zstr(tts_name)) { eval_some_js("~throw new Error(\"Invalid TTS Name\");", cx, obj, rval); return JS_FALSE; } - if (switch_strlen_zero(text)) { + if (zstr(text)) { eval_some_js("~throw new Error(\"Invalid Text\");", cx, obj, rval); return JS_FALSE; } @@ -2972,21 +2972,21 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva } - if (!switch_strlen_zero(jss->dialplan)) + if (!zstr(jss->dialplan)) dialplan = jss->dialplan; - if (!switch_strlen_zero(jss->caller_id_name)) + if (!zstr(jss->caller_id_name)) cid_name = jss->caller_id_name; - if (!switch_strlen_zero(jss->caller_id_number)) + if (!zstr(jss->caller_id_number)) cid_num = jss->caller_id_number; - if (!switch_strlen_zero(jss->ani)) + if (!zstr(jss->ani)) ani = jss->ani; - if (!switch_strlen_zero(jss->aniii)) + if (!zstr(jss->aniii)) aniii = jss->aniii; - if (!switch_strlen_zero(jss->rdnis)) + if (!zstr(jss->rdnis)) rdnis = jss->rdnis; - if (!switch_strlen_zero(jss->context)) + if (!zstr(jss->context)) context = jss->context; - if (!switch_strlen_zero(jss->username)) + if (!zstr(jss->username)) username = jss->username; dest = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); @@ -2998,7 +2998,7 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva if (argc > 2) { tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[2])); - if (!switch_strlen_zero(tmp)) { + if (!zstr(tmp)) { to = tmp; } } @@ -3678,7 +3678,7 @@ static void js_thread_launch(const char *text) struct js_task *task; switch_memory_pool_t *pool; - if (switch_strlen_zero(text)) { + if (zstr(text)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "missing required input!\n"); return; } @@ -3707,11 +3707,11 @@ SWITCH_STANDARD_API(jsapi_function) path_info = switch_event_get_header(stream->param_event, "http-path-info"); } - if (switch_strlen_zero(cmd) && path_info) { + if (zstr(cmd) && path_info) { cmd = path_info; } - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "USAGE: %s\n", jsapi_interface->syntax); return SWITCH_STATUS_SUCCESS; } @@ -3727,7 +3727,7 @@ SWITCH_STANDARD_API(jsapi_function) SWITCH_STANDARD_API(launch_async) { - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "USAGE: %s\n", js_run_interface->syntax); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c b/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c index 1cb8cbc828..6e9710ea71 100644 --- a/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c +++ b/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c @@ -144,7 +144,7 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, if (argc > 5) { cred = JS_GetStringBytes(JS_ValueToString(cx, argv[5])); - if (!switch_strlen_zero(cred)) { + if (!zstr(cred)) { curl_easy_setopt(co->curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(co->curl_handle, CURLOPT_USERPWD, cred); } @@ -174,7 +174,7 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, data = ""; } curl_easy_setopt(co->curl_handle, CURLOPT_POSTFIELDS, data); - } else if (!switch_strlen_zero(data)) { + } else if (!zstr(data)) { durl = switch_mprintf("%s?%s", url, data); url_p = durl; } diff --git a/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c b/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c index 8ca2f479b2..2a2b990f77 100644 --- a/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c +++ b/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c @@ -128,11 +128,11 @@ static JSBool odbc_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * } } - if (switch_strlen_zero(username)) { + if (zstr(username)) { username = NULL; } - if (switch_strlen_zero(password)) { + if (zstr(password)) { password = NULL; } diff --git a/src/mod/languages/mod_yaml/mod_yaml.c b/src/mod/languages/mod_yaml/mod_yaml.c index c8a99dea38..2c2068c66c 100644 --- a/src/mod/languages/mod_yaml/mod_yaml.c +++ b/src/mod/languages/mod_yaml/mod_yaml.c @@ -404,7 +404,7 @@ SWITCH_STANDARD_DIALPLAN(yaml_dialplan_hunt) char *path = NULL; FILE *input; - if (!switch_strlen_zero(alt_path)) { + if (!zstr(alt_path)) { path = strdup(alt_path); } else { path = switch_mprintf("%s/yaml/extensions.yaml", SWITCH_GLOBAL_dirs.conf_dir); diff --git a/src/mod/loggers/mod_console/mod_console.c b/src/mod/loggers/mod_console/mod_console.c index 63d3f9487d..296d8a8639 100644 --- a/src/mod/loggers/mod_console/mod_console.c +++ b/src/mod/loggers/mod_console/mod_console.c @@ -130,7 +130,7 @@ static switch_status_t config_logger(void) #else COLORIZE = 1; #endif - } else if (!strcasecmp(var, "loglevel") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { hard_log_level = switch_log_str2level(val); } } @@ -289,7 +289,7 @@ SWITCH_STANDARD_API(console_api_function) if (session) return SWITCH_STATUS_FALSE; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { stream->write_function(stream, "%s", usage_string); goto done; } diff --git a/src/mod/loggers/mod_logfile/mod_logfile.c b/src/mod/loggers/mod_logfile/mod_logfile.c index 4fbe8873e7..e859553061 100644 --- a/src/mod/loggers/mod_logfile/mod_logfile.c +++ b/src/mod/loggers/mod_logfile/mod_logfile.c @@ -277,7 +277,7 @@ static switch_status_t load_profile(switch_xml_t xml) } } - if (switch_strlen_zero(new_profile->logfile)) { + if (zstr(new_profile->logfile)) { char logfile[512]; switch_snprintf(logfile, sizeof(logfile), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, "freeswitch.log"); new_profile->logfile = strdup(logfile); diff --git a/src/mod/loggers/mod_syslog/mod_syslog.c b/src/mod/loggers/mod_syslog/mod_syslog.c index 2cccebd975..44ca4c61d2 100644 --- a/src/mod/loggers/mod_syslog/mod_syslog.c +++ b/src/mod/loggers/mod_syslog/mod_syslog.c @@ -101,7 +101,7 @@ static switch_status_t mod_syslog_logger(const switch_log_node_t *node, switch_l } /* don't log blank lines */ - if (!switch_strlen_zero(node->data) && (strspn(node->data, " \t\r\n") < strlen(node->data))) { + if (!zstr(node->data) && (strspn(node->data, " \t\r\n") < strlen(node->data))) { syslog(syslog_level, "%s", node->data); } @@ -130,7 +130,7 @@ static switch_status_t load_config(void) set_global_format(val); } else if (!strcmp(var, "facility")) { set_global_facility(val); - } else if (!strcasecmp(var, "loglevel") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { log_level = switch_log_str2level(val); if (log_level == SWITCH_LOG_INVALID) { log_level = SWITCH_LOG_WARNING; @@ -142,13 +142,13 @@ static switch_status_t load_config(void) switch_xml_free(xml); } - if (switch_strlen_zero(globals.ident)) { + if (zstr(globals.ident)) { set_global_ident(DEFAULT_IDENT); } - if (switch_strlen_zero(globals.format)) { + if (zstr(globals.format)) { set_global_format(DEFAULT_FORMAT); } - if (switch_strlen_zero(globals.facility)) { + if (zstr(globals.facility)) { set_global_facility(DEFAULT_FACILITY); } return 0; diff --git a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c index 5a1c1e53d2..462b6d4a66 100644 --- a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c +++ b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c @@ -89,7 +89,7 @@ static switch_status_t set_xml_cdr_log_dirs() switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Rotating log file paths\n"); - if (!switch_strlen_zero(globals.base_log_dir)) { + if (!zstr(globals.base_log_dir)) { if (globals.rotate) { if ((path = switch_mprintf("%s%s%s", globals.base_log_dir, SWITCH_PATH_SEPARATOR, date))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Rotating log file path to %s\n", path); @@ -131,7 +131,7 @@ static switch_status_t set_xml_cdr_log_dirs() } } - if (!switch_strlen_zero(globals.base_err_log_dir)) { + if (!zstr(globals.base_err_log_dir)) { if (globals.rotate) { if ((path = switch_mprintf("%s%s%s", globals.base_err_log_dir, SWITCH_PATH_SEPARATOR, date))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Rotating err log file path to %s\n", path); @@ -223,7 +223,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) logdir = globals.log_dir; } - if (!switch_strlen_zero(logdir)) { + if (!zstr(logdir)) { path = switch_mprintf("%s%s%s%s.cdr.xml", logdir, SWITCH_PATH_SEPARATOR, a_prefix, switch_core_session_get_uuid(session)); switch_thread_rwlock_unlock(globals.log_path_lock); if (path) { @@ -280,7 +280,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) goto error; } - if (!switch_strlen_zero(globals.cred)) { + if (!zstr(globals.cred)) { curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, globals.cred); } @@ -474,15 +474,15 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load) char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); - if (!strcasecmp(var, "cred") && !switch_strlen_zero(val)) { + if (!strcasecmp(var, "cred") && !zstr(val)) { globals.cred = switch_core_strdup(globals.pool, val); - } else if (!strcasecmp(var, "url") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "url") && !zstr(val)) { if (globals.url_count >= MAX_URLS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "maximum urls configured!\n"); } else { globals.urls[globals.url_count++] = switch_core_strdup(globals.pool, val); } - } else if (!strcasecmp(var, "delay") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "delay") && !zstr(val)) { globals.delay = (uint32_t) atoi(val); } else if (!strcasecmp(var, "log-b-leg")) { globals.log_b = switch_true(val); @@ -490,18 +490,18 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load) globals.prefix_a = switch_true(val); } else if (!strcasecmp(var, "disable-100-continue") && switch_true(val)) { globals.disable100continue = 1; - } else if (!strcasecmp(var, "encode") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "encode") && !zstr(val)) { if (!strcasecmp(val, "base64")) { globals.encode = 2; } else { globals.encode = switch_true(val) ? 1 : 0; } - } else if (!strcasecmp(var, "retries") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "retries") && !zstr(val)) { globals.retries = (uint32_t) atoi(val); - } else if (!strcasecmp(var, "rotate") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "rotate") && !zstr(val)) { globals.rotate = switch_true(val); } else if (!strcasecmp(var, "log-dir")) { - if (switch_strlen_zero(val)) { + if (zstr(val)) { globals.base_log_dir = switch_mprintf("%s%sxml_cdr", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR); } else { if (switch_is_file_path(val)) { @@ -511,7 +511,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load) } } } else if (!strcasecmp(var, "err-log-dir")) { - if (switch_strlen_zero(val)) { + if (zstr(val)) { globals.base_err_log_dir = switch_mprintf("%s%sxml_cdr", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR); } else { if (switch_is_file_path(val)) { @@ -536,8 +536,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load) globals.enable_ssl_verifyhost = 1; } - if (switch_strlen_zero(globals.base_err_log_dir)) { - if (!switch_strlen_zero(globals.base_log_dir)) { + if (zstr(globals.base_err_log_dir)) { + if (!zstr(globals.base_log_dir)) { globals.base_err_log_dir = switch_core_strdup(globals.pool, globals.base_log_dir); } else { globals.base_err_log_dir = switch_core_sprintf(globals.pool, "%s%sxml_cdr", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR); diff --git a/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c b/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c index 9e89d4b94c..3dfbe8d6de 100644 --- a/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c +++ b/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c @@ -90,7 +90,7 @@ SWITCH_STANDARD_API(xml_curl_function) return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -217,7 +217,7 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con config_data.max_bytes = XML_CURL_MAX_BYTES; if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) { - if (!switch_strlen_zero(binding->cred)) { + if (!zstr(binding->cred)) { curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, binding->auth_scheme); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, binding->cred); } @@ -508,7 +508,7 @@ static switch_status_t do_config(void) } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n", - switch_strlen_zero(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all"); + zstr(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all"); switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings), binding); x++; binding = NULL; diff --git a/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c b/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c index 1420497528..85ff8e204a 100644 --- a/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c +++ b/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c @@ -93,7 +93,7 @@ SWITCH_STANDARD_API(xml_ldap_function) return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { goto usage; } @@ -466,7 +466,7 @@ static switch_status_t do_config(void) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] (%s) [%s]\n", - switch_strlen_zero(bname) ? "N/A" : bname, binding->basedn, binding->filter, binding->bindings ? binding->bindings : "all"); + zstr(bname) ? "N/A" : bname, binding->basedn, binding->filter, binding->bindings ? binding->bindings : "all"); switch_xml_bind_search_function(xml_ldap_search, switch_xml_parse_section_string(bname), binding); diff --git a/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c b/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c index b597442fa8..429dafc600 100644 --- a/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c +++ b/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c @@ -257,7 +257,7 @@ static switch_status_t do_config(void) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] (%s) [%s]\n", - switch_strlen_zero(bname) ? "N/A" : bname, binding->basedn, binding->filter, binding->bindings ? binding->bindings : "all"); + zstr(bname) ? "N/A" : bname, binding->basedn, binding->filter, binding->bindings ? binding->bindings : "all"); switch_xml_bind_search_function(xml_ldap_search, switch_xml_parse_section_string(bname), binding); diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index 6337e775d1..92667bf3d1 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -257,7 +257,7 @@ static abyss_bool is_authorized (const TSession *r, const char *command) return FALSE; } - if (switch_strlen_zero(globals.realm) && switch_strlen_zero(globals.user)) { + if (zstr(globals.realm) && zstr(globals.user)) { return TRUE; } @@ -272,12 +272,12 @@ static abyss_bool is_authorized (const TSession *r, const char *command) domain_name = dp; } - if (!switch_strlen_zero(globals.realm) && !switch_strlen_zero(globals.user) && !strcmp(user, globals.user)) { + if (!zstr(globals.realm) && !zstr(globals.user) && !strcmp(user, globals.user)) { switch_safe_free(user); return TRUE; } - if (switch_strlen_zero(user) || switch_strlen_zero(domain_name)) { + if (zstr(user) || zstr(domain_name)) { switch_safe_free(user); return FALSE; } @@ -352,11 +352,11 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name) } } - if (switch_strlen_zero(user) || switch_strlen_zero(domain_name)) { + if (zstr(user) || zstr(domain_name)) { goto fail; } - if (!switch_strlen_zero(globals.realm) && !switch_strlen_zero(globals.user) && !switch_strlen_zero(globals.pass)) { + if (!zstr(globals.realm) && !zstr(globals.user) && !zstr(globals.pass)) { if (at) { switch_snprintf(z, sizeof(z), "%s@%s:%s", globals.user, globals.realm, globals.pass); } else { @@ -374,7 +374,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name) } - if (!switch_strlen_zero(mypass2) && !strcasecmp(mypass2, "user-choose")) { + if (!zstr(mypass2) && !strcasecmp(mypass2, "user-choose")) { mypass2 = NULL; } @@ -872,7 +872,7 @@ static xmlrpc_value *freeswitch_man(xmlrpc_env * const envP, xmlrpc_value * cons relative_oid = oid; } - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { switch_copy_string(buf, data, sizeof(buf)); } diff --git a/src/switch_caller.c b/src/switch_caller.c index 8b56299d31..2ea7dcc4b5 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -33,8 +33,8 @@ #include #include -#define profile_dup(a,b,p) if (!switch_strlen_zero(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; } -#define profile_dup_clean(a,b,p) if (!switch_strlen_zero(a)) { b = switch_var_clean_string(switch_clean_string(switch_core_strdup(p, a)));} else { b = SWITCH_BLANK_STRING; } +#define profile_dup(a,b,p) if (!zstr(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; } +#define profile_dup_clean(a,b,p) if (!zstr(a)) { b = switch_var_clean_string(switch_clean_string(switch_core_strdup(p, a)));} else { b = SWITCH_BLANK_STRING; } SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memory_pool_t *pool, const char *username, @@ -57,11 +57,11 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor context = "default"; } - if (switch_strlen_zero(caller_id_name)) { + if (zstr(caller_id_name)) { caller_id_name = "FreeSWITCH"; } - if (switch_strlen_zero(caller_id_number)) { + if (zstr(caller_id_number)) { caller_id_number = "0000000000"; } @@ -247,59 +247,59 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_ { char header_name[1024]; - if (!switch_strlen_zero(caller_profile->username)) { + if (!zstr(caller_profile->username)) { switch_snprintf(header_name, sizeof(header_name), "%s-Username", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->username); } - if (!switch_strlen_zero(caller_profile->dialplan)) { + if (!zstr(caller_profile->dialplan)) { switch_snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->dialplan); } - if (!switch_strlen_zero(caller_profile->caller_id_name)) { + if (!zstr(caller_profile->caller_id_name)) { switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Name", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_name); } - if (!switch_strlen_zero(caller_profile->caller_id_number)) { + if (!zstr(caller_profile->caller_id_number)) { switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number); } - if (!switch_strlen_zero(caller_profile->network_addr)) { + if (!zstr(caller_profile->network_addr)) { switch_snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->network_addr); } - if (!switch_strlen_zero(caller_profile->ani)) { + if (!zstr(caller_profile->ani)) { switch_snprintf(header_name, sizeof(header_name), "%s-ANI", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->ani); } - if (!switch_strlen_zero(caller_profile->aniii)) { + if (!zstr(caller_profile->aniii)) { switch_snprintf(header_name, sizeof(header_name), "%s-ANI-II", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->aniii); } - if (!switch_strlen_zero(caller_profile->destination_number)) { + if (!zstr(caller_profile->destination_number)) { switch_snprintf(header_name, sizeof(header_name), "%s-Destination-Number", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->destination_number); } - if (!switch_strlen_zero(caller_profile->uuid)) { + if (!zstr(caller_profile->uuid)) { switch_snprintf(header_name, sizeof(header_name), "%s-Unique-ID", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->uuid); } - if (!switch_strlen_zero(caller_profile->source)) { + if (!zstr(caller_profile->source)) { switch_snprintf(header_name, sizeof(header_name), "%s-Source", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->source); } - if (!switch_strlen_zero(caller_profile->context)) { + if (!zstr(caller_profile->context)) { switch_snprintf(header_name, sizeof(header_name), "%s-Context", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->context); } - if (!switch_strlen_zero(caller_profile->rdnis)) { + if (!zstr(caller_profile->rdnis)) { switch_snprintf(header_name, sizeof(header_name), "%s-RDNIS", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->rdnis); } - if (!switch_strlen_zero(caller_profile->chan_name)) { + if (!zstr(caller_profile->chan_name)) { switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->chan_name); } - if (!switch_strlen_zero(caller_profile->profile_index)) { + if (!zstr(caller_profile->profile_index)) { switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->profile_index); } diff --git a/src/switch_channel.c b/src/switch_channel.c index 9f07185404..eb8e07b48f 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -317,7 +317,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_ int i, argc; char *argv[256]; - if (switch_strlen_zero(dtmf_string)) { + if (zstr(dtmf_string)) { return SWITCH_STATUS_FALSE; } @@ -536,7 +536,7 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_ const char *val = NULL, *r = NULL; switch_assert(channel != NULL); - if (!switch_strlen_zero(varname)) { + if (!zstr(varname)) { if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { switch_core_session_t *session; if ((session = switch_core_session_locate(uuid))) { @@ -599,7 +599,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channe const char *old = NULL; switch_assert(channel != NULL); - if (!switch_strlen_zero(channel->name)) { + if (!zstr(channel->name)) { old = channel->name; } channel->name = NULL; @@ -619,7 +619,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channe SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel) { switch_assert(channel != NULL); - return (!switch_strlen_zero(channel->name)) ? channel->name : "N/A"; + return (!zstr(channel->name)) ? channel->name : "N/A"; } SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val) @@ -629,7 +629,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t switch_mutex_lock(channel->profile_mutex); - if (!switch_strlen_zero(val)) { + if (!zstr(val)) { v = switch_core_strdup(channel->caller_profile->pool, val); } else { v = SWITCH_BLANK_STRING; @@ -689,9 +689,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_cha switch_assert(channel != NULL); switch_mutex_lock(channel->profile_mutex); - if (channel->variables && !switch_strlen_zero(varname)) { + if (channel->variables && !zstr(varname)) { switch_event_del_header(channel->variables, varname); - if (!switch_strlen_zero(value)) { + if (!zstr(value)) { int ok = 1; if (var_check) { @@ -722,7 +722,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channe switch_assert(channel != NULL); switch_mutex_lock(channel->profile_mutex); - if (channel->variables && !switch_strlen_zero(varname)) { + if (channel->variables && !zstr(varname)) { switch_event_del_header(channel->variables, varname); va_start(ap, fmt); @@ -750,7 +750,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(sw const char *uuid; switch_assert(channel != NULL); - if (!switch_strlen_zero(varname)) { + if (!zstr(varname)) { if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { switch_core_session_t *session; if ((session = switch_core_session_locate(uuid))) { @@ -2126,7 +2126,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ANSWER"); switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name); - if ((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE)) && !switch_strlen_zero(var)) { + if ((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE)) && !zstr(var)) { char *arg = NULL; app = switch_core_session_strdup(channel->session, var); @@ -2143,7 +2143,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan } } - if ((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE)) && !switch_strlen_zero(var)) { + if ((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE)) && !zstr(var)) { switch_stream_handle_t stream = { 0 }; char *arg = NULL; @@ -2214,7 +2214,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel char *func_val = NULL; int nv = 0; - if (switch_strlen_zero(in)) { + if (zstr(in)) { return (char *) in; } @@ -2495,7 +2495,7 @@ SWITCH_DECLARE(char *) switch_channel_build_param_string(switch_channel_t *chann prof_names[10] = "uuid"; for (x = 0; prof[x]; x++) { - if (switch_strlen_zero(prof[x])) { + if (zstr(prof[x])) { continue; } new_len = (strlen(prof[x]) * 3) + 1; @@ -2558,12 +2558,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t * switch_mutex_lock(channel->profile_mutex); switch_mutex_lock(other_channel->profile_mutex); - if (!switch_strlen_zero(channel->caller_profile->callee_id_name)) { + if (!zstr(channel->caller_profile->callee_id_name)) { other_channel->caller_profile->callee_id_name = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_name); x++; } - if (!switch_strlen_zero(channel->caller_profile->callee_id_number)) { + if (!zstr(channel->caller_profile->callee_id_number)) { other_channel->caller_profile->callee_id_number = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_number); x++; } @@ -2621,7 +2621,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t * ocp = switch_channel_get_originator_caller_profile(channel); } - if (!switch_strlen_zero(caller_profile->caller_id_name)) { + if (!zstr(caller_profile->caller_id_name)) { cid_buf = switch_core_session_sprintf(channel->session, "\"%s\" <%s>", caller_profile->caller_id_name, switch_str_nil(caller_profile->caller_id_number)); } else { diff --git a/src/switch_console.c b/src/switch_console.c index c230b70c0e..375965b65e 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -464,7 +464,7 @@ static void *SWITCH_THREAD_FUNC console_thread(switch_thread_t *thread, void *ob line = el_gets(el, &count); if (count > 1) { - if (!switch_strlen_zero(line)) { + if (!zstr(line)) { char *cmd = strdup(line); char *p; const LineInfo *lf = el_line(el); @@ -513,7 +513,7 @@ static int comp_callback(void *pArg, int argc, char **argv, char **columnNames) switch_copy_string(h->last, target, sizeof(h->last)); - if (!switch_strlen_zero(target)) { + if (!zstr(target)) { if ((++h->hits % 4) == 0) { fprintf(h->out, "\n"); } diff --git a/src/switch_core.c b/src/switch_core.c index cd90384443..c7eafba552 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -957,7 +957,7 @@ SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload) const char *dft = switch_xml_attr(x_list, "default"); switch_bool_t default_type = SWITCH_TRUE; - if (switch_strlen_zero(name)) { + if (zstr(name)) { continue; } @@ -1393,34 +1393,34 @@ static void switch_load_core_config(const char *file) #endif } else if (!strcasecmp(var, "colorize-console") && switch_true(val)) { runtime.colorize_console = SWITCH_TRUE; - } else if (!strcasecmp(var, "mailer-app") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "mailer-app") && !zstr(val)) { runtime.mailer_app = switch_core_strdup(runtime.memory_pool, val); } else if (!strcasecmp(var, "mailer-app-args") && val) { runtime.mailer_app_args = switch_core_strdup(runtime.memory_pool, val); - } else if (!strcasecmp(var, "sessions-per-second") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "sessions-per-second") && !zstr(val)) { switch_core_sessions_per_second(atoi(val)); - } else if (!strcasecmp(var, "max_dtmf_duration") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "max_dtmf_duration") && !zstr(val)) { int tmp = atoi(val); if (tmp > 0) { switch_core_max_dtmf_duration((uint32_t) tmp); } - } else if (!strcasecmp(var, "min_dtmf_duration") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "min_dtmf_duration") && !zstr(val)) { int tmp = atoi(val); if (tmp > 0) { switch_core_min_dtmf_duration((uint32_t) tmp); } - } else if (!strcasecmp(var, "default_dtmf_duration") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "default_dtmf_duration") && !zstr(val)) { int tmp = atoi(val); if (tmp > 0) { switch_core_default_dtmf_duration((uint32_t) tmp); } } else if (!strcasecmp(var, "disable-monotonic-timing")) { switch_time_set_monotonic(SWITCH_FALSE); - } else if (!strcasecmp(var, "max-sessions") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "max-sessions") && !zstr(val)) { switch_core_session_limit(atoi(val)); - } else if (!strcasecmp(var, "rtp-start-port") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "rtp-start-port") && !zstr(val)) { switch_rtp_set_start_port((switch_port_t) atoi(val)); - } else if (!strcasecmp(var, "rtp-end-port") && !switch_strlen_zero(val)) { + } else if (!strcasecmp(var, "rtp-end-port") && !zstr(val)) { switch_rtp_set_end_port((switch_port_t) atoi(val)); #ifdef ENABLE_ZRTP } else if (!strcasecmp(var, "rtp-enable-zrtp")) { diff --git a/src/switch_core_asr.c b/src/switch_core_asr.c index 75e0ba1e68..f68c502519 100644 --- a/src/switch_core_asr.c +++ b/src/switch_core_asr.c @@ -96,7 +96,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_load_grammar(switch_asr_handle_t switch_assert(ah != NULL); - if (switch_strlen_zero(grammar)) { + if (zstr(grammar)) { status = SWITCH_STATUS_FALSE; goto done; } @@ -111,7 +111,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_load_grammar(switch_asr_handle_t while (data && *data == ' ') { data++; } - if (switch_strlen_zero(data)) { + if (zstr(data)) { status = SWITCH_STATUS_FALSE; goto done; } @@ -120,7 +120,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_load_grammar(switch_asr_handle_t if (*data == '{') { param_string = data + 1; data = switch_find_end_paren(data, '{', '}'); - if (switch_strlen_zero(data)) { + if (zstr(data)) { status = SWITCH_STATUS_FALSE; goto done; } else { @@ -130,7 +130,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_load_grammar(switch_asr_handle_t } /* set ASR params */ - if (!switch_strlen_zero(param_string)) { + if (!zstr(param_string)) { char *param[256] = { 0 }; int i; int argc = switch_separate_string(param_string, ',', param, (sizeof(param) / sizeof(param[0]))); diff --git a/src/switch_core_file.c b/src/switch_core_file.c index b8e86e31ba..a83615367f 100644 --- a/src/switch_core_file.c +++ b/src/switch_core_file.c @@ -53,7 +53,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(file_path)) { + if (zstr(file_path)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Filename\n"); return SWITCH_STATUS_FALSE; } diff --git a/src/switch_core_io.c b/src/switch_core_io.c index fead8ab27c..e2d002b0ec 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -1182,7 +1182,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core return SWITCH_STATUS_FALSE; } - if (switch_strlen_zero(dtmf_string)) { + if (zstr(dtmf_string)) { return SWITCH_STATUS_FALSE; } diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c index a255469a8d..474645e505 100644 --- a/src/switch_core_memory.c +++ b/src/switch_core_memory.c @@ -139,7 +139,7 @@ SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(const char *todup, c return NULL; } - if (switch_strlen_zero(todup)) { + if (zstr(todup)) { return SWITCH_BLANK_STRING; } @@ -235,7 +235,7 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t return NULL; } - if (switch_strlen_zero(todup)) { + if (zstr(todup)) { return SWITCH_BLANK_STRING; } @@ -275,7 +275,7 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co return NULL; } - if (switch_strlen_zero(todup)) { + if (zstr(todup)) { return SWITCH_BLANK_STRING; } diff --git a/src/switch_core_session.c b/src/switch_core_session.c index f99287c67b..23c404eecc 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -373,7 +373,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_ switch_assert(channel != NULL); forwardvar = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE); - if (!switch_strlen_zero(forwardvar)) { + if (!zstr(forwardvar)) { forwardval = atoi(forwardvar) - 1; } if (forwardval <= 0) { @@ -1494,7 +1494,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t * char *myarg = NULL; if (expanded) { myarg = switch_mprintf("%s(%s)", app, expanded); - } else if (!switch_strlen_zero(arg)) { + } else if (!zstr(arg)) { myarg = switch_mprintf("%s(%s)", app, arg); } else { myarg = switch_mprintf("%s", app); @@ -1583,11 +1583,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_se new_profile = switch_caller_profile_clone(session, profile); new_profile->destination_number = switch_core_strdup(new_profile->pool, exten); - if (!switch_strlen_zero(dialplan)) { + if (!zstr(dialplan)) { new_profile->dialplan = switch_core_strdup(new_profile->pool, dialplan); } - if (!switch_strlen_zero(context)) { + if (!zstr(context)) { new_profile->context = switch_core_strdup(new_profile->pool, context); } diff --git a/src/switch_core_speech.c b/src/switch_core_speech.c index 0f28b623e6..1575adf9bf 100644 --- a/src/switch_core_speech.c +++ b/src/switch_core_speech.c @@ -45,7 +45,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t * char buf[256] = ""; char *param = NULL; - if (!sh || !flags || switch_strlen_zero(module_name)) { + if (!sh || !flags || zstr(module_name)) { return SWITCH_STATUS_FALSE; } @@ -102,7 +102,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle switch_assert(sh != NULL); - if (switch_strlen_zero(text)) { + if (zstr(text)) { status = SWITCH_STATUS_FALSE; goto done; } @@ -117,7 +117,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle while (data && *data == ' ') { data++; } - if (switch_strlen_zero(data)) { + if (zstr(data)) { status = SWITCH_STATUS_FALSE; goto done; } @@ -126,7 +126,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle if (*data == '{') { param_string = data + 1; data = switch_find_end_paren(data, '{', '}'); - if (switch_strlen_zero(data)) { + if (zstr(data)) { status = SWITCH_STATUS_FALSE; goto done; } else { @@ -136,7 +136,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle } /* set TTS params */ - if (!switch_strlen_zero(param_string)) { + if (!zstr(param_string)) { char *param[256] = { 0 }; int i; int argc = switch_separate_string(param_string, ',', param, (sizeof(param) / sizeof(param[0]))); diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index a2d5dc36fd..b6fb502097 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -316,7 +316,7 @@ static void core_event_handler(switch_event_t *event) char *state = switch_event_get_header_nil(event, "channel-state-number"); switch_channel_state_t state_i = CS_DESTROY; - if (!switch_strlen_zero(state)) { + if (!zstr(state)) { state_i = atoi(state); } @@ -375,7 +375,7 @@ static void core_event_handler(switch_event_t *event) const char *syntax = switch_event_get_header_nil(event, "syntax"); const char *key = switch_event_get_header_nil(event, "key"); const char *filename = switch_event_get_header_nil(event, "filename"); - if (!switch_strlen_zero(type) && !switch_strlen_zero(name)) { + if (!zstr(type) && !zstr(name)) { sql = switch_mprintf("insert into interfaces (type,name,description,syntax,key,filename) values('%q','%q','%q','%q','%q','%q')", type, name, switch_str_nil(description), switch_str_nil(syntax), switch_str_nil(key), switch_str_nil(filename) @@ -387,7 +387,7 @@ static void core_event_handler(switch_event_t *event) { const char *type = switch_event_get_header_nil(event, "type"); const char *name = switch_event_get_header_nil(event, "name"); - if (!switch_strlen_zero(type) && !switch_strlen_zero(name)) { + if (!zstr(type) && !zstr(name)) { sql = switch_mprintf("delete from interfaces where type='%q' and name='%q'", type, name); } break; @@ -396,7 +396,7 @@ static void core_event_handler(switch_event_t *event) { const char *type = switch_event_get_header_nil(event, "secure_type"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Secure Type: %s\n", type); - if (switch_strlen_zero(type)) { + if (zstr(type)) { break; } sql = switch_mprintf("update channels set secure='%s' where uuid='%s'", diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index b33353e48a..7a78d4a9c2 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -85,7 +85,7 @@ static void switch_core_standard_on_routing(switch_core_session_t *session) char *dp[25]; int argc, x, count = 0; - if (!switch_strlen_zero(caller_profile->dialplan)) { + if (!zstr(caller_profile->dialplan)) { if ((dpstr = switch_core_session_strdup(session, caller_profile->dialplan))) { expanded = switch_channel_expand_variables(session->channel, dpstr); argc = switch_separate_string(expanded, ',', dp, (sizeof(dp) / sizeof(dp[0]))); @@ -482,7 +482,7 @@ SWITCH_DECLARE(void) switch_core_session_hangup_state(switch_core_session_t *ses use_session = session; } - if (!switch_strlen_zero(hook_var)) { + if (!zstr(hook_var)) { switch_stream_handle_t stream = { 0 }; char *cmd = switch_core_session_strdup(session, hook_var); char *arg = NULL; @@ -552,7 +552,7 @@ SWITCH_DECLARE(void) switch_core_session_reporting_state(switch_core_session_t * driver_state_handler = endpoint_interface->state_handler; switch_assert(driver_state_handler != NULL); - if (!switch_strlen_zero(var)) { + if (!zstr(var)) { if (!strcasecmp(var, "a_only")) { if (switch_channel_get_originator_caller_profile(session->channel)) { do_extra_handlers = 0; diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 9f9590f3a2..094513dac8 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -55,7 +55,7 @@ SWITCH_DECLARE_CONSTRUCTOR EventConsumer::EventConsumer(const char *event_name, switch_name_event(event_name, &e_event_id); switch_core_new_memory_pool(&pool); - if (!switch_strlen_zero(subclass_name)) { + if (!zstr(subclass_name)) { e_subclass_name = switch_core_strdup(pool, subclass_name); } else { e_subclass_name = NULL; @@ -124,7 +124,7 @@ SWITCH_DECLARE_CONSTRUCTOR IVRMenu::IVRMenu(IVRMenu *main, menu = NULL; switch_core_new_memory_pool(&pool); switch_assert(pool); - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = "no name"; } @@ -227,7 +227,7 @@ SWITCH_DECLARE_CONSTRUCTOR Event::Event(const char *type, const char *subclass_n event_id = SWITCH_EVENT_MESSAGE; } - if (!switch_strlen_zero(subclass_name) && event_id != SWITCH_EVENT_CUSTOM) { + if (!zstr(subclass_name) && event_id != SWITCH_EVENT_CUSTOM) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_WARNING, "Changing event type to custom because you specified a subclass name!\n"); event_id = SWITCH_EVENT_CUSTOM; } @@ -1204,7 +1204,7 @@ SWITCH_DECLARE(switch_status_t) CoreSession::process_callback_result(char *resul this_check(SWITCH_STATUS_FALSE); sanity_check(SWITCH_STATUS_FALSE); - if (switch_strlen_zero(result)) { + if (zstr(result)) { return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_event.c b/src/switch_event.c index 54574b4575..6bc918816c 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -1071,7 +1071,7 @@ SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const ch } } - if (!switch_strlen_zero(data)) { + if (!zstr(data)) { body = data; } else if (event->body) { body = event->body; @@ -1606,7 +1606,7 @@ SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, co for (x = 0; prof[x]; x++) { - if (switch_strlen_zero(prof[x])) { + if (zstr(prof[x])) { continue; } new_len = (strlen(prof[x]) * 3) + 1; diff --git a/src/switch_ivr.c b/src/switch_ivr.c index bd170a88e9..6236ee12cf 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -463,7 +463,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se char *event_lock = switch_event_get_header(event, "event-lock"); switch_status_t status = SWITCH_STATUS_FALSE; - if (switch_strlen_zero(cmd)) { + if (zstr(cmd)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Command!\n"); return SWITCH_STATUS_FALSE; } @@ -569,19 +569,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se char *transport = switch_event_get_header(event, "transport"); char *flags = switch_event_get_header(event, "flags"); - if (switch_strlen_zero(local_ip)) { + if (zstr(local_ip)) { local_ip = "127.0.0.1"; } - if (switch_strlen_zero(remote_ip)) { + if (zstr(remote_ip)) { remote_ip = "127.0.0.1"; } - if (switch_strlen_zero(local_port)) { + if (zstr(local_port)) { local_port = "8025"; } - if (switch_strlen_zero(remote_port)) { + if (zstr(remote_port)) { remote_port = "8026"; } - if (switch_strlen_zero(transport)) { + if (zstr(transport)) { transport = "udp"; } @@ -972,7 +972,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess *terminator = '\0'; } - if (!switch_strlen_zero(terminators)) { + if (!zstr(terminators)) { for (i = 0; i < x; i++) { if (strchr(terminators, buf[i]) && terminator != NULL) { *terminator = buf[i]; @@ -1038,7 +1038,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess break; } - if (!switch_strlen_zero(terminators) && strchr(terminators, dtmf.digit) && terminator != NULL) { + if (!zstr(terminators) && strchr(terminators, dtmf.digit) && terminator != NULL) { *terminator = dtmf.digit; return SWITCH_STATUS_SUCCESS; } @@ -1281,7 +1281,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ const char *forwardvar = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE); int forwardval = 70; - if (!switch_strlen_zero(forwardvar)) { + if (!zstr(forwardvar)) { forwardval = atoi(forwardvar) - 1; } if (forwardval <= 0) { @@ -1301,26 +1301,26 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ if ((profile = switch_channel_get_caller_profile(channel))) { const char *var; - if (switch_strlen_zero(dialplan)) { + if (zstr(dialplan)) { dialplan = profile->dialplan; - if (!switch_strlen_zero(dialplan) && !strcasecmp(dialplan, "inline")) { + if (!zstr(dialplan) && !strcasecmp(dialplan, "inline")) { dialplan = NULL; } } - if (switch_strlen_zero(context)) { + if (zstr(context)) { context = profile->context; } - if (switch_strlen_zero(dialplan)) { + if (zstr(dialplan)) { dialplan = "XML"; } - if (switch_strlen_zero(context)) { + if (zstr(context)) { context = "default"; } - if (switch_strlen_zero(extension)) { + if (zstr(extension)) { extension = "service"; } @@ -1750,7 +1750,7 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channe return off; for (; hi; hi = hi->next) { - if (!switch_strlen_zero(hi->name) && !switch_strlen_zero(hi->value) && ((variable = switch_xml_add_child_d(xml, hi->name, off++)))) { + if (!zstr(hi->name) && !zstr(hi->value) && ((variable = switch_xml_add_child_d(xml, hi->name, off++)))) { char *data; switch_size_t dlen = strlen(hi->value) * 3; @@ -1815,11 +1815,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_ goto error; } - if (!switch_strlen_zero(caller_profile->dialplan)) { + if (!zstr(caller_profile->dialplan)) { switch_xml_set_attr_d(x_callflow, "dialplan", caller_profile->dialplan); } - if (!switch_strlen_zero(caller_profile->profile_index)) { + if (!zstr(caller_profile->profile_index)) { switch_xml_set_attr_d(x_callflow, "profile_index", caller_profile->profile_index); } @@ -2185,7 +2185,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *sessi char * prefix_buffer = NULL, *prefix; size_t buffer_size =0; size_t prefix_size=0; - if (switch_strlen_zero(data)) { + if (zstr(data)) { goto error; } @@ -2208,7 +2208,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *sessi status = SWITCH_STATUS_SUCCESS; - if (!switch_strlen_zero(prefix)) { + if (!zstr(prefix)) { prefix_size = strlen(prefix); buffer_size = 1024 + prefix_size + 1; prefix_buffer = switch_core_session_alloc(session, buffer_size); diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 7ee95f3fac..43b74b59ec 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -653,7 +653,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session } - if (!switch_strlen_zero(require_group)) { + if (!zstr(require_group)) { int argc, i; int ok = 0; char *argv[10] = { 0 }; @@ -1774,7 +1774,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi switch_core_session_get_read_impl(session, &read_impl); - if (switch_strlen_zero(key)) { + if (zstr(key)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No Key Specified!\n"); return SWITCH_STATUS_FALSE; } @@ -1786,7 +1786,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi } for (i = 0; i < cont->index; i++) { - if (!switch_strlen_zero(cont->list[i].key) && !strcasecmp(key, cont->list[i].key)) { + if (!zstr(cont->list[i].key) && !strcasecmp(key, cont->list[i].key)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Re-enabling %s\n", key); cont->list[i].up = 1; cont->list[i].hits = 0; @@ -1797,7 +1797,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi } } - if (switch_strlen_zero(tone_spec)) { + if (zstr(tone_spec)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No Spec Specified!\n"); return SWITCH_STATUS_FALSE; } @@ -1876,7 +1876,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi } - if (switch_strlen_zero(flags)) { + if (zstr(flags)) { bflags = SMBF_READ_REPLACE; } else { if (strchr(flags, 'o')) { @@ -2117,7 +2117,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se switch_core_event_hook_add_recv_dtmf(session, meta_on_dtmf); } - if (!switch_strlen_zero(app)) { + if (!zstr(app)) { if ((bind_flags & SBF_DIAL_ALEG)) { md->sr[SWITCH_DTMF_RECV].up = 1; md->sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 2893461974..876e41e64c 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -93,20 +93,20 @@ static void send_display(switch_core_session_t *session, switch_core_session_t * name = caller_profile->callee_id_name; number = caller_profile->callee_id_number; - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = caller_profile->destination_number; } - if (switch_strlen_zero(number)) { + if (zstr(number)) { number = caller_profile->destination_number; } } else { name = caller_profile->caller_id_name; number = caller_profile->caller_id_number; - if (switch_strlen_zero(name)) { + if (zstr(name)) { name = caller_profile->destination_number; } - if (switch_strlen_zero(number)) { + if (zstr(number)) { number = caller_profile->destination_number; } } @@ -482,7 +482,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) hook_var = switch_channel_get_variable(chan_a, SWITCH_API_BRIDGE_END_VARIABLE); } - if (!switch_strlen_zero(hook_var)) { + if (!zstr(hook_var)) { switch_stream_handle_t stream = { 0 }; char *cmd = switch_core_session_strdup(session_a, hook_var); char *arg = NULL; @@ -546,7 +546,7 @@ static void transfer_after_bridge(switch_core_session_t *session, const char *wh switch_channel_set_variable(switch_core_session_get_channel(session), SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE, NULL); - if (!switch_strlen_zero(where) && (mydata = switch_core_session_strdup(session, where))) { + if (!zstr(where) && (mydata = switch_core_session_strdup(session, where))) { if ((argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]); } else { @@ -787,7 +787,7 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session) const char *sbv = switch_channel_get_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE); const char *var; - if (!switch_strlen_zero(sbv) && !strcmp(sbv, switch_core_session_get_uuid(session))) { + if (!zstr(sbv) && !strcmp(sbv, switch_core_session_get_uuid(session))) { switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL); switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL); @@ -1147,7 +1147,7 @@ static void cleanup_proxy_mode(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Restore media to %s\n", switch_channel_get_name(channel)); switch_ivr_media(switch_core_session_get_uuid(session), SMF_IMMEDIATE); - if (!switch_strlen_zero(sbv) && (sbsession = switch_core_session_locate(sbv))) { + if (!zstr(sbv) && (sbsession = switch_core_session_locate(sbv))) { switch_channel_t *sbchannel = switch_core_session_get_channel(sbsession); switch_channel_hangup(sbchannel, SWITCH_CAUSE_ATTENDED_TRANSFER); switch_core_session_rwunlock(sbsession); @@ -1321,7 +1321,7 @@ SWITCH_DECLARE(void) switch_ivr_intercept_session(switch_core_session_t *session } } - if (switch_strlen_zero(uuid) || !(rsession = switch_core_session_locate(uuid))) { + if (zstr(uuid) || !(rsession = switch_core_session_locate(uuid))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no uuid %s\n", uuid); return; } diff --git a/src/switch_ivr_menu.c b/src/switch_ivr_menu.c index d16aa57e1b..7b67b8b962 100644 --- a/src/switch_ivr_menu.c +++ b/src/switch_ivr_menu.c @@ -140,35 +140,35 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me inter_timeout = timeout / 2; } - if (!switch_strlen_zero(name)) { + if (!zstr(name)) { menu->name = switch_core_strdup(menu->pool, name); } - if (!switch_strlen_zero(greeting_sound)) { + if (!zstr(greeting_sound)) { menu->greeting_sound = switch_core_strdup(menu->pool, greeting_sound); } - if (!switch_strlen_zero(short_greeting_sound)) { + if (!zstr(short_greeting_sound)) { menu->short_greeting_sound = switch_core_strdup(menu->pool, short_greeting_sound); } - if (!switch_strlen_zero(invalid_sound)) { + if (!zstr(invalid_sound)) { menu->invalid_sound = switch_core_strdup(menu->pool, invalid_sound); } - if (!switch_strlen_zero(exit_sound)) { + if (!zstr(exit_sound)) { menu->exit_sound = switch_core_strdup(menu->pool, exit_sound); } - if (!switch_strlen_zero(confirm_macro)) { + if (!zstr(confirm_macro)) { menu->confirm_macro = switch_core_strdup(menu->pool, confirm_macro); } - if (!switch_strlen_zero(tts_engine)) { + if (!zstr(tts_engine)) { menu->tts_engine = switch_core_strdup(menu->pool, tts_engine); } - if (!switch_strlen_zero(tts_voice)) { + if (!zstr(tts_voice)) { menu->tts_voice = switch_core_strdup(menu->pool, tts_voice); } @@ -294,7 +294,7 @@ static switch_status_t play_and_collect(switch_core_session_t *session, switch_i char *sound_expanded = sound; switch_size_t menu_buf_len = 0; - if (!session || !menu || switch_strlen_zero(sound)) { + if (!session || !menu || zstr(sound)) { return status; } @@ -396,7 +396,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s switch_goto_status(SWITCH_STATUS_FALSE, end); } - if (!session || !stack || switch_strlen_zero(name)) { + if (!session || !stack || zstr(name)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid menu context\n"); switch_goto_status(SWITCH_STATUS_FALSE, end); } @@ -408,7 +408,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s switch_goto_status(SWITCH_STATUS_FALSE, end); } - if (!switch_strlen_zero(menu->tts_engine) && !switch_strlen_zero(menu->tts_voice)) { + if (!zstr(menu->tts_engine) && !zstr(menu->tts_voice)) { switch_channel_set_variable(channel, "tts_engine", menu->tts_engine); switch_channel_set_variable(channel, "tts_voice", menu->tts_voice); } @@ -456,7 +456,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s char substituted[1024]; char *use_arg = ap->arg; - if (!switch_strlen_zero(menu->tts_engine) && !switch_strlen_zero(menu->tts_voice)) { + if (!zstr(menu->tts_engine) && !zstr(menu->tts_voice)) { switch_channel_set_variable(channel, "tts_engine", menu->tts_engine); switch_channel_set_variable(channel, "tts_voice", menu->tts_voice); } @@ -516,7 +516,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s status = SWITCH_STATUS_FALSE; - if (!switch_strlen_zero(aptr)) { + if (!zstr(aptr)) { app_name = switch_core_session_strdup(session, aptr); if ((app_arg = strchr(app_name, ' '))) { *app_arg++ = '\0'; @@ -579,7 +579,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s if (stack->stack_count == 1) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "exit-sound '%s'\n", menu->exit_sound); - if (!switch_strlen_zero(menu->exit_sound)) { + if (!zstr(menu->exit_sound)) { status = play_and_collect(session, menu, menu->exit_sound, 0); } } @@ -669,7 +669,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_na { int i; - if (!switch_strlen_zero(action_name)) { + if (!zstr(action_name)) { for(i = 0;;i++) { if (!iam[i].name) { break; @@ -689,7 +689,7 @@ static switch_bool_t is_valid_action(const char *action) { int i; - if (!switch_strlen_zero(action)) { + if (!zstr(action)) { for(i = 0;;i++) { if (!iam[i].name) { break; @@ -770,7 +770,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_ switch_ivr_menu_t *menu = NULL; - if (switch_strlen_zero(max_timeouts)) { + if (zstr(max_timeouts)) { max_timeouts = max_failures; } @@ -812,7 +812,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_ const char *digits = switch_xml_attr(xml_kvp, "digits"); const char *param = switch_xml_attr_soft(xml_kvp, "param"); - if (is_valid_action(action) && !switch_strlen_zero(digits)) { + if (is_valid_action(action) && !zstr(digits)) { switch_ivr_menu_xml_map_t *xml_map = xml_menu_ctx->map; int found = 0; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index fa20e6ab4b..c7dbaf8afb 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -409,7 +409,7 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat if (oglobals->monitor_early_media_fail) { const char *var = switch_channel_get_variable(originate_status[i].peer_channel, "monitor_early_media_fail"); - if (!switch_strlen_zero(var)) { + if (!zstr(var)) { char *fail_array[128] = {0}; int fail_count = 0; char *fail_data = strdup(var); @@ -476,7 +476,7 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat if (oglobals->monitor_early_media_ring) { const char *var = switch_channel_get_variable(originate_status[i].peer_channel, "monitor_early_media_ring"); const char *var_total = switch_channel_get_variable(originate_status[i].peer_channel, "monitor_early_media_ring_total"); - if (!switch_strlen_zero(var)) { + if (!zstr(var)) { char *ring_array[128] = {0}; int ring_count = 0; char *ring_data = strdup(var); @@ -569,7 +569,7 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat && !switch_channel_test_flag(originate_status[i].peer_channel, CF_TAGGED) ) { - if (!switch_strlen_zero(oglobals->key)) { + if (!zstr(oglobals->key)) { struct key_collect *collect; if (oglobals->cancel_timeout < 0) { @@ -578,10 +578,10 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat if ((collect = switch_core_session_alloc(originate_status[i].peer_session, sizeof(*collect)))) { switch_channel_set_flag(originate_status[i].peer_channel, CF_TAGGED); - if (!switch_strlen_zero(oglobals->key)) { + if (!zstr(oglobals->key)) { collect->key = switch_core_session_strdup(originate_status[i].peer_session, oglobals->key); } - if (!switch_strlen_zero(oglobals->file)) { + if (!zstr(oglobals->file)) { collect->file = switch_core_session_strdup(originate_status[i].peer_session, oglobals->file); } switch_channel_audio_sync(originate_status[i].peer_channel); @@ -719,7 +719,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) || switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)) { ringback_data = NULL; - } else if (switch_strlen_zero(ringback_data)) { + } else if (zstr(ringback_data)) { if ((var = switch_channel_get_variable(caller_channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE))) { int sval = atoi(var); @@ -1146,7 +1146,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess data++; } - if (switch_strlen_zero(data)) { + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "No origination URL specified!\n"); status = SWITCH_STATUS_GENERR; goto done; @@ -1266,7 +1266,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) || switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)) { ringback_data = NULL; - } else if (switch_strlen_zero(ringback_data)) { + } else if (zstr(ringback_data)) { const char *vvar; if ((vvar = switch_channel_get_variable(caller_channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE))) { @@ -2209,19 +2209,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess switch_core_session_t *holding_session; if (caller_channel) { - if (switch_strlen_zero(context)) { + if (zstr(context)) { context = switch_channel_get_variable(caller_channel, "context"); } - if (switch_strlen_zero(dialplan)) { + if (zstr(dialplan)) { dialplan = switch_channel_get_variable(caller_channel, "dialplan"); } } - if (switch_strlen_zero(context)) { + if (zstr(context)) { context = "default"; } - if (switch_strlen_zero(context)) { + if (zstr(context)) { dialplan = "XML"; } diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 3a0450eeff..2819995147 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -327,7 +327,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s if (!my_tts_voice) { my_tts_voice = tts_voice; } - if (switch_strlen_zero(tts_engine) || switch_strlen_zero(tts_voice)) { + if (zstr(tts_engine) || zstr(tts_voice)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "TTS is not configured\n"); } else { status = switch_ivr_speak_text(session, my_tts_engine, my_tts_voice, odata, args); @@ -924,7 +924,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess prefix = switch_channel_get_variable(channel, "sound_prefix"); timer_name = switch_channel_get_variable(channel, "timer_name"); - if (switch_strlen_zero(file) || !switch_channel_media_ready(channel)) { + if (zstr(file) || !switch_channel_media_ready(channel)) { return SWITCH_STATUS_FALSE; } @@ -982,21 +982,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess dup = switch_core_session_strdup(session, alt); engine = dup; - if (!switch_strlen_zero(engine)) { + if (!zstr(engine)) { if ((voice = strchr(engine, ':'))) { *voice++ = '\0'; - if (!switch_strlen_zero(voice) && (text = strchr(voice, ':'))) { + if (!zstr(voice) && (text = strchr(voice, ':'))) { *text++ = '\0'; } } } - if (!switch_strlen_zero(engine) && !switch_strlen_zero(voice) && !switch_strlen_zero(text)) { + if (!zstr(engine) && !zstr(voice) && !zstr(text)) { if ((status = switch_ivr_speak_text(session, engine, voice, text, args)) != SWITCH_STATUS_SUCCESS) { return status; } continue; - } else if (!switch_strlen_zero(engine) && !(voice && text)) { + } else if (!zstr(engine) && !(voice && text)) { text = engine; engine = (char *) switch_channel_get_variable(channel, "tts_engine"); voice = (char *) switch_channel_get_variable(channel, "tts_voice"); @@ -1639,7 +1639,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session, args.buf = digit_buffer; args.buflen = (uint32_t) digit_buffer_length; - if (!switch_strlen_zero(prompt_audio_file) && strcasecmp(prompt_audio_file, "silence")) { + if (!zstr(prompt_audio_file) && strcasecmp(prompt_audio_file, "silence")) { if ((status = switch_ivr_play_file(session, NULL, prompt_audio_file, &args)) == SWITCH_STATUS_BREAK) { status = SWITCH_STATUS_SUCCESS; } @@ -1686,7 +1686,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session, *digit_buffer = '\0'; } - if (var_name && !switch_strlen_zero(digit_buffer)) { + if (var_name && !zstr(digit_buffer)) { switch_channel_set_variable(channel, var_name, digit_buffer); } @@ -1721,8 +1721,8 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t } if (status == SWITCH_STATUS_SUCCESS) { - if (!switch_strlen_zero(digit_buffer)) { - if (switch_strlen_zero(digits_regex)) { + if (!zstr(digit_buffer)) { + if (zstr(digits_regex)) { return SWITCH_STATUS_SUCCESS; } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Test Regex [%s][%s]\n", digit_buffer, digits_regex); @@ -2217,7 +2217,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess moh = switch_channel_get_variable(other_channel, "hold_music"); } - if (!switch_strlen_zero(moh) && strcasecmp(moh, "silence") && !switch_channel_test_flag(other_channel, CF_BROADCAST)) { + if (!zstr(moh) && strcasecmp(moh, "silence") && !switch_channel_test_flag(other_channel, CF_BROADCAST)) { switch_ivr_broadcast(other_uuid, moh, SMF_ECHO_ALEG | SMF_LOOP); moh_br++; } @@ -2228,7 +2228,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *sess moh = switch_channel_get_variable(channel, "hold_music"); } - if (!switch_strlen_zero(moh) && strcasecmp(moh, "silence")) { + if (!zstr(moh) && strcasecmp(moh, "silence")) { switch_ivr_play_file(session, NULL, moh, &args); } else { switch_ivr_collect_digits_callback(session, &args, 0, 0); diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 097df70eaf..ec54423a03 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -960,7 +960,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_exists(const char *mod) { switch_status_t status; - if (switch_strlen_zero(mod)) { + if (zstr(mod)) { return SWITCH_STATUS_FALSE; } @@ -1166,7 +1166,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init() switch_bool_t global = SWITCH_FALSE; const char *val = switch_xml_attr_soft(ld, "module"); const char *sglobal = switch_xml_attr_soft(ld, "global"); - if (switch_strlen_zero(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) { + if (zstr(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val); continue; } @@ -1189,7 +1189,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init() switch_bool_t global = SWITCH_FALSE; const char *val = switch_xml_attr_soft(ld, "module"); const char *sglobal = switch_xml_attr_soft(ld, "global"); - if (switch_strlen_zero(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) { + if (zstr(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val); continue; } @@ -1230,7 +1230,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init() continue; } - if (switch_strlen_zero(fname) || (!strstr(fname, ext) && !strstr(fname, EXT))) { + if (zstr(fname) || (!strstr(fname, ext) && !strstr(fname, EXT))) { continue; } diff --git a/src/switch_log.c b/src/switch_log.c index 60175026e8..f28960c3c0 100644 --- a/src/switch_log.c +++ b/src/switch_log.c @@ -103,12 +103,12 @@ SWITCH_DECLARE(switch_log_node_t*) switch_log_node_dup(const switch_log_node_t * *newnode = *node; - if (!switch_strlen_zero(node->data)) { + if (!zstr(node->data)) { newnode->data = strdup(node->data); switch_assert(node->data); } - if (!switch_strlen_zero(node->userdata)) { + if (!zstr(node->userdata)) { newnode->userdata = strdup(node->userdata); switch_assert(node->userdata); } @@ -398,7 +398,7 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Log-Function", funcp); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Level", "%d", (int) level); - if (!switch_strlen_zero(userdata)) { + if (!zstr(userdata)) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "User-Data", userdata); } switch_event_fire(&event); @@ -458,7 +458,7 @@ SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const cha node->content = content; node->timestamp = now; node->channel = channel; - node->userdata = !switch_strlen_zero(userdata) ? strdup(userdata) : NULL; + node->userdata = !zstr(userdata) ? strdup(userdata) : NULL; if (switch_queue_trypush(LOG_QUEUE, node) != SWITCH_STATUS_SUCCESS) { switch_log_node_free(&node); diff --git a/src/switch_nat.c b/src/switch_nat.c index 505e9963fe..394841118f 100644 --- a/src/switch_nat.c +++ b/src/switch_nat.c @@ -69,7 +69,7 @@ static switch_status_t get_upnp_pubaddr(char *pub_addr) if (UPNP_GetExternalIPAddress(nat_globals.urls.controlURL, nat_globals.data.servicetype, pub_addr) == UPNPCOMMAND_SUCCESS) { - if (!strcmp(pub_addr, "0.0.0.0") || switch_strlen_zero_buf(pub_addr)) { + if (!strcmp(pub_addr, "0.0.0.0") || zstr_buf(pub_addr)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "uPNP Device (url: %s) returned an invalid external address of '%s'. Disabling uPNP\n", nat_globals.urls.controlURL, pub_addr); return SWITCH_STATUS_GENERR; diff --git a/src/switch_odbc.c b/src/switch_odbc.c index 3066c4e1cb..cb0a91c801 100644 --- a/src/switch_odbc.c +++ b/src/switch_odbc.c @@ -524,7 +524,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(c if (stmt) { err_str = switch_odbc_handle_get_error(handle, stmt); - if (!switch_strlen_zero(err_str)) { + if (!zstr(err_str)) { switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str)); } switch_safe_free(err_str); diff --git a/src/switch_rtp.c b/src/switch_rtp.c index f654fa1a40..32f087c2e4 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -765,7 +765,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s *err = NULL; - if (switch_strlen_zero(host) || !port) { + if (zstr(host) || !port) { *err = "Address Error"; goto done; } @@ -869,7 +869,7 @@ SWITCH_DECLARE(void) switch_rtp_reset_media_timer(switch_rtp_t *rtp_session) SWITCH_DECLARE(char *) switch_rtp_get_remote_host(switch_rtp_t *rtp_session) { - return switch_strlen_zero(rtp_session->remote_host_str) ? "0.0.0.0" : rtp_session->remote_host_str; + return zstr(rtp_session->remote_host_str) ? "0.0.0.0" : rtp_session->remote_host_str; } SWITCH_DECLARE(switch_port_t) switch_rtp_get_remote_port(switch_rtp_t *rtp_session) @@ -1138,15 +1138,15 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session switch_rtp_set_interval(rtp_session, ms_per_packet, samples_per_interval); rtp_session->conf_samples_per_interval = samples_per_interval; - if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) && switch_strlen_zero(timer_name)) { + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) && zstr(timer_name)) { timer_name = "soft"; } - if (!switch_strlen_zero(timer_name) && !strcasecmp(timer_name, "none")) { + if (!zstr(timer_name) && !strcasecmp(timer_name, "none")) { timer_name = NULL; } - if (!switch_strlen_zero(timer_name)) { + if (!zstr(timer_name)) { rtp_session->timer_name = switch_core_strdup(pool, timer_name); switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER); switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK); @@ -1229,7 +1229,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, { switch_rtp_t *rtp_session = NULL; - if (switch_strlen_zero(rx_host)) { + if (zstr(rx_host)) { *err = "Missing local host"; goto end; } @@ -1239,7 +1239,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, goto end; } - if (switch_strlen_zero(tx_host)) { + if (zstr(tx_host)) { *err = "Missing remote host"; goto end; } @@ -1901,7 +1901,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ const char *err; uint32_t old = rtp_session->remote_port; - if (!switch_strlen_zero(tx_host) && switch_sockaddr_get_port(rtp_session->from_addr) > 0) { + if (!zstr(tx_host) && switch_sockaddr_get_port(rtp_session->from_addr) > 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host, switch_sockaddr_get_port(rtp_session->from_addr)); diff --git a/src/switch_scheduler.c b/src/switch_scheduler.c index 4a4e006886..de0e5281cc 100644 --- a/src/switch_scheduler.c +++ b/src/switch_scheduler.c @@ -263,7 +263,7 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_group(const char *group) switch_mutex_lock(globals.task_mutex); for (tp = globals.task_list; tp; tp = tp->next) { - if (!switch_strlen_zero(group) && !strcmp(tp->task.group, group)) { + if (!zstr(group) && !strcmp(tp->task.group, group)) { if (switch_test_flag(tp, SSHF_NO_DEL)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Attempt made to delete undeletable task #%u (group %s)\n", tp->task.task_id, group); diff --git a/src/switch_swig.c b/src/switch_swig.c index 297dafb65d..44f3755afc 100644 --- a/src/switch_swig.c +++ b/src/switch_swig.c @@ -49,7 +49,7 @@ int fs_core_init(char *path) switch_status_t status; const char *err = NULL; - if (switch_strlen_zero(path)) { + if (zstr(path)) { path = NULL; } diff --git a/src/switch_time.c b/src/switch_time.c index 50e52ebfbe..53813df6ce 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -640,11 +640,11 @@ void switch_load_timezones(switch_bool_t reload) const char *name = switch_xml_attr(x_list, "name"); const char *value= switch_xml_attr(x_list, "value"); - if (switch_strlen_zero(name)) { + if (zstr(name)) { continue; } - if (switch_strlen_zero(value)) { + if (zstr(value)) { continue; } @@ -683,7 +683,7 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_t timep = (thetime) / (int64_t) (1000000); - if (!switch_strlen_zero(tz_name)) { + if (!zstr(tz_name)) { tzdef = switch_lookup_timezone( tz_name ); } else { /* We set the default timezone to GMT. */ @@ -719,7 +719,7 @@ SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *f timep = (thetime) / (int64_t) (1000000); - if (!switch_strlen_zero(tz_name)) { + if (!zstr(tz_name)) { tzdef = switch_lookup_timezone( tz_name ); } else { /* We set the default timezone to GMT. */ @@ -730,8 +730,8 @@ SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *f if (tzdef) { /* The lookup of the zone may fail. */ tztime( &timep, tzdef, &tm ); tm2switchtime( &tm, &stm ); - switch_strftime_nocheck(date, &retsize, len, switch_strlen_zero(format) ? "%Y-%m-%d %T" : format, &stm); - if (!switch_strlen_zero_buf(date)) { + switch_strftime_nocheck(date, &retsize, len, zstr(format) ? "%Y-%m-%d %T" : format, &stm); + if (!zstr_buf(date)) { return SWITCH_STATUS_SUCCESS; } } diff --git a/src/switch_utils.c b/src/switch_utils.c index 4ba48464af..868936dcdb 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -181,7 +181,7 @@ SWITCH_DECLARE(switch_status_t) switch_network_list_add_cidr_token(switch_networ node->bits = bits; node->str = switch_core_strdup(list->pool, cidr_str); - if (!switch_strlen_zero(token)) { + if (!zstr(token)) { node->token = switch_core_strdup(list->pool, token); } @@ -449,7 +449,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, char *newfile = NULL; switch_bool_t rval = SWITCH_FALSE; - if (!switch_strlen_zero(file) && !switch_strlen_zero(convert_cmd) && !switch_strlen_zero(convert_ext)) { + if (!zstr(file) && !zstr(convert_cmd) && !zstr(convert_ext)) { if ((ext = strrchr(file, '.'))) { dupfile = strdup(file); if ((ext = strrchr(dupfile, '.'))) { @@ -580,7 +580,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, close(ifd); } - if (switch_strlen_zero(from)) { + if (zstr(from)) { from = "freeswitch"; } @@ -617,7 +617,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip) { - if (switch_strlen_zero(ip)) + if (zstr(ip)) return SWITCH_FALSE; return (strncmp(ip, "10.", 3) && @@ -1824,7 +1824,7 @@ SWITCH_DECLARE(char *) switch_url_decode(char *s) char *o; unsigned int tmp; - if (switch_strlen_zero(s)) { + if (zstr(s)) { return s; } diff --git a/src/switch_xml.c b/src/switch_xml.c index 2257475bfa..e2b3035648 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -1551,7 +1551,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section, const char *err = NULL; err = switch_xml_error(xml); - if (switch_strlen_zero(err)) { + if (zstr(err)) { if ((conf = switch_xml_find_child(xml, "section", "name", "result"))) { switch_xml_t p; const char *aname; @@ -1890,7 +1890,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e *err = switch_xml_error(new_main); switch_copy_string(not_so_threadsafe_error_buffer, *err, sizeof(not_so_threadsafe_error_buffer)); *err = not_so_threadsafe_error_buffer; - if (!switch_strlen_zero(*err)) { + if (!zstr(*err)) { switch_xml_free(new_main); new_main = NULL; errcnt++; diff --git a/src/switch_xml_config.c b/src/switch_xml_config.c index 48147a059a..78bf4a541f 100644 --- a/src/switch_xml_config.c +++ b/src/switch_xml_config.c @@ -208,7 +208,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_event(switch_event_t *ev /* Perform validation */ if (value) { - if (!switch_strlen_zero(string_options->validation_regex)) { + if (!zstr(string_options->validation_regex)) { if (switch_regex_match(value, string_options->validation_regex) == SWITCH_STATUS_SUCCESS) { newstring = value; /* Regex match, accept value*/ } else {