version 1.3, 2009/07/26 12:58:44 |
version 1.4, 2009/10/10 10:02:48 |
|
|
int |
int |
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx) |
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct session *s; |
struct session *s; |
char *tim; |
struct session_group *sg; |
u_int i; |
char *tim, tmp[64]; |
time_t t; |
u_int i, idx; |
|
time_t t; |
|
|
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { |
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { |
s = ARRAY_ITEM(&sessions, i); |
s = ARRAY_ITEM(&sessions, i); |
if (s == NULL) |
if (s == NULL) |
continue; |
continue; |
|
|
|
sg = session_group_find(s); |
|
if (sg == NULL) |
|
*tmp = '\0'; |
|
else { |
|
idx = session_group_index(sg); |
|
xsnprintf(tmp, sizeof tmp, " (group %u)", idx); |
|
} |
|
|
t = s->tv.tv_sec; |
t = s->tv.tv_sec; |
tim = ctime(&t); |
tim = ctime(&t); |
*strchr(tim, '\n') = '\0'; |
*strchr(tim, '\n') = '\0'; |
|
|
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s", |
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s%s", |
s->name, winlink_count(&s->windows), tim, s->sx, s->sy, |
s->name, winlink_count(&s->windows), tim, s->sx, s->sy, |
s->flags & SESSION_UNATTACHED ? "" : " (attached)"); |
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)"); |
} |
} |
|
|
return (0); |
return (0); |