mirror of
https://github.com/tmux/tmux.git
synced 2025-01-11 18:58:47 +00:00
Sync OpenBSD patchset 435:
Tidy identify message send into a separate function.
This commit is contained in:
parent
dc8b7d6b03
commit
eaa188bb63
66
client.c
66
client.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: client.c,v 1.79 2009-10-23 17:32:26 tcunha Exp $ */
|
/* $OpenBSD: client.c,v 1.26 2009/10/21 21:11:55 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -36,6 +36,7 @@
|
|||||||
struct imsgbuf client_ibuf;
|
struct imsgbuf client_ibuf;
|
||||||
const char *client_exitmsg;
|
const char *client_exitmsg;
|
||||||
|
|
||||||
|
void client_send_identify(int);
|
||||||
void client_send_environ(void);
|
void client_send_environ(void);
|
||||||
void client_write_server(enum msgtype, void *, size_t);
|
void client_write_server(enum msgtype, void *, size_t);
|
||||||
int client_dispatch(void);
|
int client_dispatch(void);
|
||||||
@ -44,15 +45,12 @@ void client_suspend(void);
|
|||||||
struct imsgbuf *
|
struct imsgbuf *
|
||||||
client_init(char *path, int cmdflags, int flags)
|
client_init(char *path, int cmdflags, int flags)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct msg_identify_data data;
|
size_t size;
|
||||||
struct winsize ws;
|
int fd, mode;
|
||||||
size_t size;
|
|
||||||
int fd, fd2, mode;
|
|
||||||
char *term;
|
|
||||||
#ifdef HAVE_SETPROCTITLE
|
#ifdef HAVE_SETPROCTITLE
|
||||||
char rpathbuf[MAXPATHLEN];
|
char rpathbuf[MAXPATHLEN];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SETPROCTITLE
|
#ifdef HAVE_SETPROCTITLE
|
||||||
@ -107,26 +105,8 @@ server_started:
|
|||||||
|
|
||||||
if (cmdflags & CMD_SENDENVIRON)
|
if (cmdflags & CMD_SENDENVIRON)
|
||||||
client_send_environ();
|
client_send_environ();
|
||||||
if (isatty(STDIN_FILENO)) {
|
if (isatty(STDIN_FILENO))
|
||||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
client_send_identify(flags);
|
||||||
fatal("ioctl(TIOCGWINSZ)");
|
|
||||||
data.flags = flags;
|
|
||||||
|
|
||||||
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
|
||||||
*data.cwd = '\0';
|
|
||||||
|
|
||||||
*data.term = '\0';
|
|
||||||
if ((term = getenv("TERM")) != NULL) {
|
|
||||||
if (strlcpy(data.term,
|
|
||||||
term, sizeof data.term) >= sizeof data.term)
|
|
||||||
*data.term = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd2 = dup(STDIN_FILENO)) == -1)
|
|
||||||
fatal("dup failed");
|
|
||||||
imsg_compose(&client_ibuf, MSG_IDENTIFY,
|
|
||||||
PROTOCOL_VERSION, -1, fd2, &data, sizeof data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (&client_ibuf);
|
return (&client_ibuf);
|
||||||
|
|
||||||
@ -139,11 +119,37 @@ not_found:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_send_identify(int flags)
|
||||||
|
{
|
||||||
|
struct msg_identify_data data;
|
||||||
|
struct winsize ws;
|
||||||
|
char *term;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
|
||||||
|
fatal("ioctl(TIOCGWINSZ)");
|
||||||
|
data.flags = flags;
|
||||||
|
|
||||||
|
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
|
||||||
|
*data.cwd = '\0';
|
||||||
|
|
||||||
|
term = getenv("TERM");
|
||||||
|
if (term == NULL ||
|
||||||
|
strlcpy(data.term, term, sizeof data.term) >= sizeof data.term)
|
||||||
|
*data.term = '\0';
|
||||||
|
|
||||||
|
if ((fd = dup(STDIN_FILENO)) == -1)
|
||||||
|
fatal("dup failed");
|
||||||
|
imsg_compose(&client_ibuf,
|
||||||
|
MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
client_send_environ(void)
|
client_send_environ(void)
|
||||||
{
|
{
|
||||||
char **var;
|
|
||||||
struct msg_environ_data data;
|
struct msg_environ_data data;
|
||||||
|
char **var;
|
||||||
|
|
||||||
for (var = environ; *var != NULL; var++) {
|
for (var = environ; *var != NULL; var++) {
|
||||||
if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
|
if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
|
||||||
|
Loading…
Reference in New Issue
Block a user