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; char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; profile = switch_core_alloc(pool, sizeof(*profile)); switch_assert(profile != NULL); switch_uuid_str(uuid_str, sizeof(uuid_str)); profile->uuid_str = switch_core_strdup(pool, uuid_str); profile->clone_of = switch_core_strdup(pool, tocopy->uuid_str); profile_dup(tocopy->username, profile->username, pool); profile_dup(tocopy->dialplan, profile->dialplan, pool); profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool); profile_dup(tocopy->caller_id_number, profile->caller_id_number, pool); profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool); profile_dup(tocopy->callee_id_number, profile->callee_id_number, pool); profile_dup(tocopy->orig_caller_id_name, profile->orig_caller_id_name, pool); profile_dup(tocopy->orig_caller_id_number, profile->orig_caller_id_number, pool); profile_dup(tocopy->network_addr, profile->network_addr, pool); profile_dup(tocopy->ani, profile->ani, pool); profile_dup(tocopy->aniii, profile->aniii, pool); profile_dup(tocopy->rdnis, profile->rdnis, pool); profile_dup(tocopy->source, profile->source, pool); profile_dup(tocopy->context, profile->context, pool); profile_dup(tocopy->destination_number, profile->destination_number, pool); profile_dup(tocopy->uuid, profile->uuid, pool); profile_dup(tocopy->chan_name, profile->chan_name, pool); profile->caller_ton = tocopy->caller_ton; profile->caller_numplan = tocopy->caller_numplan; profile->ani_ton = tocopy->ani_ton; profile->ani_numplan = tocopy->ani_numplan; profile->rdnis_ton = tocopy->rdnis_ton; profile->rdnis_numplan = tocopy->rdnis_numplan; profile->destination_number_ton = tocopy->destination_number_ton; profile->destination_number_numplan = tocopy->destination_number_numplan; profile->flags = tocopy->flags; profile->pool = pool; profile->direction = tocopy->direction; if (tocopy->times) { profile->old_times = (switch_channel_timetable_t *) switch_core_alloc(profile->pool, sizeof(switch_channel_timetable_t)); *profile->old_times = *tocopy->times; } else { tocopy->times = (switch_channel_timetable_t *) switch_core_alloc(tocopy->pool, sizeof(*tocopy->times)); } if (tocopy->soft) { profile_node_t *pn; for (pn = tocopy->soft; pn; pn = pn->next) { profile_node_t *pp, *n = switch_core_alloc(profile->pool, sizeof(*n)); n->var = switch_core_strdup(profile->pool, pn->var); n->val = switch_core_strdup(profile->pool, pn->val); if (!profile->soft) { profile->soft = n; } else { for(pp = profile->soft; pp && pp->next; pp = pp->next); if (pp) { pp->next = n; } } } } return profile; }
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; profile = switch_core_alloc(pool, sizeof(*profile)); switch_assert(profile != NULL); profile_dup(tocopy->username, profile->username, pool); profile_dup(tocopy->dialplan, profile->dialplan, pool); profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool); profile_dup(tocopy->caller_id_number, profile->caller_id_number, pool); profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool); profile_dup(tocopy->callee_id_number, profile->callee_id_number, pool); profile_dup(tocopy->network_addr, profile->network_addr, pool); profile_dup(tocopy->ani, profile->ani, pool); profile_dup(tocopy->aniii, profile->aniii, pool); profile_dup(tocopy->rdnis, profile->rdnis, pool); profile_dup(tocopy->source, profile->source, pool); profile_dup(tocopy->context, profile->context, pool); profile_dup(tocopy->destination_number, profile->destination_number, pool); profile_dup(tocopy->uuid, profile->uuid, pool); profile_dup(tocopy->chan_name, profile->chan_name, pool); profile->caller_ton = tocopy->caller_ton; profile->caller_numplan = tocopy->caller_numplan; profile->ani_ton = tocopy->ani_ton; profile->ani_numplan = tocopy->ani_numplan; profile->rdnis_ton = tocopy->rdnis_ton; profile->rdnis_numplan = tocopy->rdnis_numplan; profile->destination_number_ton = tocopy->destination_number_ton; profile->destination_number_numplan = tocopy->destination_number_numplan; profile->flags = tocopy->flags; profile->pool = pool; profile->direction = tocopy->direction; return profile; }