From 7d6d688e538835b133ee638ff0d972956cbace04 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 26 Aug 2013 20:25:14 +0500 Subject: [PATCH] FS-5731 --resolve --- src/include/switch_core.h | 2 ++ .../applications/mod_commands/mod_commands.c | 8 ++++---- .../mod_conference/mod_conference.c | 6 +++--- src/mod/applications/mod_dptools/mod_dptools.c | 12 ++++++------ src/mod/applications/mod_fifo/mod_fifo.c | 2 +- src/mod/applications/mod_httapi/mod_httapi.c | 2 +- .../mod_valet_parking/mod_valet_parking.c | 2 +- .../applications/mod_voicemail/mod_voicemail.c | 2 +- src/mod/endpoints/mod_rtmp/rtmp_sig.c | 2 +- src/mod/endpoints/mod_sofia/mod_sofia.c | 4 ++-- src/mod/endpoints/mod_sofia/sofia_presence.c | 2 +- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 2 +- src/switch_core.c | 18 ++++++++++++++++++ 13 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 880cf9b893..1a12da7129 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -878,6 +878,8 @@ SWITCH_DECLARE(char *) switch_core_get_variable_pdup(_In_z_ const char *varname, SWITCH_DECLARE(const char *) switch_core_get_hostname(void); SWITCH_DECLARE(const char *) switch_core_get_switchname(void); +SWITCH_DECLARE(char *) switch_core_get_domain(switch_bool_t dup); + /*! \brief Add a global variable to the core \param varname the name of the variable diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index abc0aace9a..2b7804dd31 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -467,7 +467,7 @@ SWITCH_STANDARD_API(reg_url_function) } if (zstr(domain)) { - dup_domain = switch_core_get_variable_dup("domain"); + dup_domain = switch_core_get_domain(SWITCH_TRUE); domain = dup_domain; } @@ -886,7 +886,7 @@ SWITCH_STANDARD_API(group_call_function) if (domain) { *domain++ = '\0'; } else { - if ((dup_domain = switch_core_get_variable_dup("domain"))) { + if ((dup_domain = switch_core_get_domain(SWITCH_TRUE))) { domain = dup_domain; } } @@ -1076,7 +1076,7 @@ SWITCH_STANDARD_API(in_group_function) if ((domain = strchr(user, '@'))) { *domain++ = '\0'; } else { - if ((dup_domain = switch_core_get_variable_dup("domain"))) { + if ((dup_domain = switch_core_get_domain(SWITCH_TRUE))) { domain = dup_domain; } } @@ -1131,7 +1131,7 @@ SWITCH_STANDARD_API(user_data_function) if ((domain = strchr(user, '@'))) { *domain++ = '\0'; } else { - if ((dup_domain = switch_core_get_variable_dup("domain"))) { + if ((dup_domain = switch_core_get_domain(SWITCH_TRUE))) { domain = dup_domain; } else { domain = "cluecon.com"; diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 19cb860267..398491eb13 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -643,7 +643,7 @@ static char *conference_rfc4579_render(conference_obj_t *conference, switch_even if (!event || !(domain = switch_event_get_header(event, "conference-domain"))) { if (!(domain = conference->domain)) { - dup_domain = switch_core_get_variable_dup("domain"); + dup_domain = switch_core_get_domain(SWITCH_TRUE); if (!(domain = dup_domain)) { domain = "cluecon.com"; } @@ -1338,7 +1338,7 @@ static void send_rfc_event(conference_obj_t *conference) } if (!(domain = conference->domain)) { - dup_domain = switch_core_get_variable_dup("domain"); + dup_domain = switch_core_get_domain(SWITCH_TRUE); if (!(domain = dup_domain)) { domain = "cluecon.com"; } @@ -1377,7 +1377,7 @@ static void send_conference_notify(conference_obj_t *conference, const char *sta } if (!(domain = conference->domain)) { - dup_domain = switch_core_get_variable_dup("domain"); + dup_domain = switch_core_get_domain(SWITCH_TRUE); if (!(domain = dup_domain)) { domain = "cluecon.com"; } diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 1f910c70ab..a05f880a4a 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -3288,7 +3288,7 @@ static void pickup_send_presence(const char *key_name) } if (zstr(domain_name)) { - dup_domain_name = switch_core_get_variable_dup("domain"); + dup_domain_name = switch_core_get_domain(SWITCH_TRUE); domain_name = dup_domain_name; } @@ -3363,7 +3363,7 @@ static void pickup_pres_event_handler(switch_event_t *event) if ((domain_name = strchr(key_name, '@'))) { *domain_name++ = '\0'; } else { - dup_domain_name = switch_core_get_variable_dup("domain"); + dup_domain_name = switch_core_get_domain(SWITCH_TRUE); domain_name = dup_domain_name; } @@ -3422,7 +3422,7 @@ static void pickup_add_session(switch_core_session_t *session, const char *key) char *dup_key = NULL; if (!strchr(key, '@')) { - dup_key = switch_mprintf("%s@%s", key, switch_core_get_variable("domain")); + dup_key = switch_mprintf("%s@%s", key, switch_core_get_domain(SWITCH_FALSE)); key = dup_key; } @@ -3456,7 +3456,7 @@ static char *pickup_pop_uuid(const char *key, const char *uuid) char *dup_key = NULL; if (!strchr(key, '@')) { - dup_key = switch_mprintf("%s@%s", key, switch_core_get_variable("domain")); + dup_key = switch_mprintf("%s@%s", key, switch_core_get_domain(SWITCH_FALSE)); key = dup_key; } @@ -3781,7 +3781,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session if ((domain = strchr(group, '@'))) { *domain++ = '\0'; } else { - domain = switch_core_get_variable_dup("domain"); + domain = switch_core_get_domain(SWITCH_TRUE); dup_domain = domain; } @@ -3904,7 +3904,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, if ((domain = strchr(user, '@'))) { *domain++ = '\0'; } else { - domain = switch_core_get_variable_dup("domain"); + domain = switch_core_get_domain(SWITCH_TRUE); dup_domain = domain; } diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 05652d2c23..d2cefcfea4 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -863,7 +863,7 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu node->name = switch_core_strdup(node->pool, name); if (!strchr(name, '@')) { - domain_name = switch_core_get_variable_dup("domain"); + domain_name = switch_core_get_domain(SWITCH_TRUE); node->domain_name = switch_core_strdup(node->pool, domain_name); } diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 52e4a21a6b..e5bfac12ae 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -263,7 +263,7 @@ static switch_status_t parse_voicemail(const char *tag_name, client_t *client, s if (zstr(profile)) profile = "default"; if (zstr(domain)) { - if ((ddom = switch_core_get_variable_dup("domain"))) { + if ((ddom = switch_core_get_domain(SWITCH_TRUE))) { domain = ddom; } } 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 a428f82684..f14c81c3bf 100644 --- a/src/mod/applications/mod_valet_parking/mod_valet_parking.c +++ b/src/mod/applications/mod_valet_parking/mod_valet_parking.c @@ -287,7 +287,7 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to } if (zstr(domain_name)) { - dup_domain_name = switch_core_get_variable_dup("domain"); + dup_domain_name = switch_core_get_domain(SWITCH_TRUE); domain_name = dup_domain_name; } diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index e7d4da79ca..bf355d043b 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -3167,7 +3167,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t } if (zstr(domain)) { - if ((dup_domain = switch_core_get_variable_dup("domain"))) { + if ((dup_domain = switch_core_get_domain(SWITCH_TRUE))) { domain = dup_domain; } profile_name = domain; diff --git a/src/mod/endpoints/mod_rtmp/rtmp_sig.c b/src/mod/endpoints/mod_rtmp/rtmp_sig.c index fb82b180ea..a3160eee5b 100644 --- a/src/mod/endpoints/mod_rtmp/rtmp_sig.c +++ b/src/mod/endpoints/mod_rtmp/rtmp_sig.c @@ -376,7 +376,7 @@ RTMP_INVOKE_FUNCTION(rtmp_i_login) } if (zstr(domain)) { - ddomain = switch_core_get_variable_dup("domain"); + ddomain = switch_core_get_domain(SWITCH_TRUE); domain = ddomain; } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 7c146f41ba..e3ffae4778 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -3538,7 +3538,7 @@ SWITCH_STANDARD_API(sofia_contact_function) } if (zstr(domain)) { - dup_domain = switch_core_get_variable_dup("domain"); + dup_domain = switch_core_get_domain(SWITCH_TRUE); domain = dup_domain; } @@ -3728,7 +3728,7 @@ SWITCH_STANDARD_API(sofia_presence_data_function) } if (zstr(domain)) { - dup_domain = switch_core_get_variable_dup("domain"); + dup_domain = switch_core_get_domain(SWITCH_TRUE); domain = dup_domain; } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 6f3ba5c8a4..465455568b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1037,7 +1037,7 @@ static void conference_data_event_handler(switch_event_t *event) sofia_profile_t *profile = NULL; if (zstr(host)) { - dup_domain = switch_core_get_variable_dup("domain"); + dup_domain = switch_core_get_domain(SWITCH_TRUE); host = dup_domain; } 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 3db20be69b..9d9e3fbb14 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 @@ -428,7 +428,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name) if (globals.default_domain) { domain_name = globals.default_domain; } else { - if ((dup_domain = switch_core_get_variable_dup("domain"))) { + if ((dup_domain = switch_core_get_domain(SWITCH_TRUE))) { domain_name = dup_domain; } } diff --git a/src/switch_core.c b/src/switch_core.c index b2dc5dc2ab..6529166686 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -311,6 +311,24 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void) return runtime.hostname; } +SWITCH_DECLARE(char *) switch_core_get_domain(switch_bool_t dup) +{ + char *domain; + const char *var; + + switch_thread_rwlock_rdlock(runtime.global_var_rwlock); + if (!(var = switch_core_get_variable("domain"))) { + var = "freeswitch.local"; + } + if (dup) { + domain = strdup(var); + } else { + domain = (char *) var; + } + switch_thread_rwlock_unlock(runtime.global_var_rwlock); + + return domain; +} SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event) {