mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 16:43:11 +01:00
Sync OpenBSD patchset 436:
Merge prepare_cmd into main as it is short and only called once.
This commit is contained in:
parent
9260888d1c
commit
dbefea339f
38
tmux.c
38
tmux.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.c,v 1.179 2009-10-23 17:32:26 tcunha Exp $ */
|
||||
/* $Id: tmux.c,v 1.180 2009-10-23 17:40:23 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -60,7 +60,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 *);
|
||||
|
||||
@ -291,26 +290,6 @@ makesockpath(const char *label)
|
||||
return (path);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -322,6 +301,7 @@ main(int argc, char **argv)
|
||||
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;
|
||||
@ -538,8 +518,20 @@ main(int argc, char **argv)
|
||||
msg = MSG_SHELL;
|
||||
buf = NULL;
|
||||
len = 0;
|
||||
} else if (prepare_cmd(&msg, &buf, &len, argc, argv) != 0)
|
||||
} 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;
|
||||
|
Loading…
Reference in New Issue
Block a user