summaryrefslogtreecommitdiffstats
path: root/cmd-server-info.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-12-21 22:37:59 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-12-21 22:37:59 +0000
commitacf13ce9784111ca1e42ffc8206e752668476859 (patch)
tree49ccd47b2e589a27dab8657d516133205f07f393 /cmd-server-info.c
parent1b8488ee75458c4561089bf056c0e911de958428 (diff)
Store sessions in an RB tree by name rather than a list, this is tidier
and allows them to easily be shown sorted in various lists (list-sessions/choose-sessions). Keep a session index which is used in a couple of places internally but make it an ever-increasing number rather than filling in gaps with new sessions.
Diffstat (limited to 'cmd-server-info.c')
-rw-r--r--cmd-server-info.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/cmd-server-info.c b/cmd-server-info.c
index 60acbdf8..a114bf05 100644
--- a/cmd-server-info.c
+++ b/cmd-server-info.c
@@ -81,8 +81,6 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
else
ctx->print(ctx, "configuration file not specified");
ctx->print(ctx, "protocol version is %d", PROTOCOL_VERSION);
- ctx->print(ctx, "%u clients, %u sessions",
- ARRAY_LENGTH(&clients), ARRAY_LENGTH(&sessions));
ctx->print(ctx, "%s", "");
ctx->print(ctx, "Clients:");
@@ -101,19 +99,14 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
ctx->print(ctx, "Sessions: [%zu/%zu]",
sizeof (struct grid_cell), sizeof (struct grid_utf8));
- for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
- s = ARRAY_ITEM(&sessions, i);
- if (s == NULL)
- continue;
-
+ RB_FOREACH(s, sessions, &sessions) {
t = s->creation_time.tv_sec;
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
ctx->print(ctx, "%2u: %s: %u windows (created %s) [%ux%u] "
- "[flags=0x%x, references=%u]", i, s->name,
- winlink_count(&s->windows), tim, s->sx, s->sy, s->flags,
- s->references);
+ "[flags=0x%x]", s->idx, s->name,
+ winlink_count(&s->windows), tim, s->sx, s->sy, s->flags);
RB_FOREACH(wl, winlinks, &s->windows) {
w = wl->window;
ctx->print(ctx, "%4u: %s [%ux%u] [flags=0x%x, "