diff options
author | nicm <nicm> | 2015-04-24 23:17:11 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-04-24 23:17:11 +0000 |
commit | aeedb464a6ee038289ddcfefae437928ab020cb1 (patch) | |
tree | 0428a0446bd50d08e4b0fe6741644e36d8b1a071 /cmd-list-clients.c | |
parent | 583b4ab72b7bf66fda8ab63a08fe435483de5e5a (diff) | |
download | rtmux-aeedb464a6ee038289ddcfefae437928ab020cb1.tar.gz rtmux-aeedb464a6ee038289ddcfefae437928ab020cb1.tar.bz2 rtmux-aeedb464a6ee038289ddcfefae437928ab020cb1.zip |
Convert clients list into a TAILQ.
Diffstat (limited to 'cmd-list-clients.c')
-rw-r--r-- | cmd-list-clients.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/cmd-list-clients.c b/cmd-list-clients.c index 893a6d05..372b5283 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -51,7 +51,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq) struct session *s; struct format_tree *ft; const char *template; - u_int i; + u_int idx; char *line; if (args_has(args, 't')) { @@ -64,16 +64,13 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq) if ((template = args_get(args, 'F')) == NULL) template = LIST_CLIENTS_TEMPLATE; - for (i = 0; i < ARRAY_LENGTH(&clients); i++) { - c = ARRAY_ITEM(&clients, i); - if (c == NULL || c->session == NULL) - continue; - - if (s != NULL && s != c->session) + idx = 0; + TAILQ_FOREACH(c, &clients, entry) { + if (c->session == NULL || (s != NULL && s != c->session)) continue; ft = format_create(); - format_add(ft, "line", "%u", i); + format_add(ft, "line", "%u", idx); format_defaults(ft, c, NULL, NULL, NULL); line = format_expand(ft, template); @@ -81,6 +78,8 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq) free(line); format_free(ft); + + idx++; } return (CMD_RETURN_NORMAL); |