/* find the beginning bracket */ p = strchr(chan->callerid, '<'); if (p) { p++; /* find the ending bracket */ e = strchr(p, '>'); } /* if there's ending, copy the value */ if (e) { len = e-p; account->callerid = malloc(len + 1); strncpy(account->callerid, p, len); account->callerid[len] = '\0'; } else { account->callerid = chan->callerid; }