xref: /openbsd-src/usr.bin/tmux/tmux-protocol.h (revision 4e1ee0786f11cc571bd0be17d38e46f635c719fc)
1 /* $OpenBSD: tmux-protocol.h,v 1.1 2021/08/13 07:37:58 nicm Exp $ */
2 
3 /*
4  * Copyright (c) 2021 Nicholas Marriott <nicholas.marriott@gmail.com>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef TMUX_PROTOCOL_H
20 #define TMUX_PROTOCOL_H
21 
22 /* Protocol version. */
23 #define PROTOCOL_VERSION 8
24 
25 /* Message types. */
26 enum msgtype {
27 	MSG_VERSION = 12,
28 
29 	MSG_IDENTIFY_FLAGS = 100,
30 	MSG_IDENTIFY_TERM,
31 	MSG_IDENTIFY_TTYNAME,
32 	MSG_IDENTIFY_OLDCWD, /* unused */
33 	MSG_IDENTIFY_STDIN,
34 	MSG_IDENTIFY_ENVIRON,
35 	MSG_IDENTIFY_DONE,
36 	MSG_IDENTIFY_CLIENTPID,
37 	MSG_IDENTIFY_CWD,
38 	MSG_IDENTIFY_FEATURES,
39 	MSG_IDENTIFY_STDOUT,
40 	MSG_IDENTIFY_LONGFLAGS,
41 	MSG_IDENTIFY_TERMINFO,
42 
43 	MSG_COMMAND = 200,
44 	MSG_DETACH,
45 	MSG_DETACHKILL,
46 	MSG_EXIT,
47 	MSG_EXITED,
48 	MSG_EXITING,
49 	MSG_LOCK,
50 	MSG_READY,
51 	MSG_RESIZE,
52 	MSG_SHELL,
53 	MSG_SHUTDOWN,
54 	MSG_OLDSTDERR, /* unused */
55 	MSG_OLDSTDIN, /* unused */
56 	MSG_OLDSTDOUT, /* unused */
57 	MSG_SUSPEND,
58 	MSG_UNLOCK,
59 	MSG_WAKEUP,
60 	MSG_EXEC,
61 	MSG_FLAGS,
62 
63 	MSG_READ_OPEN = 300,
64 	MSG_READ,
65 	MSG_READ_DONE,
66 	MSG_WRITE_OPEN,
67 	MSG_WRITE,
68 	MSG_WRITE_READY,
69 	MSG_WRITE_CLOSE
70 };
71 
72 /*
73  * Message data.
74  *
75  * Don't forget to bump PROTOCOL_VERSION if any of these change!
76  */
77 struct msg_command {
78 	int	argc;
79 }; /* followed by packed argv */
80 
81 struct msg_read_open {
82 	int	stream;
83 	int	fd;
84 }; /* followed by path */
85 
86 struct msg_read_data {
87 	int	stream;
88 };
89 
90 struct msg_read_done {
91 	int	stream;
92 	int	error;
93 };
94 
95 struct msg_write_open {
96 	int	stream;
97 	int	fd;
98 	int	flags;
99 }; /* followed by path */
100 
101 struct msg_write_data {
102 	int	stream;
103 }; /* followed by data */
104 
105 struct msg_write_ready {
106 	int	stream;
107 	int	error;
108 };
109 
110 struct msg_write_close {
111 	int	stream;
112 };
113 
114 #endif /* TMUX_PROTOCOL_H */
115