Index: cli.c =================================================================== RCS file: /usr/cvsroot/asterisk/cli.c,v retrieving revision 1.92 diff -u -r1.92 cli.c --- cli.c 15 Jul 2005 23:00:46 -0000 1.92 +++ cli.c 19 Jul 2005 14:22:18 -0000 @@ -398,11 +398,14 @@ } static int handle_chanlist(int fd, int argc, char *argv[]) { -#define FORMAT_STRING "%15s (%-10s %-12s %-4d) %7s %-12s %-15s\n" -#define FORMAT_STRING2 "%15s (%-10s %-12s %-4s) %7s %-12s %-15s\n" +#define FORMAT_STRING "%-15.15s (%-12.12s %-15.15s %3d) %-7.7s %-12.12s %-20.20s %-15.15s %-15.15s %8.8s\n" +#define FORMAT_STRING2 "%-15.15s (%-12.12s %-15.15s %-3.3s) %-7.7s %-12.12s %-20.20s %-15.15s %-15.15s %8.8s\n" #define CONCISE_FORMAT_STRING "%s:%s:%s:%d:%s:%s:%s:%s:%s:%d\n" - struct ast_channel *c=NULL; + struct ast_channel *c = NULL, *bc = NULL; + char durbuf[10]; + time_t duration; + int durh, durm, durs; int numchans = 0; int concise = 0; if (argc < 2 || argc > 3) @@ -410,16 +413,26 @@ concise = (argc == 3 && (!strcasecmp(argv[2],"concise"))); if(!concise) - ast_cli(fd, FORMAT_STRING2, "Channel", "Context", "Extension", "Pri", "State", "Appl.", "Data"); + ast_cli(fd, FORMAT_STRING2, "Channel", "Context", "Extension", "Prio", "State", "Application", "Data", "CallerID", "Bridged to", "Duration"); while ( (c = ast_channel_walk_locked(c)) != NULL) { - if(concise) + bc = ast_bridged_channel(c); + if (c->cdr && !ast_tvzero(c->cdr->start)) { + duration = ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000; + durh = duration / 3600; + durm = (duration % 3600) / 60; + durs = duration % 60; + snprintf(durbuf, sizeof(durbuf), "%02d:%02d:%02d", durh, durm, durs); + } else + strcpy(durbuf, "-"); + if (concise) ast_cli(fd, CONCISE_FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state), c->appl ? c->appl : "(None)", c->data ? ( !ast_strlen_zero(c->data) ? c->data : "" ): "", (c->cid.cid_num && !ast_strlen_zero(c->cid.cid_num)) ? c->cid.cid_num : "", - (c->accountcode && !ast_strlen_zero(c->accountcode)) ? c->accountcode : "",c->amaflags); + (c->accountcode && !ast_strlen_zero(c->accountcode)) ? c->accountcode : "", c->amaflags); else ast_cli(fd, FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state), - c->appl ? c->appl : "(None)", c->data ? ( !ast_strlen_zero(c->data) ? c->data : "(Empty)" ): "(None)"); + c->appl ? c->appl : "(None)", c->data ? ( !ast_strlen_zero(c->data) ? c->data : "(Empty)" ): "(None)", + (c->cid.cid_num && !ast_strlen_zero(c->cid.cid_num)) ? c->cid.cid_num : "", bc ? bc->name : "(None)", durbuf); numchans++; ast_mutex_unlock(&c->lock);