diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-27 09:52:03 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-27 09:52:03 +0000 |
commit | 22990a6595fdff840010aa6df9a60ada61331b5e (patch) | |
tree | 48fa49a39ca8ba91652d9e5bbdcc7a942462c183 /server-msg.c | |
parent | 3fa8f1636486420b9f27b129dbd0f36015d4c24b (diff) |
New session selection rules:
- find by name if given
- otherwise try current index from $TMUX
- otherwise if only one session, use it
- otherwise error
Diffstat (limited to 'server-msg.c')
-rw-r--r-- | server-msg.c | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/server-msg.c b/server-msg.c index 0f8d092d..4d84a3d3 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.4 2007-09-26 18:50:49 nicm Exp $ */ +/* $Id: server-msg.c,v 1.5 2007-09-27 09:52:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -138,9 +138,7 @@ int server_msg_fn_attach(struct hdr *hdr, struct client *c) { struct attach_data data; - char *msg; - struct session *s; - u_int i; + char *cause; if (c->session != NULL) return (0); @@ -155,23 +153,9 @@ server_msg_fn_attach(struct hdr *hdr, struct client *c) if (c->sy == 0) c->sy = 25; - if (*data.name != '\0') { - if ((c->session = session_find(data.name)) == NULL) - xasprintf(&msg, "session not found: %s", data.name); - } else { - /* Find the oldest session. */ - for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { - if ((s = ARRAY_ITEM(&sessions, i)) == NULL) - continue; - if (c->session == NULL || s->tim < c->session->tim) - c->session = s; - } - if (c->session == NULL) - xasprintf(&msg, "no sessions found"); - } - if (c->session == NULL) { - server_write_client(c, MSG_ERROR, msg, strlen(msg)); - xfree(msg); + if ((c->session = server_find_sessid(&data.sid, &cause)) == NULL) { + server_write_client(c, MSG_ERROR, cause, strlen(cause)); + xfree(cause); return (0); } @@ -361,15 +345,15 @@ server_msg_fn_windows(struct hdr *hdr, struct client *c) struct session *s; struct window *w; u_int i; + char *cause; if (hdr->size != sizeof data) fatalx("bad MSG_WINDOWS size"); buffer_read(c->in, &data, hdr->size); - s = session_find(data.name); - if (s == NULL) { - data.windows = 0; - server_write_client(c, MSG_WINDOWS, &data, sizeof data); + if ((s = server_find_sessid(&data.sid, &cause)) == NULL) { + server_write_client(c, MSG_ERROR, cause, strlen(cause)); + xfree(cause); return (0); } |