Sync OpenBSD patchset 831:

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.
This commit is contained in:
Tiago Cunha
2011-01-07 15:02:38 +00:00
parent b2b5d88f3f
commit ca413cf270
17 changed files with 239 additions and 588 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-lock-server.c,v 1.10 2011-01-07 14:45:34 tcunha Exp $ */
/* $Id: cmd-lock-server.c,v 1.11 2011-01-07 15:02:38 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -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);