summaryrefslogtreecommitdiff
path: root/src/ua.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-07-26 23:38:03 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-07-26 23:38:03 +0200
commit49ea18057b64e2a806d6799bc2aa87b30491634e (patch)
tree6b407138e2f94c2a14eedd6dc97b2f184ab82c38 /src/ua.c
parentff3961ad2920ba674272b4f842f4456ed685a4a7 (diff)
add '@' command to switch calls using line numbers
1. for a given UA, each call has a unique line number starting from 1 2. the list of calls is sorted in an arbitrary order, but the last list element indicates "current call" 3. the '@' command takes a numeric argument which is the line-number of the wanted call
Diffstat (limited to 'src/ua.c')
-rw-r--r--src/ua.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/ua.c b/src/ua.c
index 35626f7..41a80e7 100644
--- a/src/ua.c
+++ b/src/ua.c
@@ -1545,21 +1545,35 @@ int ua_print_sip_status(struct re_printf *pf, void *unused)
*/
int ua_print_calls(struct re_printf *pf, const struct ua *ua)
{
- struct le *le;
+ uint32_t n, count=0;
+ uint32_t linenum;
int err = 0;
+
if (!ua) {
err |= re_hprintf(pf, "\n--- No active calls ---\n");
return err;
}
+ n = list_count(&ua->calls);
+
err |= re_hprintf(pf, "\n--- List of active calls (%u): ---\n",
- list_count(&ua->calls));
+ n);
+
+ for (linenum=CALL_LINENUM_MIN; linenum<CALL_LINENUM_MAX; linenum++) {
- for (le = ua->calls.head; le; le = le->next) {
+ const struct call *call;
- const struct call *call = le->data;
+ call = call_find_linenum(&ua->calls, linenum);
+ if (call) {
+ ++count;
- err |= re_hprintf(pf, " %H\n", call_info, call);
+ err |= re_hprintf(pf, " %c %H\n",
+ call == ua_call(ua) ? '>' : ' ',
+ call_info, call);
+ }
+
+ if (count >= n)
+ break;
}
err |= re_hprintf(pf, "\n");