TT#170203 split out function to truncate call ID suffixes

Change-Id: I212ba747cec7eff4369b0dbedaa157047b8e0765
mr11.0
Richard Fuchs 4 years ago
parent 9296e59fbb
commit 0aab12ef9d

26
cdr.c

@ -1638,3 +1638,29 @@ void cdr_parse_entry(med_entry_t *e)
e->method = MED_UNRECOGNIZED;
}
}
// try strip one suffix and return whether it was done
static inline int cdr_truncate_suffix(char *callid, size_t *len, const char *suffix) {
size_t slen = strlen(suffix);
if (*len < slen)
return 0;
if (memcmp(&callid[*len - slen], suffix, slen) != 0)
return 0;
callid[*len - slen] = '\0';
*len -= slen;
return 1;
}
// strip (potentially chained) suffices
void cdr_truncate_call_id_suffix(char *callid)
{
size_t len = strlen(callid);
while (1) {
if (cdr_truncate_suffix(callid, &len, PBXSUFFIX))
continue;
if (cdr_truncate_suffix(callid, &len, XFERSUFFIX))
continue;
break;
};
}

@ -63,6 +63,7 @@ typedef struct {
int cdr_process_records(GQueue *records, uint64_t *cdr_count, struct medmysql_batches *,
int do_intermediate);
void cdr_parse_entry(med_entry_t *);
void cdr_truncate_call_id_suffix(char *);
#endif /* _CDR_H */

@ -584,11 +584,7 @@ gboolean medredis_fetch_callids(GQueue *output) {
*tmp = '\0';
}
// strip (potentially chained) suffices
if ((tmp = strstr(entry->str, PBXSUFFIX)) ||
(tmp = strstr(entry->str, XFERSUFFIX))) {
*tmp = '\0';
}
cdr_truncate_call_id_suffix(cid);
if (g_hash_table_insert(cid_table, cid, cid)) {
g_queue_push_tail(output, cid);

Loading…
Cancel
Save