mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 01:18:52 +00:00
Merge prepare_cmd into main as it is short and only called once.
This commit is contained in:
parent
284b94662a
commit
eb0c33cba4
64
tmux.c
64
tmux.c
@ -55,7 +55,6 @@ int login_shell;
|
|||||||
__dead void usage(void);
|
__dead void usage(void);
|
||||||
void fill_session(struct msg_command_data *);
|
void fill_session(struct msg_command_data *);
|
||||||
char *makesockpath(const char *);
|
char *makesockpath(const char *);
|
||||||
int prepare_cmd(enum msgtype *, void **, size_t *, int, char **);
|
|
||||||
int dispatch_imsg(struct imsgbuf *, const char *, int *);
|
int dispatch_imsg(struct imsgbuf *, const char *, int *);
|
||||||
__dead void shell_exec(const char *, const char *);
|
__dead void shell_exec(const char *, const char *);
|
||||||
|
|
||||||
@ -282,42 +281,23 @@ makesockpath(const char *label)
|
|||||||
return (path);
|
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
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
struct pollfd pfd;
|
struct pollfd pfd;
|
||||||
enum msgtype msg;
|
enum msgtype msg;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct options *so, *wo;
|
struct options *so, *wo;
|
||||||
struct keylist *keylist;
|
struct keylist *keylist;
|
||||||
struct imsgbuf *ibuf;
|
struct imsgbuf *ibuf;
|
||||||
char *s, *shellcmd, *path, *label, *home, *cause;
|
struct msg_command_data cmddata;
|
||||||
char cwd[MAXPATHLEN], **var;
|
char *s, *shellcmd, *path, *label, *home, *cause;
|
||||||
void *buf;
|
char cwd[MAXPATHLEN], **var;
|
||||||
size_t len;
|
void *buf;
|
||||||
int nfds, retcode, opt, flags, cmdflags = 0;
|
size_t len;
|
||||||
|
int nfds, retcode, opt, flags, cmdflags = 0;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
shellcmd = label = path = NULL;
|
shellcmd = label = path = NULL;
|
||||||
@ -529,8 +509,20 @@ main(int argc, char **argv)
|
|||||||
msg = MSG_SHELL;
|
msg = MSG_SHELL;
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
} else if (prepare_cmd(&msg, &buf, &len, argc, argv) != 0)
|
} else {
|
||||||
exit(1);
|
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)
|
if (shellcmd != NULL)
|
||||||
cmdflags |= CMD_STARTSERVER;
|
cmdflags |= CMD_STARTSERVER;
|
||||||
|
Loading…
Reference in New Issue
Block a user