summaryrefslogtreecommitdiffstats
path: root/cmd-lock-server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-04 02:03:41 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-04 02:03:41 +0000
commit96c37fa80a46e189b9b6535242aa1966f4d375c8 (patch)
tree38f3b6c86abbddd1388528b39f70380ee6661c54 /cmd-lock-server.c
parent55346b0d103016e8ee633e08e41b8b977b5904ef (diff)
Now that parsing is common, merge some of the small, related commands
together to use the same code. Also add some arguments (such as -n and -p) to some commands to match existing commands.
Diffstat (limited to 'cmd-lock-server.c')
-rw-r--r--cmd-lock-server.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/cmd-lock-server.c b/cmd-lock-server.c
index 347cc128..955de11f 100644
--- a/cmd-lock-server.c
+++ b/cmd-lock-server.c
@@ -25,7 +25,7 @@
#include "tmux.h"
/*
- * Lock server.
+ * Lock commands.
*/
int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
@@ -40,11 +40,45 @@ const struct cmd_entry cmd_lock_server_entry = {
cmd_lock_server_exec
};
+const struct cmd_entry cmd_lock_session_entry = {
+ "lock-session", "locks",
+ "t:", 0, 0,
+ CMD_TARGET_SESSION_USAGE,
+ 0,
+ NULL,
+ NULL,
+ cmd_lock_server_exec
+};
+
+const struct cmd_entry cmd_lock_client_entry = {
+ "lock-client", "lockc",
+ "t:", 0, 0,
+ CMD_TARGET_CLIENT_USAGE,
+ 0,
+ NULL,
+ NULL,
+ cmd_lock_server_exec
+};
+
/* ARGSUSED */
int
-cmd_lock_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
+cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
{
- server_lock();
+ struct args *args = self->args;
+ struct client *c;
+ struct session *s;
+
+ if (self->entry == &cmd_lock_server_entry)
+ server_lock();
+ else if (self->entry == &cmd_lock_session_entry) {
+ if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
+ return (-1);
+ server_lock_session(s);
+ } else {
+ if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+ return (-1);
+ server_lock_client(c);
+ }
recalculate_sizes();
return (0);