summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/tmux.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 9d5c46273b5..fe9fc0aad0c 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.50 2009/10/21 20:11:47 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.51 2009/10/22 10:04:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -55,7 +55,6 @@ int login_shell;
__dead void usage(void);
void fill_session(struct msg_command_data *);
char *makesockpath(const char *);
-int prepare_cmd(enum msgtype *, void **, size_t *, int, char **);
int dispatch_imsg(struct imsgbuf *, const char *, int *);
__dead void shell_exec(const char *, const char *);
@@ -283,41 +282,22 @@ makesockpath(const char *label)
}
int
-prepare_cmd(enum msgtype *msg, void **buf, size_t *len, int argc, char **argv)
-{
- static struct msg_command_data cmddata;
-
- fill_session(&cmddata);
-
- cmddata.argc = argc;
- if (cmd_pack_argv(argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
- log_warnx("command too long");
- return (-1);
- }
-
- *buf = &cmddata;
- *len = sizeof cmddata;
-
- *msg = MSG_COMMAND;
- return (0);
-}
-
-int
main(int argc, char **argv)
{
- struct cmd_list *cmdlist;
- struct cmd *cmd;
- struct pollfd pfd;
- enum msgtype msg;
- struct passwd *pw;
- struct options *so, *wo;
- struct keylist *keylist;
- struct imsgbuf *ibuf;
- char *s, *shellcmd, *path, *label, *home, *cause;
- char cwd[MAXPATHLEN], **var;
- void *buf;
- size_t len;
- int nfds, retcode, opt, flags, cmdflags = 0;
+ struct cmd_list *cmdlist;
+ struct cmd *cmd;
+ struct pollfd pfd;
+ enum msgtype msg;
+ struct passwd *pw;
+ struct options *so, *wo;
+ struct keylist *keylist;
+ struct imsgbuf *ibuf;
+ struct msg_command_data cmddata;
+ char *s, *shellcmd, *path, *label, *home, *cause;
+ char cwd[MAXPATHLEN], **var;
+ void *buf;
+ size_t len;
+ int nfds, retcode, opt, flags, cmdflags = 0;
flags = 0;
shellcmd = label = path = NULL;
@@ -529,8 +509,20 @@ main(int argc, char **argv)
msg = MSG_SHELL;
buf = NULL;
len = 0;
- } else if (prepare_cmd(&msg, &buf, &len, argc, argv) != 0)
- exit(1);
+ } else {
+ fill_session(&cmddata);
+
+ cmddata.argc = argc;
+ if (cmd_pack_argv(
+ argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
+ log_warnx("command too long");
+ exit(1);
+ }
+
+ msg = MSG_COMMAND;
+ buf = &cmddata;
+ len = sizeof cmddata;
+ }
if (shellcmd != NULL)
cmdflags |= CMD_STARTSERVER;