diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-02 18:08:17 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-02 18:08:17 +0000 |
commit | c7243b73cb3baaf6993d8a9dfb16c054c3978040 (patch) | |
tree | 1d67ee4c5cf764dc83245c79d27da52857b4a89d /server-fn.c | |
parent | 11ee55e755af67dc9155e956b4569c8fdeb11848 (diff) |
Move -s and -c down a level so handling them is the responsibility of the command (with some helper functions), rather than the top-level. This changes the action command syntax so that -s and -c must be after the command rather than before.
Diffstat (limited to 'server-fn.c')
-rw-r--r-- | server-fn.c | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/server-fn.c b/server-fn.c index 9da001f5..cf55e238 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,4 +1,4 @@ -/* $Id: server-fn.c,v 1.36 2007-12-06 09:46:23 nicm Exp $ */ +/* $Id: server-fn.c,v 1.37 2008-06-02 18:08:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -23,57 +23,6 @@ #include "tmux.h" -/* Find session from command message. */ -struct session * -server_extract_session(struct msg_command_data *data, char *name, char **cause) -{ - struct session *s; - u_int i, n; - - if (name != NULL) { - if ((s = session_find(name)) == NULL) { - xasprintf(cause, "session not found: %s", name); - return (NULL); - } - return (s); - } - - if (data->pid != -1) { - if (data->pid != getpid()) { - xasprintf(cause, "wrong server: %lld", data->pid); - return (NULL); - } - if (data->idx > ARRAY_LENGTH(&sessions)) { - xasprintf(cause, "index out of range: %d", data->idx); - return (NULL); - } - if ((s = ARRAY_ITEM(&sessions, data->idx)) == NULL) { - xasprintf( - cause, "session doesn't exist: %u", data->idx); - return (NULL); - } - return (s); - } - - s = NULL; - n = 0; - for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { - if (ARRAY_ITEM(&sessions, i) != NULL) { - s = ARRAY_ITEM(&sessions, i); - n++; - } - } - if (s == NULL) { - xasprintf(cause, "no sessions found"); - return (NULL); - } - if (n != 1) { - xasprintf(cause, "multiple sessions and session not specified"); - return (NULL); - } - return (s); -} - void server_write_client( struct client *c, enum hdrtype type, const void *buf, size_t len) |