=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tmux.h,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- src/usr.bin/tmux/tmux.h 2009/07/24 14:52:47 1.54 +++ src/usr.bin/tmux/tmux.h 2009/07/26 12:58:44 1.55 @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.54 2009/07/24 14:52:47 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.55 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -19,7 +19,7 @@ #ifndef TMUX_H #define TMUX_H -#define PROTOCOL_VERSION -14 +#define PROTOCOL_VERSION -15 #include #include @@ -62,6 +62,14 @@ /* Maximum poll timeout (when attached). */ #define POLL_TIMEOUT 50 +/* + * Maximum sizes of strings in message data. Don't forget to bump + * PROTOCOL_VERSION if any of these change! + */ +#define COMMAND_LENGTH 2048 /* packed argv size */ +#define TERMINAL_LENGTH 128 /* length of TERM environment variable */ +#define PRINT_LENGTH 512 /* printed error/message size */ + /* Fatal errors. */ #define fatal(msg) log_fatal("%s: %s", __func__, msg); #define fatalx(msg) log_fatalx("%s: %s", __func__, msg); @@ -293,17 +301,29 @@ MSG_WAKEUP, }; -/* Message header structure. */ +/* + * Message header and data. + * + * Don't forget to bump PROTOCOL_VERSION if any of these change! + * + * Changing sizeof (struct hdr) or sizeof (struct msg_identify_data) will make + * the tmux client hang even if the protocol version is bumped. + */ struct hdr { enum hdrtype type; size_t size; }; +struct msg_print_data { + char msg[PRINT_LENGTH]; +}; + struct msg_command_data { pid_t pid; /* pid from $TMUX or -1 */ u_int idx; /* index from $TMUX */ - size_t namelen; + int argc; + char argv[COMMAND_LENGTH]; }; struct msg_identify_data { @@ -312,6 +332,8 @@ char cwd[MAXPATHLEN]; + char term[TERMINAL_LENGTH]; + #define IDENTIFY_UTF8 0x1 #define IDENTIFY_256COLOURS 0x2 #define IDENTIFY_88COLOURS 0x4 @@ -320,8 +342,6 @@ u_int sx; u_int sy; - - size_t termlen; }; struct msg_resize_data { @@ -329,6 +349,10 @@ u_int sy; }; +struct msg_unlock_data { + char pass[PASS_MAX]; +}; + /* Editing keys. */ enum mode_key_cmd { MODEKEYCMD_BACKSPACE = 0x1000, @@ -907,8 +931,6 @@ void (*init)(struct cmd *, int); int (*parse)(struct cmd *, int, char **, char **); int (*exec)(struct cmd *, struct cmd_ctx *); - void (*send)(struct cmd *, struct buffer *); - void (*recv)(struct cmd *, struct buffer *); void (*free)(struct cmd *); size_t (*print)(struct cmd *, char *, size_t); }; @@ -1113,14 +1135,13 @@ void clock_draw(struct screen_write_ctx *, u_int, int); /* cmd.c */ +int cmd_pack_argv(int, char **, char *, size_t); +int cmd_unpack_argv(char *, size_t, int, char ***); +void cmd_free_argv(int, char **); struct cmd *cmd_parse(int, char **, char **); int cmd_exec(struct cmd *, struct cmd_ctx *); -void cmd_send(struct cmd *, struct buffer *); -struct cmd *cmd_recv(struct buffer *); void cmd_free(struct cmd *); size_t cmd_print(struct cmd *, char *, size_t); -void cmd_send_string(struct buffer *, const char *); -char *cmd_recv_string(struct buffer *); struct session *cmd_current_session(struct cmd_ctx *); struct client *cmd_find_client(struct cmd_ctx *, const char *); struct session *cmd_find_session(struct cmd_ctx *, const char *); @@ -1205,8 +1226,6 @@ /* cmd-list.c */ struct cmd_list *cmd_list_parse(int, char **, char **); int cmd_list_exec(struct cmd_list *, struct cmd_ctx *); -void cmd_list_send(struct cmd_list *, struct buffer *); -struct cmd_list *cmd_list_recv(struct buffer *); void cmd_list_free(struct cmd_list *); size_t cmd_list_print(struct cmd_list *, char *, size_t); @@ -1220,8 +1239,6 @@ #define CMD_TARGET_CLIENT_USAGE "[-t target-client]" void cmd_target_init(struct cmd *, int); int cmd_target_parse(struct cmd *, int, char **, char **); -void cmd_target_send(struct cmd *, struct buffer *); -void cmd_target_recv(struct cmd *, struct buffer *); void cmd_target_free(struct cmd *); size_t cmd_target_print(struct cmd *, char *, size_t); #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]" @@ -1229,8 +1246,6 @@ #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]" void cmd_srcdst_init(struct cmd *, int); int cmd_srcdst_parse(struct cmd *, int, char **, char **); -void cmd_srcdst_send(struct cmd *, struct buffer *); -void cmd_srcdst_recv(struct cmd *, struct buffer *); void cmd_srcdst_free(struct cmd *); size_t cmd_srcdst_print(struct cmd *, char *, size_t); #define CMD_BUFFER_WINDOW_USAGE "[-b buffer-index] [-t target-window]" @@ -1238,8 +1253,6 @@ #define CMD_BUFFER_CLIENT_USAGE "[-b buffer-index] [-t target-client]" void cmd_buffer_init(struct cmd *, int); int cmd_buffer_parse(struct cmd *, int, char **, char **); -void cmd_buffer_send(struct cmd *, struct buffer *); -void cmd_buffer_recv(struct cmd *, struct buffer *); void cmd_buffer_free(struct cmd *); size_t cmd_buffer_print(struct cmd *, char *, size_t); #define CMD_OPTION_WINDOW_USAGE "[-gu] [-t target-window] option [value]" @@ -1247,8 +1260,6 @@ #define CMD_OPTION_CLIENT_USAGE "[-gu] [-t target-client] option [value]" void cmd_option_init(struct cmd *, int); int cmd_option_parse(struct cmd *, int, char **, char **); -void cmd_option_send(struct cmd *, struct buffer *); -void cmd_option_recv(struct cmd *, struct buffer *); void cmd_option_free(struct cmd *); size_t cmd_option_print(struct cmd *, char *, size_t); #define CMD_PANE_WINDOW_USAGE "[-t target-window] [-p pane-index]" @@ -1256,8 +1267,6 @@ #define CMD_PANE_CLIENT_USAGE "[-t target-client] [-p pane-index]" void cmd_pane_init(struct cmd *, int); int cmd_pane_parse(struct cmd *, int, char **, char **); -void cmd_pane_send(struct cmd *, struct buffer *); -void cmd_pane_recv(struct cmd *, struct buffer *); void cmd_pane_free(struct cmd *); size_t cmd_pane_print(struct cmd *, char *, size_t); @@ -1270,8 +1279,6 @@ /* client-fn.c */ void client_write_server(struct client_ctx *, enum hdrtype, void *, size_t); -void client_write_server2( - struct client_ctx *, enum hdrtype, void *, size_t, void *, size_t); void client_fill_session(struct msg_command_data *); /* key-bindings.c */ @@ -1303,6 +1310,7 @@ /* server-fn.c */ const char **server_fill_environ(struct session *); +void server_write_error(struct client *, const char *); void server_write_client( struct client *, enum hdrtype, const void *, size_t); void server_write_session(