mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 18:38:48 +00:00
Lift last MAXNAMELEN limit on -s argument.
This commit is contained in:
parent
21c17da7e6
commit
688a487570
3
CHANGES
3
CHANGES
@ -1,5 +1,6 @@
|
|||||||
23 October 2007
|
23 October 2007
|
||||||
|
|
||||||
|
* (nicm) Lift limit on session name passed with -s.
|
||||||
* (nicm) Show size in session/window lists.
|
* (nicm) Show size in session/window lists.
|
||||||
* (nicm) Pass tty up to server when client identifies and add a list-clients
|
* (nicm) Pass tty up to server when client identifies and add a list-clients
|
||||||
command to list connected clients.
|
command to list connected clients.
|
||||||
@ -150,5 +151,5 @@
|
|||||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||||
customisation.
|
customisation.
|
||||||
|
|
||||||
$Id: CHANGES,v 1.47 2007-10-23 09:36:19 nicm Exp $
|
$Id: CHANGES,v 1.48 2007-10-23 10:48:22 nicm Exp $
|
||||||
|
|
||||||
|
1
TODO
1
TODO
@ -47,7 +47,6 @@
|
|||||||
|
|
||||||
-- For 0.1 --------------------------------------------------------------------
|
-- For 0.1 --------------------------------------------------------------------
|
||||||
- man page
|
- man page
|
||||||
- get rid of MAXNAMELEN limits (sessid)
|
|
||||||
- commands:
|
- commands:
|
||||||
rename sessions
|
rename sessions
|
||||||
swap windows
|
swap windows
|
||||||
|
12
client-fn.c
12
client-fn.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client-fn.c,v 1.2 2007-10-03 12:34:16 nicm Exp $ */
|
/* $Id: client-fn.c,v 1.3 2007-10-23 10:48:22 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -24,15 +24,13 @@
|
|||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
client_fill_sessid(struct sessid *sid, char name[MAXNAMELEN])
|
client_fill_session(struct msg_command_data *data)
|
||||||
{
|
{
|
||||||
char *env, *ptr, buf[256];
|
char *env, *ptr, buf[256];
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
long long ll;
|
long long ll;
|
||||||
|
|
||||||
strlcpy(sid->name, name, sizeof sid->name);
|
data->pid = -1;
|
||||||
|
|
||||||
sid->pid = -1;
|
|
||||||
if ((env = getenv("TMUX")) == NULL)
|
if ((env = getenv("TMUX")) == NULL)
|
||||||
return;
|
return;
|
||||||
if ((ptr = strchr(env, ',')) == NULL)
|
if ((ptr = strchr(env, ',')) == NULL)
|
||||||
@ -45,12 +43,12 @@ client_fill_sessid(struct sessid *sid, char name[MAXNAMELEN])
|
|||||||
ll = strtonum(ptr + 1, 0, UINT_MAX, &errstr);
|
ll = strtonum(ptr + 1, 0, UINT_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
return;
|
return;
|
||||||
sid->idx = ll;
|
data->idx = ll;
|
||||||
|
|
||||||
ll = strtonum(buf, 0, LLONG_MAX, &errstr);
|
ll = strtonum(buf, 0, LLONG_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
return;
|
return;
|
||||||
sid->pid = ll;
|
data->pid = ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
28
server-fn.c
28
server-fn.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-fn.c,v 1.21 2007-10-19 10:21:35 nicm Exp $ */
|
/* $Id: server-fn.c,v 1.22 2007-10-23 10:48:23 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -23,33 +23,33 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/* Find session from sessid. */
|
/* Find session from command message. */
|
||||||
struct session *
|
struct session *
|
||||||
server_find_sessid(struct sessid *sid, char **cause)
|
server_extract_session(struct msg_command_data *data, char *name, char **cause)
|
||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
u_int i, n;
|
u_int i, n;
|
||||||
|
|
||||||
if (*sid->name != '\0') {
|
if (name != NULL) {
|
||||||
sid->name[(sizeof sid->name) - 1] = '\0';
|
if ((s = session_find(name)) == NULL) {
|
||||||
if ((s = session_find(sid->name)) == NULL) {
|
xasprintf(cause, "session not found: %s", name);
|
||||||
xasprintf(cause, "session not found: %s", sid->name);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sid->pid != -1) {
|
if (data->pid != -1) {
|
||||||
if (sid->pid != getpid()) {
|
if (data->pid != getpid()) {
|
||||||
xasprintf(cause, "wrong server: %lld", sid->pid);
|
xasprintf(cause, "wrong server: %lld", data->pid);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (sid->idx > ARRAY_LENGTH(&sessions)) {
|
if (data->idx > ARRAY_LENGTH(&sessions)) {
|
||||||
xasprintf(cause, "index out of range: %u", sid->idx);
|
xasprintf(cause, "index out of range: %u", data->idx);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if ((s = ARRAY_ITEM(&sessions, sid->idx)) == NULL) {
|
if ((s = ARRAY_ITEM(&sessions, data->idx)) == NULL) {
|
||||||
xasprintf(cause, "session doesn't exist: %u", sid->idx);
|
xasprintf(
|
||||||
|
cause, "session doesn't exist: %u", data->idx);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
return (s);
|
return (s);
|
||||||
|
16
server-msg.c
16
server-msg.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-msg.c,v 1.28 2007-10-23 09:36:19 nicm Exp $ */
|
/* $Id: server-msg.c,v 1.29 2007-10-23 10:48:23 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -108,11 +108,12 @@ server_msg_fn_command(struct hdr *hdr, struct client *c)
|
|||||||
struct msg_command_data data;
|
struct msg_command_data data;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
char *cause;
|
char *name, *cause;
|
||||||
|
|
||||||
if (hdr->size < sizeof data)
|
if (hdr->size < sizeof data)
|
||||||
fatalx("bad MSG_COMMAND size");
|
fatalx("bad MSG_COMMAND size");
|
||||||
buffer_read(c->in, &data, sizeof data);
|
buffer_read(c->in, &data, sizeof data);
|
||||||
|
name = cmd_recv_string(c->in);
|
||||||
|
|
||||||
cmd = cmd_recv(c->in);
|
cmd = cmd_recv(c->in);
|
||||||
log_debug("got command %s from client %d", cmd->entry->name, c->fd);
|
log_debug("got command %s from client %d", cmd->entry->name, c->fd);
|
||||||
@ -123,26 +124,29 @@ server_msg_fn_command(struct hdr *hdr, struct client *c)
|
|||||||
ctx.client = c;
|
ctx.client = c;
|
||||||
ctx.flags = 0;
|
ctx.flags = 0;
|
||||||
|
|
||||||
if (data.sid.pid != -1 && (cmd->entry->flags & CMD_CANTNEST)) {
|
if (data.pid != -1 && (cmd->entry->flags & CMD_CANTNEST)) {
|
||||||
server_msg_fn_command_error(&ctx, "sessions should be nested "
|
server_msg_fn_command_error(&ctx, "sessions should be nested "
|
||||||
"with care. unset $TMUX to force");
|
"with care. unset $TMUX to force");
|
||||||
return (0);
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd->entry->flags & CMD_NOSESSION)
|
if (cmd->entry->flags & CMD_NOSESSION)
|
||||||
ctx.session = NULL;
|
ctx.session = NULL;
|
||||||
else {
|
else {
|
||||||
ctx.session = server_find_sessid(&data.sid, &cause);
|
ctx.session = server_extract_session(&data, name, &cause);
|
||||||
if (ctx.session == NULL) {
|
if (ctx.session == NULL) {
|
||||||
server_msg_fn_command_error(&ctx, "%s", cause);
|
server_msg_fn_command_error(&ctx, "%s", cause);
|
||||||
xfree(cause);
|
xfree(cause);
|
||||||
return (0);
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_exec(cmd, &ctx);
|
cmd_exec(cmd, &ctx);
|
||||||
cmd_free(cmd);
|
cmd_free(cmd);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (name != NULL)
|
||||||
|
xfree(name);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
tmux.c
13
tmux.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.c,v 1.35 2007-10-20 09:57:08 nicm Exp $ */
|
/* $Id: tmux.c,v 1.36 2007-10-23 10:48:23 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -170,19 +170,17 @@ main(int argc, char **argv)
|
|||||||
struct hdr hdr;
|
struct hdr hdr;
|
||||||
const char *shell;
|
const char *shell;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char *path, *cause, name[MAXNAMELEN];
|
char *path, *cause, *name;
|
||||||
int n, opt;
|
int n, opt;
|
||||||
|
|
||||||
*name = '\0';
|
path = name = NULL;
|
||||||
path = NULL;
|
|
||||||
while ((opt = getopt(argc, argv, "S:s:v")) != EOF) {
|
while ((opt = getopt(argc, argv, "S:s:v")) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'S':
|
case 'S':
|
||||||
path = xstrdup(optarg);
|
path = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (strlcpy(name, optarg, sizeof name) >= sizeof name)
|
name = xstrdup(optarg);
|
||||||
errx(1, "session name too long: %s", optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
debug_level++;
|
debug_level++;
|
||||||
@ -225,10 +223,11 @@ main(int argc, char **argv)
|
|||||||
memset(&cctx, 0, sizeof cctx);
|
memset(&cctx, 0, sizeof cctx);
|
||||||
if (!(cmd->entry->flags & CMD_NOSESSION) ||
|
if (!(cmd->entry->flags & CMD_NOSESSION) ||
|
||||||
(cmd->entry->flags & CMD_CANTNEST))
|
(cmd->entry->flags & CMD_CANTNEST))
|
||||||
client_fill_sessid(&data.sid, name);
|
client_fill_session(&data);
|
||||||
if (client_init(path, &cctx, cmd->entry->flags & CMD_STARTSERVER) != 0)
|
if (client_init(path, &cctx, cmd->entry->flags & CMD_STARTSERVER) != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
b = buffer_create(BUFSIZ);
|
b = buffer_create(BUFSIZ);
|
||||||
|
cmd_send_string(b, name);
|
||||||
cmd_send(cmd, b);
|
cmd_send(cmd, b);
|
||||||
cmd_free(cmd);
|
cmd_free(cmd);
|
||||||
|
|
||||||
|
20
tmux.h
20
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.64 2007-10-23 10:21:59 nicm Exp $ */
|
/* $Id: tmux.h,v 1.65 2007-10-23 10:48:23 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -44,7 +44,6 @@ extern char *__progname;
|
|||||||
#define TTY_NAME_MAX 32
|
#define TTY_NAME_MAX 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAXNAMELEN 32
|
|
||||||
#define MAXTITLELEN 192
|
#define MAXTITLELEN 192
|
||||||
|
|
||||||
/* Fatal errors. */
|
/* Fatal errors. */
|
||||||
@ -283,13 +282,6 @@ enum hdrtype {
|
|||||||
MSG_PAUSE,
|
MSG_PAUSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Session identification. */
|
|
||||||
struct sessid {
|
|
||||||
long long pid; /* pid from $TMUX or -1 */
|
|
||||||
u_int idx; /* index from $TMUX */
|
|
||||||
char name[MAXNAMELEN]; /* empty for current */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Message header structure. */
|
/* Message header structure. */
|
||||||
struct hdr {
|
struct hdr {
|
||||||
enum hdrtype type;
|
enum hdrtype type;
|
||||||
@ -297,7 +289,10 @@ struct hdr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct msg_command_data {
|
struct msg_command_data {
|
||||||
struct sessid sid;
|
long long pid; /* pid from $TMUX or -1 */
|
||||||
|
u_int idx; /* index from $TMUX */
|
||||||
|
|
||||||
|
size_t namelen;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct msg_identify_data {
|
struct msg_identify_data {
|
||||||
@ -565,7 +560,7 @@ int client_msg_dispatch(struct client_ctx *, char **);
|
|||||||
void client_write_server(struct client_ctx *, enum hdrtype, void *, size_t);
|
void client_write_server(struct client_ctx *, enum hdrtype, void *, size_t);
|
||||||
void client_write_server2(
|
void client_write_server2(
|
||||||
struct client_ctx *, enum hdrtype, void *, size_t, void *, size_t);
|
struct client_ctx *, enum hdrtype, void *, size_t, void *, size_t);
|
||||||
void client_fill_sessid(struct sessid *, char [MAXNAMELEN]);
|
void client_fill_session(struct msg_command_data *);
|
||||||
|
|
||||||
/* key-bindings.c */
|
/* key-bindings.c */
|
||||||
extern struct bindings key_bindings;
|
extern struct bindings key_bindings;
|
||||||
@ -587,7 +582,8 @@ int server_start(char *);
|
|||||||
int server_msg_dispatch(struct client *);
|
int server_msg_dispatch(struct client *);
|
||||||
|
|
||||||
/* server-fn.c */
|
/* server-fn.c */
|
||||||
struct session *server_find_sessid(struct sessid *, char **);
|
struct session *server_extract_session(
|
||||||
|
struct msg_command_data *, char *, char **);
|
||||||
void server_write_client(
|
void server_write_client(
|
||||||
struct client *, enum hdrtype, const void *, size_t);
|
struct client *, enum hdrtype, const void *, size_t);
|
||||||
void server_write_session(
|
void server_write_session(
|
||||||
|
Loading…
Reference in New Issue
Block a user