From 7cd66c9830da62c6d367bf8ea10a9a18aa84d4ab Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 13 Oct 2020 09:47:00 -0400 Subject: [PATCH] TT#97150 restore strings broken up by separator parsing This is relevant for records coming from Redis, as the insertion into the trash and backup tables is done from the strings kept in memory. Change-Id: I1398f7bfc0d4a0c2da8b8104dc4589ea9d983da7 (cherry picked from commit 6e957e69b7ee5cc0d21a3b40d917a0f3ce70eab6) --- cdr.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/cdr.c b/cdr.c index af017b6..2d26049 100644 --- a/cdr.c +++ b/cdr.c @@ -732,6 +732,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_user_id, tmp2, sizeof(cdr->source_user_id)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -743,6 +744,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) *tmp1 = '\0'; g_strlcpy(cdr->source_user, tmp2, sizeof(cdr->source_user)); uri_unescape(cdr->source_user); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -753,6 +755,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_domain, tmp2, sizeof(cdr->source_domain)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; @@ -765,6 +768,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) *tmp1 = '\0'; g_strlcpy(cdr->source_cli, tmp2, sizeof(cdr->source_cli)); uri_unescape(cdr->source_cli); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -776,6 +780,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) *tmp1 = '\0'; g_strlcpy(cdr->source_ext_subscriber_id, tmp2, sizeof(cdr->source_ext_subscriber_id)); uri_unescape(cdr->source_ext_subscriber_id); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -787,6 +792,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) *tmp1 = '\0'; g_strlcpy(cdr->source_ext_contract_id, tmp2, sizeof(cdr->source_ext_contract_id)); uri_unescape(cdr->source_ext_contract_id); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -797,6 +803,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; cdr->source_account_id = atoll(tmp2); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -807,6 +814,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->peer_auth_user, tmp2, sizeof(cdr->peer_auth_user)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -817,6 +825,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->peer_auth_realm, tmp2, sizeof(cdr->peer_auth_realm)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -827,6 +836,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; cdr->source_clir = atoi(tmp2); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -837,6 +847,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->call_type, tmp2, sizeof(cdr->call_type)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -847,6 +858,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_ip, tmp2, sizeof(cdr->source_ip)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -857,6 +869,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; cdr->init_time = g_strtod(tmp2, NULL); + *tmp1 = MED_SEP; tmp2 = ++tmp1; int i; @@ -870,6 +883,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_gpp[i], tmp2, sizeof(cdr->source_gpp[i])); + *tmp1 = MED_SEP; tmp2 = ++tmp1; } @@ -888,6 +902,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_lnp_prefix, tmp2, sizeof(cdr->source_lnp_prefix)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -905,6 +920,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) *tmp1 = '\0'; g_strlcpy(cdr->source_user_out, tmp2, sizeof(cdr->source_user_out)); uri_unescape(cdr->source_user_out); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -915,6 +931,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_lnp_type, tmp2, sizeof(cdr->source_lnp_type)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -925,6 +942,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->header_pai, tmp2, sizeof(cdr->header_pai)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -935,6 +953,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->header_diversion, tmp2, sizeof(cdr->header_diversion)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -945,6 +964,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->group, tmp2, sizeof(cdr->group)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -955,6 +975,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->header_u2u, tmp2, sizeof(cdr->header_u2u)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -967,6 +988,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; cdr->source_lcr_id = atoll(tmp2); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -978,6 +1000,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_concurrent_calls_quota, tmp2, sizeof(cdr->source_concurrent_calls_quota)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -989,6 +1012,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_concurrent_calls_count, tmp2, sizeof(cdr->source_concurrent_calls_count)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1000,6 +1024,7 @@ static int cdr_parse_srcleg_list(char *srcleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->source_concurrent_calls_count_customer, tmp2, sizeof(cdr->source_concurrent_calls_count_customer)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; return 0; @@ -1019,6 +1044,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; cdr->split = atoi(tmp2); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1030,6 +1056,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) *tmp1 = '\0'; g_strlcpy(cdr->destination_ext_subscriber_id, tmp2, sizeof(cdr->destination_ext_subscriber_id)); uri_unescape(cdr->destination_ext_subscriber_id); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1041,6 +1068,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) *tmp1 = '\0'; g_strlcpy(cdr->destination_ext_contract_id, tmp2, sizeof(cdr->destination_ext_contract_id)); uri_unescape(cdr->destination_ext_contract_id); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1051,6 +1079,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; cdr->destination_account_id = atoll(tmp2); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1061,6 +1090,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_dialed, tmp2, sizeof(cdr->destination_dialed)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1071,6 +1101,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_user_id, tmp2, sizeof(cdr->destination_user_id)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1081,6 +1112,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_user, tmp2, sizeof(cdr->destination_user)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1091,6 +1123,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_domain, tmp2, sizeof(cdr->destination_domain)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1101,6 +1134,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_user_in, tmp2, sizeof(cdr->destination_user_in)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1111,6 +1145,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_domain_in, tmp2, sizeof(cdr->destination_domain_in)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1121,6 +1156,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; cdr->destination_lcr_id = atoll(tmp2); + *tmp1 = MED_SEP; tmp2 = ++tmp1; int i; @@ -1134,6 +1170,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_gpp[i], tmp2, sizeof(cdr->destination_gpp[i])); + *tmp1 = MED_SEP; tmp2 = ++tmp1; } @@ -1152,6 +1189,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_lnp_prefix, tmp2, sizeof(cdr->destination_lnp_prefix)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1168,6 +1206,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_user_out, tmp2, sizeof(cdr->destination_user_out)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1178,6 +1217,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_lnp_type, tmp2, sizeof(cdr->destination_lnp_type)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1188,6 +1228,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->furnished_charging_info, tmp2, sizeof(cdr->furnished_charging_info)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1199,6 +1240,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_concurrent_calls_quota, tmp2, sizeof(cdr->destination_concurrent_calls_quota)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1210,6 +1252,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_concurrent_calls_count, tmp2, sizeof(cdr->destination_concurrent_calls_count)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; tmp1 = strchr(tmp2, MED_SEP); @@ -1221,6 +1264,7 @@ static int cdr_parse_dstleg_list(char *dstleg, cdr_entry_t *cdr) } *tmp1 = '\0'; g_strlcpy(cdr->destination_concurrent_calls_count_customer, tmp2, sizeof(cdr->destination_concurrent_calls_count_customer)); + *tmp1 = MED_SEP; tmp2 = ++tmp1; return 0;