mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Change server-info format.
This commit is contained in:
parent
a49e9b5b00
commit
fd05d07c2b
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client-fn.c,v 1.4 2008-07-01 20:35:16 nicm Exp $ */
|
/* $Id: client-fn.c,v 1.5 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -61,7 +61,7 @@ client_write_server(
|
|||||||
hdr.size = len;
|
hdr.size = len;
|
||||||
buffer_write(cctx->srv_out, &hdr, sizeof hdr);
|
buffer_write(cctx->srv_out, &hdr, sizeof hdr);
|
||||||
|
|
||||||
if (buf != NULL)
|
if (buf != NULL && len > 0)
|
||||||
buffer_write(cctx->srv_out, buf, len);
|
buffer_write(cctx->srv_out, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +75,8 @@ client_write_server2(struct client_ctx *cctx,
|
|||||||
hdr.size = len1 + len2;
|
hdr.size = len1 + len2;
|
||||||
buffer_write(cctx->srv_out, &hdr, sizeof hdr);
|
buffer_write(cctx->srv_out, &hdr, sizeof hdr);
|
||||||
|
|
||||||
if (buf1 != NULL)
|
if (buf1 != NULL && len1 > 0)
|
||||||
buffer_write(cctx->srv_out, buf1, len1);
|
buffer_write(cctx->srv_out, buf1, len1);
|
||||||
if (buf2 != NULL)
|
if (buf2 != NULL && len2 > 0)
|
||||||
buffer_write(cctx->srv_out, buf2, len2);
|
buffer_write(cctx->srv_out, buf2, len2);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-list-sessions.c,v 1.16 2008-08-28 17:45:25 nicm Exp $ */
|
/* $Id: cmd-list-sessions.c,v 1.17 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -45,9 +45,8 @@ void
|
|||||||
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;
|
||||||
struct winlink *wl;
|
|
||||||
char *tim;
|
char *tim;
|
||||||
u_int i, n;
|
u_int i;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
||||||
@ -55,15 +54,12 @@ cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
n = 0;
|
|
||||||
RB_FOREACH(wl, winlinks, &s->windows)
|
|
||||||
n++;
|
|
||||||
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"
|
ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]",
|
||||||
" (created %s) [%ux%u]", s->name, n, tim, s->sx, s->sy);
|
s->name, winlink_count(&s->windows), tim, s->sx, s->sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->cmdclient != NULL)
|
if (ctx->cmdclient != NULL)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd-server-info.c,v 1.5 2009-01-10 12:52:57 nicm Exp $ */
|
/* $Id: cmd-server-info.c,v 1.6 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -17,8 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vis.h>
|
#include <vis.h>
|
||||||
@ -48,33 +50,60 @@ void
|
|||||||
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct tty_term *term;
|
struct tty_term *term;
|
||||||
struct client *cmdclient;
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
struct tty_code *code;
|
struct tty_code *code;
|
||||||
struct tty_term_code_entry *ent;
|
struct tty_term_code_entry *ent;
|
||||||
|
struct utsname un;
|
||||||
u_int i;
|
u_int i;
|
||||||
char s[BUFSIZ];
|
char out[BUFSIZ];
|
||||||
|
char *tim;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
ctx->print(ctx, "tmux " BUILD
|
tim = ctime(&start_time);
|
||||||
", pid %ld, started %s", (long) getpid(), ctime(&start_time));
|
*strchr(tim, '\n') = '\0';
|
||||||
|
ctx->print(ctx,
|
||||||
|
"tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim);
|
||||||
ctx->print(ctx, "socket path %s, debug level %d%s",
|
ctx->print(ctx, "socket path %s, debug level %d%s",
|
||||||
socket_path, debug_level, be_quiet ? ", quiet" : "");
|
socket_path, debug_level, be_quiet ? ", quiet" : "");
|
||||||
|
if (uname(&un) == 0) {
|
||||||
|
ctx->print(ctx, "system is %s %s %s %s",
|
||||||
|
un.sysname, un.release, un.version, un.machine);
|
||||||
|
}
|
||||||
if (cfg_file != NULL)
|
if (cfg_file != NULL)
|
||||||
ctx->print(ctx, "configuration file %s", cfg_file);
|
ctx->print(ctx, "configuration file is %s", cfg_file);
|
||||||
else
|
else
|
||||||
ctx->print(ctx, "configuration file not specified");
|
ctx->print(ctx, "configuration file not specified");
|
||||||
ctx->print(ctx, "%u clients, %u sessions",
|
ctx->print(ctx, "%u clients, %u sessions",
|
||||||
ARRAY_LENGTH(&clients), ARRAY_LENGTH(&sessions));
|
ARRAY_LENGTH(&clients), ARRAY_LENGTH(&sessions));
|
||||||
ctx->print(ctx, "");
|
ctx->print(ctx, "");
|
||||||
|
|
||||||
cmdclient = ctx->cmdclient;
|
|
||||||
ctx->cmdclient = NULL;
|
|
||||||
|
|
||||||
ctx->print(ctx, "Clients:");
|
ctx->print(ctx, "Clients:");
|
||||||
cmd_list_clients_entry.exec(self, ctx);
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ctx->print(ctx, " %2d: %s (%d, %d): %s [%ux%u %s] "
|
||||||
|
"[flags=0x%x]", i, c->tty.path, c->fd, c->tty.fd,
|
||||||
|
c->session->name, c->sx, c->sy, c->tty.termname, c->flags);
|
||||||
|
}
|
||||||
ctx->print(ctx, "");
|
ctx->print(ctx, "");
|
||||||
|
|
||||||
ctx->print(ctx, "Sessions:");
|
ctx->print(ctx, "Sessions:");
|
||||||
cmd_list_sessions_entry.exec(self, ctx);
|
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
||||||
|
s = ARRAY_ITEM(&sessions, i);
|
||||||
|
if (s == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
t = s->tv.tv_sec;
|
||||||
|
tim = ctime(&t);
|
||||||
|
*strchr(tim, '\n') = '\0';
|
||||||
|
|
||||||
|
ctx->print(ctx, " %2d: %s: %u windows (created %s) [%ux%u] "
|
||||||
|
"[flags=0x%x]", i, s->name, winlink_count(&s->windows),
|
||||||
|
tim, s->sx, s->sy, s->flags);
|
||||||
|
}
|
||||||
ctx->print(ctx, "");
|
ctx->print(ctx, "");
|
||||||
|
|
||||||
ctx->print(ctx, "Terminals:");
|
ctx->print(ctx, "Terminals:");
|
||||||
@ -86,23 +115,23 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
code = &term->codes[ent->code];
|
code = &term->codes[ent->code];
|
||||||
switch (code->type) {
|
switch (code->type) {
|
||||||
case TTYCODE_NONE:
|
case TTYCODE_NONE:
|
||||||
ctx->print(ctx, " %2d,%s: [missing]",
|
ctx->print(ctx, " %2d: %s: [missing]",
|
||||||
ent->code, ent->name);
|
ent->code, ent->name);
|
||||||
break;
|
break;
|
||||||
case TTYCODE_STRING:
|
case TTYCODE_STRING:
|
||||||
strnvis(s, code->value.string,
|
strnvis(out, code->value.string,
|
||||||
sizeof s, VIS_OCTAL|VIS_WHITE);
|
sizeof out, VIS_OCTAL|VIS_WHITE);
|
||||||
s[(sizeof s) - 1] = '\0';
|
out[(sizeof out) - 1] = '\0';
|
||||||
|
|
||||||
ctx->print(ctx, " %2d,%s: (string) %s",
|
ctx->print(ctx, " %2d: %s: (string) %s",
|
||||||
ent->code, ent->name, s);
|
ent->code, ent->name, out);
|
||||||
break;
|
break;
|
||||||
case TTYCODE_NUMBER:
|
case TTYCODE_NUMBER:
|
||||||
ctx->print(ctx, " %2d,%s: (number) %d",
|
ctx->print(ctx, " %2d: %s: (number) %d",
|
||||||
ent->code, ent->name, code->value.number);
|
ent->code, ent->name, code->value.number);
|
||||||
break;
|
break;
|
||||||
case TTYCODE_FLAG:
|
case TTYCODE_FLAG:
|
||||||
ctx->print(ctx, " %2d,%s: (flag) %s",
|
ctx->print(ctx, " %2d: %s: (flag) %s",
|
||||||
ent->code, ent->name,
|
ent->code, ent->name,
|
||||||
code->value.flag ? "true" : "false");
|
code->value.flag ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
@ -111,6 +140,6 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
ctx->print(ctx, "");
|
ctx->print(ctx, "");
|
||||||
|
|
||||||
if (cmdclient != NULL)
|
if (ctx->cmdclient != NULL)
|
||||||
server_write_client(cmdclient, MSG_EXIT, NULL, 0);
|
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-fn.c,v 1.51 2009-01-06 15:37:15 nicm Exp $ */
|
/* $Id: server-fn.c,v 1.52 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -102,7 +102,7 @@ server_write_client(
|
|||||||
hdr.size = len;
|
hdr.size = len;
|
||||||
|
|
||||||
buffer_write(c->out, &hdr, sizeof hdr);
|
buffer_write(c->out, &hdr, sizeof hdr);
|
||||||
if (buf != NULL)
|
if (buf != NULL && len > 0)
|
||||||
buffer_write(c->out, buf, len);
|
buffer_write(c->out, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: session.c,v 1.47 2008-12-08 16:19:51 nicm Exp $ */
|
/* $Id: session.c,v 1.48 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -115,6 +115,7 @@ session_create(const char *name, const char *cmd, u_int sx, u_int sy)
|
|||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
s = xmalloc(sizeof *s);
|
s = xmalloc(sizeof *s);
|
||||||
|
s->flags = 0;
|
||||||
if (gettimeofday(&s->tv, NULL) != 0)
|
if (gettimeofday(&s->tv, NULL) != 0)
|
||||||
fatal("gettimeofday");
|
fatal("gettimeofday");
|
||||||
s->curw = NULL;
|
s->curw = NULL;
|
||||||
|
4
tmux.c
4
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.c,v 1.88 2009-01-10 01:51:22 nicm Exp $ */
|
/* $Id: tmux.c,v 1.89 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -356,6 +356,7 @@ main(int argc, char **argv)
|
|||||||
fatalx("bad MSG_PRINT size");
|
fatalx("bad MSG_PRINT size");
|
||||||
log_info("%.*s",
|
log_info("%.*s",
|
||||||
(int) hdr.size, BUFFER_OUT(cctx.srv_in));
|
(int) hdr.size, BUFFER_OUT(cctx.srv_in));
|
||||||
|
if (hdr.size != 0)
|
||||||
buffer_remove(cctx.srv_in, hdr.size);
|
buffer_remove(cctx.srv_in, hdr.size);
|
||||||
goto restart;
|
goto restart;
|
||||||
case MSG_ERROR:
|
case MSG_ERROR:
|
||||||
@ -363,6 +364,7 @@ main(int argc, char **argv)
|
|||||||
fatalx("bad MSG_ERROR size");
|
fatalx("bad MSG_ERROR size");
|
||||||
log_warnx("%.*s",
|
log_warnx("%.*s",
|
||||||
(int) hdr.size, BUFFER_OUT(cctx.srv_in));
|
(int) hdr.size, BUFFER_OUT(cctx.srv_in));
|
||||||
|
if (hdr.size != 0)
|
||||||
buffer_remove(cctx.srv_in, hdr.size);
|
buffer_remove(cctx.srv_in, hdr.size);
|
||||||
n = 1;
|
n = 1;
|
||||||
goto out;
|
goto out;
|
||||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.214 2009-01-10 01:51:22 nicm Exp $ */
|
/* $Id: tmux.h,v 1.215 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1331,6 +1331,7 @@ RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
|
|||||||
struct winlink *winlink_find_by_index(struct winlinks *, int);
|
struct winlink *winlink_find_by_index(struct winlinks *, int);
|
||||||
struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
|
struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
|
||||||
int winlink_next_index(struct winlinks *);
|
int winlink_next_index(struct winlinks *);
|
||||||
|
u_int winlink_count(struct winlinks *);
|
||||||
struct winlink *winlink_add(struct winlinks *, struct window *, int);
|
struct winlink *winlink_add(struct winlinks *, struct window *, int);
|
||||||
void winlink_remove(struct winlinks *, struct winlink *);
|
void winlink_remove(struct winlinks *, struct winlink *);
|
||||||
struct winlink *winlink_next(struct winlinks *, struct winlink *);
|
struct winlink *winlink_next(struct winlinks *, struct winlink *);
|
||||||
|
15
window.c
15
window.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: window.c,v 1.52 2008-12-08 16:19:51 nicm Exp $ */
|
/* $Id: window.c,v 1.53 2009-01-10 14:43:43 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -99,6 +99,19 @@ winlink_next_index(struct winlinks *wwl)
|
|||||||
fatalx("no free indexes");
|
fatalx("no free indexes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_int
|
||||||
|
winlink_count(struct winlinks *wwl)
|
||||||
|
{
|
||||||
|
struct winlink *wl;
|
||||||
|
u_int n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
RB_FOREACH(wl, winlinks, wwl)
|
||||||
|
n++;
|
||||||
|
|
||||||
|
return (n);
|
||||||
|
}
|
||||||
|
|
||||||
struct winlink *
|
struct winlink *
|
||||||
winlink_add(struct winlinks *wwl, struct window *w, int idx)
|
winlink_add(struct winlinks *wwl, struct window *w, int idx)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user