/* Set caller ID */ callerid_len = 10; if ((i->cd.call_source_alias != NULL) && (strlen(i->cd.call_source_alias) > 0)) callerid_len += strlen(i->cd.call_source_alias); if ((i->cd.call_source_e164 != NULL) && (strlen(i->cd.call_source_e164) > 0)) callerid_len += strlen(i->cd.call_source_e164); tmp->callerid = (char *)malloc(callerid_len); if (tmp->callerid != NULL) { memset(tmp->callerid, 0, callerid_len); if ((i->cd.call_source_alias != NULL) && (strlen(i->cd.call_source_alias) > 0)) { dnamelen = strcspn(i->cd.call_source_alias, "(["); if (dnamelen < strlen(i->cd.call_source_alias)) { strncat(tmp->callerid, "\"", 1); strncat(tmp->callerid, i->cd.call_source_alias, dnamelen); strncat(tmp->callerid, "\"", 1); } else { strncat(tmp->callerid, "\"\"", 2); dnamelen = 0; } if ((i->cd.call_source_e164 != NULL) && (strlen(i->cd.call_source_e164) > 0)) { strncat(tmp->callerid, " <", 2); strncat(tmp->callerid, i->cd.call_source_e164, strlen(i->cd.call_source_e164)); strncat(tmp->callerid, ">", 1); } else { strncat(tmp->callerid, "<>", 2); } } else if ((i->cd.call_source_e164 != NULL) && (strlen(i->cd.call_source_e164) > 0)) memcpy(tmp->callerid, i->cd.call_source_e164, strlen(i->cd.call_source_e164)); /* Set ANI */ tmp->ani = strdup(tmp->callerid); }