add ability to match in dialplan to the ton and numplan caller profile fields. added switch_caller_profile_dup function to be used in the future for places where we copy one profile to another to reduce code duplication. add "pool" member to the caller profile for when we need to allocate strings off that pool.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5669 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris committed 2007-08-28 16:41:38 +00:00
1 parent 8dc23d384e
commit 352cc95813
2 files changed
+61 -16

No files matched your search

+53 -15
View File
@@ -63,29 +63,31 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
profile->context = switch_clean_string(switch_core_strdup(pool, switch_str_nil(context)));
profile->destination_number = switch_clean_string(switch_core_strdup(pool, switch_str_nil(destination_number)));
switch_set_flag(profile, SWITCH_CPF_SCREEN);
profile->pool = pool;
}
return profile;
}
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
{
switch_caller_profile_t *profile = NULL;
if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile_t))) != 0) {
profile->username = switch_core_session_strdup(session, tocopy->username);
profile->dialplan = switch_core_session_strdup(session, tocopy->dialplan);
profile->caller_id_name = switch_core_session_strdup(session, tocopy->caller_id_name);
profile->ani = switch_core_session_strdup(session, tocopy->ani);
profile->aniii = switch_core_session_strdup(session, tocopy->aniii);
profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number);
profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr);
profile->rdnis = switch_core_session_strdup(session, tocopy->rdnis);
profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number);
profile->uuid = switch_core_session_strdup(session, tocopy->uuid);
profile->source = switch_core_session_strdup(session, tocopy->source);
profile->context = switch_core_session_strdup(session, tocopy->context);
profile->chan_name = switch_core_session_strdup(session, tocopy->chan_name);
if ((profile = switch_core_alloc(pool, sizeof(switch_caller_profile_t))) != 0) {
profile->username = switch_core_strdup(pool, tocopy->username);
profile->dialplan = switch_core_strdup(pool, tocopy->dialplan);
profile->caller_id_name = switch_core_strdup(pool, tocopy->caller_id_name);
profile->ani = switch_core_strdup(pool, tocopy->ani);
profile->aniii = switch_core_strdup(pool, tocopy->aniii);
profile->caller_id_number = switch_core_strdup(pool, tocopy->caller_id_number);
profile->network_addr = switch_core_strdup(pool, tocopy->network_addr);
profile->rdnis = switch_core_strdup(pool, tocopy->rdnis);
profile->destination_number = switch_core_strdup(pool, tocopy->destination_number);
profile->uuid = switch_core_strdup(pool, tocopy->uuid);
profile->source = switch_core_strdup(pool, tocopy->source);
profile->context = switch_core_strdup(pool, tocopy->context);
profile->chan_name = switch_core_strdup(pool, tocopy->chan_name);
profile->caller_ton = tocopy->caller_ton;
profile->caller_numplan = tocopy->caller_numplan;
profile->ani_ton = tocopy->ani_ton;
@@ -95,11 +97,23 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor
profile->destination_number_ton = tocopy->destination_number_ton;
profile->destination_number_numplan = tocopy->destination_number_numplan;
profile->flags = tocopy->flags;
profile->pool = pool;
}
return profile;
}
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
{
switch_memory_pool_t *pool;
pool = switch_core_session_get_pool(session);
return switch_caller_profile_dup(pool, tocopy);
}
SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name)
{
if (!strcasecmp(name, "dialplan")) {
@@ -141,6 +155,30 @@ SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *
if (!strcasecmp(name, "chan_name")) {
return caller_profile->chan_name;
}
if (!strcasecmp(name, "caller_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
}
if (!strcasecmp(name, "caller_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
}
if (!strcasecmp(name, "destination_number_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
}
if (!strcasecmp(name, "destination_number_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
}
if (!strcasecmp(name, "ani_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
}
if (!strcasecmp(name, "ani_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
}
if (!strcasecmp(name, "rdnis_ton")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
}
if (!strcasecmp(name, "rdnis_numplan")) {
return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
}
return NULL;
}