diff options
Diffstat (limited to 'usr.bin/tmux')
82 files changed, 335 insertions, 862 deletions
diff --git a/usr.bin/tmux/client-fn.c b/usr.bin/tmux/client-fn.c index 8a0e9c8627f..195254d322e 100644 --- a/usr.bin/tmux/client-fn.c +++ b/usr.bin/tmux/client-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client-fn.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: client-fn.c,v 1.2 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -74,19 +74,3 @@ client_write_server( if (buf != NULL && len > 0) buffer_write(cctx->srv_out, buf, len); } - -void -client_write_server2(struct client_ctx *cctx, - enum hdrtype type, void *buf1, size_t len1, void *buf2, size_t len2) -{ - struct hdr hdr; - - hdr.type = type; - hdr.size = len1 + len2; - buffer_write(cctx->srv_out, &hdr, sizeof hdr); - - if (buf1 != NULL && len1 > 0) - buffer_write(cctx->srv_out, buf1, len1); - if (buf2 != NULL && len2 > 0) - buffer_write(cctx->srv_out, buf2, len2); -} diff --git a/usr.bin/tmux/client-msg.c b/usr.bin/tmux/client-msg.c index 4db5ea920b0..26183343d36 100644 --- a/usr.bin/tmux/client-msg.c +++ b/usr.bin/tmux/client-msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client-msg.c,v 1.4 2009/07/23 20:24:27 nicm Exp $ */ +/* $OpenBSD: client-msg.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -70,16 +70,15 @@ client_msg_dispatch(struct client_ctx *cctx) int client_msg_fn_error(struct hdr *hdr, struct client_ctx *cctx) { - char *errstr; + struct msg_print_data data; - if (hdr->size == SIZE_MAX) - fatalx("bad MSG_ERROR size"); + if (hdr->size < sizeof data) + fatalx("bad MSG_PRINT size"); + buffer_read(cctx->srv_in, &data, sizeof data); - errstr = xmalloc(hdr->size + 1); - buffer_read(cctx->srv_in, errstr, hdr->size); - errstr[hdr->size] = '\0'; + data.msg[(sizeof data.msg) - 1] = '\0'; + cctx->errstr = xstrdup(data.msg); - cctx->errstr = errstr; return (-1); } diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index fe68e24fc3d..4547b40e194 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.6 2009/07/23 21:19:11 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.7 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -44,8 +44,7 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags) struct winsize ws; size_t size; int mode; - struct buffer *b; - char *name; + char *name, *term; char rpathbuf[MAXPATHLEN]; if (realpath(path, rpathbuf) == NULL) @@ -103,20 +102,24 @@ server_started: data.flags = flags; data.sx = ws.ws_col; data.sy = ws.ws_row; - *data.tty = '\0'; + 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'; + } + + *data.tty = '\0'; if ((name = ttyname(STDIN_FILENO)) == NULL) fatal("ttyname failed"); if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty) fatalx("ttyname failed"); - b = buffer_create(BUFSIZ); - cmd_send_string(b, getenv("TERM")); - client_write_server2(cctx, MSG_IDENTIFY, - &data, sizeof data, BUFFER_OUT(b), BUFFER_USED(b)); - buffer_destroy(b); + client_write_server(cctx, MSG_IDENTIFY, &data, sizeof data); } return (0); diff --git a/usr.bin/tmux/cmd-attach-session.c b/usr.bin/tmux/cmd-attach-session.c index 5e6454e81bf..22d6423b891 100644 --- a/usr.bin/tmux/cmd-attach-session.c +++ b/usr.bin/tmux/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-attach-session.c,v 1.5 2009/07/23 12:33:48 nicm Exp $ */ +/* $OpenBSD: cmd-attach-session.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_attach_session_entry = { cmd_target_init, cmd_target_parse, cmd_attach_session_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-bind-key.c b/usr.bin/tmux/cmd-bind-key.c index c4775474dc4..74f1db566e5 100644 --- a/usr.bin/tmux/cmd-bind-key.c +++ b/usr.bin/tmux/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-bind-key.c,v 1.3 2009/07/24 14:52:47 nicm Exp $ */ +/* $OpenBSD: cmd-bind-key.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,8 +26,6 @@ int cmd_bind_key_parse(struct cmd *, int, char **, char **); int cmd_bind_key_exec(struct cmd *, struct cmd_ctx *); -void cmd_bind_key_send(struct cmd *, struct buffer *); -void cmd_bind_key_recv(struct cmd *, struct buffer *); void cmd_bind_key_free(struct cmd *); size_t cmd_bind_key_print(struct cmd *, char *, size_t); @@ -44,8 +42,6 @@ const struct cmd_entry cmd_bind_key_entry = { NULL, cmd_bind_key_parse, cmd_bind_key_exec, - cmd_bind_key_send, - cmd_bind_key_recv, cmd_bind_key_free, cmd_bind_key_print }; @@ -114,25 +110,6 @@ cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx) } void -cmd_bind_key_send(struct cmd *self, struct buffer *b) -{ - struct cmd_bind_key_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_list_send(data->cmdlist, b); -} - -void -cmd_bind_key_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_bind_key_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->cmdlist = cmd_list_recv(b); -} - -void cmd_bind_key_free(struct cmd *self) { struct cmd_bind_key_data *data = self->data; diff --git a/usr.bin/tmux/cmd-break-pane.c b/usr.bin/tmux/cmd-break-pane.c index b77e1536276..edf2fbf8b87 100644 --- a/usr.bin/tmux/cmd-break-pane.c +++ b/usr.bin/tmux/cmd-break-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-break-pane.c,v 1.3 2009/07/19 13:21:40 nicm Exp $ */ +/* $OpenBSD: cmd-break-pane.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_break_pane_entry = { cmd_pane_init, cmd_pane_parse, cmd_break_pane_exec, - cmd_pane_send, - cmd_pane_recv, cmd_pane_free, cmd_pane_print }; diff --git a/usr.bin/tmux/cmd-choose-session.c b/usr.bin/tmux/cmd-choose-session.c index 91613b8f623..81719f0fc55 100644 --- a/usr.bin/tmux/cmd-choose-session.c +++ b/usr.bin/tmux/cmd-choose-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-session.c,v 1.3 2009/07/17 07:05:58 nicm Exp $ */ +/* $OpenBSD: cmd-choose-session.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_choose_session_entry = { cmd_target_init, cmd_target_parse, cmd_choose_session_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-choose-window.c b/usr.bin/tmux/cmd-choose-window.c index 99f7f7a67bc..ed853d74f0c 100644 --- a/usr.bin/tmux/cmd-choose-window.c +++ b/usr.bin/tmux/cmd-choose-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-window.c,v 1.4 2009/07/19 13:21:40 nicm Exp $ */ +/* $OpenBSD: cmd-choose-window.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_choose_window_entry = { cmd_target_init, cmd_target_parse, cmd_choose_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-clear-history.c b/usr.bin/tmux/cmd-clear-history.c index 07a400cb174..922fe25a4fa 100644 --- a/usr.bin/tmux/cmd-clear-history.c +++ b/usr.bin/tmux/cmd-clear-history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-clear-history.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-clear-history.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_clear_history_entry = { cmd_pane_init, cmd_pane_parse, cmd_clear_history_exec, - cmd_pane_send, - cmd_pane_recv, cmd_pane_free, cmd_pane_print }; diff --git a/usr.bin/tmux/cmd-clock-mode.c b/usr.bin/tmux/cmd-clock-mode.c index 6ca2fddc3b1..89231c8e89f 100644 --- a/usr.bin/tmux/cmd-clock-mode.c +++ b/usr.bin/tmux/cmd-clock-mode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-clock-mode.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-clock-mode.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_clock_mode_entry = { cmd_target_init, cmd_target_parse, cmd_clock_mode_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-command-prompt.c b/usr.bin/tmux/cmd-command-prompt.c index be532a75738..4019689b702 100644 --- a/usr.bin/tmux/cmd-command-prompt.c +++ b/usr.bin/tmux/cmd-command-prompt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-command-prompt.c,v 1.5 2009/07/20 07:31:10 nicm Exp $ */ +/* $OpenBSD: cmd-command-prompt.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -40,8 +40,6 @@ const struct cmd_entry cmd_command_prompt_entry = { cmd_command_prompt_init, cmd_target_parse, cmd_command_prompt_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-confirm-before.c b/usr.bin/tmux/cmd-confirm-before.c index 4fe70270bb6..e4fd9e2617a 100644 --- a/usr.bin/tmux/cmd-confirm-before.c +++ b/usr.bin/tmux/cmd-confirm-before.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-confirm-before.c,v 1.5 2009/07/21 18:52:03 nicm Exp $ */ +/* $OpenBSD: cmd-confirm-before.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -38,8 +38,6 @@ const struct cmd_entry cmd_confirm_before_entry = { cmd_confirm_before_init, cmd_target_parse, cmd_confirm_before_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-copy-buffer.c b/usr.bin/tmux/cmd-copy-buffer.c index 4f922a16d5a..3f6f5cb28a7 100644 --- a/usr.bin/tmux/cmd-copy-buffer.c +++ b/usr.bin/tmux/cmd-copy-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-copy-buffer.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-copy-buffer.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -26,8 +26,6 @@ int cmd_copy_buffer_parse(struct cmd *, int, char **, char **); int cmd_copy_buffer_exec(struct cmd *, struct cmd_ctx *); -void cmd_copy_buffer_send(struct cmd *, struct buffer *); -void cmd_copy_buffer_recv(struct cmd *, struct buffer *); void cmd_copy_buffer_free(struct cmd *); void cmd_copy_buffer_init(struct cmd *, int); size_t cmd_copy_buffer_print(struct cmd *, char *, size_t); @@ -46,8 +44,6 @@ const struct cmd_entry cmd_copy_buffer_entry = { cmd_copy_buffer_init, cmd_copy_buffer_parse, cmd_copy_buffer_exec, - cmd_copy_buffer_send, - cmd_copy_buffer_recv, cmd_copy_buffer_free, cmd_copy_buffer_print }; @@ -161,27 +157,6 @@ cmd_copy_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_copy_buffer_send(struct cmd *self, struct buffer *b) -{ - struct cmd_copy_buffer_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->dst_session); - cmd_send_string(b, data->src_session); -} - -void -cmd_copy_buffer_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_copy_buffer_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->dst_session = cmd_recv_string(b); - data->src_session = cmd_recv_string(b); -} - -void cmd_copy_buffer_free(struct cmd *self) { struct cmd_copy_buffer_data *data = self->data; diff --git a/usr.bin/tmux/cmd-copy-mode.c b/usr.bin/tmux/cmd-copy-mode.c index 481d3508b5f..6e9a1f3ddd7 100644 --- a/usr.bin/tmux/cmd-copy-mode.c +++ b/usr.bin/tmux/cmd-copy-mode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-copy-mode.c,v 1.4 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-copy-mode.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_copy_mode_entry = { cmd_target_init, cmd_target_parse, cmd_copy_mode_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, NULL }; diff --git a/usr.bin/tmux/cmd-delete-buffer.c b/usr.bin/tmux/cmd-delete-buffer.c index 579d13c70e8..de9de2156a6 100644 --- a/usr.bin/tmux/cmd-delete-buffer.c +++ b/usr.bin/tmux/cmd-delete-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-delete-buffer.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-delete-buffer.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_delete_buffer_entry = { cmd_buffer_init, cmd_buffer_parse, cmd_delete_buffer_exec, - cmd_buffer_send, - cmd_buffer_recv, cmd_buffer_free, cmd_buffer_print }; diff --git a/usr.bin/tmux/cmd-detach-client.c b/usr.bin/tmux/cmd-detach-client.c index 1f77d82e0a0..334338282ad 100644 --- a/usr.bin/tmux/cmd-detach-client.c +++ b/usr.bin/tmux/cmd-detach-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-detach-client.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-detach-client.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_detach_client_entry = { cmd_target_init, cmd_target_parse, cmd_detach_client_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c index dea7bf0748c..71b64f01364 100644 --- a/usr.bin/tmux/cmd-display-message.c +++ b/usr.bin/tmux/cmd-display-message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-message.c,v 1.1 2009/07/17 18:45:08 nicm Exp $ */ +/* $OpenBSD: cmd-display-message.c,v 1.2 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_display_message_entry = { cmd_target_init, cmd_target_parse, cmd_display_message_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-down-pane.c b/usr.bin/tmux/cmd-down-pane.c index feec23a3521..a436da5de5f 100644 --- a/usr.bin/tmux/cmd-down-pane.c +++ b/usr.bin/tmux/cmd-down-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-down-pane.c,v 1.5 2009/07/20 19:35:33 nicm Exp $ */ +/* $OpenBSD: cmd-down-pane.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_down_pane_entry = { cmd_target_init, cmd_target_parse, cmd_down_pane_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c index 95dac74fb56..0e2d876b42d 100644 --- a/usr.bin/tmux/cmd-find-window.c +++ b/usr.bin/tmux/cmd-find-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find-window.c,v 1.4 2009/07/17 07:05:58 nicm Exp $ */ +/* $OpenBSD: cmd-find-window.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -38,8 +38,6 @@ const struct cmd_entry cmd_find_window_entry = { cmd_target_init, cmd_target_parse, cmd_find_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-generic.c b/usr.bin/tmux/cmd-generic.c index 843e2ae3065..9eff797b4ff 100644 --- a/usr.bin/tmux/cmd-generic.c +++ b/usr.bin/tmux/cmd-generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-generic.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-generic.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -177,27 +177,6 @@ usage: } void -cmd_target_send(struct cmd *self, struct buffer *b) -{ - struct cmd_target_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); - cmd_send_string(b, data->arg); -} - -void -cmd_target_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_target_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); - data->arg = cmd_recv_string(b); -} - -void cmd_target_free(struct cmd *self) { struct cmd_target_data *data = self->data; @@ -279,29 +258,6 @@ usage: } void -cmd_srcdst_send(struct cmd *self, struct buffer *b) -{ - struct cmd_srcdst_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->src); - cmd_send_string(b, data->dst); - cmd_send_string(b, data->arg); -} - -void -cmd_srcdst_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_srcdst_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->src = cmd_recv_string(b); - data->dst = cmd_recv_string(b); - data->arg = cmd_recv_string(b); -} - -void cmd_srcdst_free(struct cmd *self) { struct cmd_srcdst_data *data = self->data; @@ -395,27 +351,6 @@ error: } void -cmd_buffer_send(struct cmd *self, struct buffer *b) -{ - struct cmd_buffer_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); - cmd_send_string(b, data->arg); -} - -void -cmd_buffer_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_buffer_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); - data->arg = cmd_recv_string(b); -} - -void cmd_buffer_free(struct cmd *self) { struct cmd_buffer_data *data = self->data; @@ -501,29 +436,6 @@ usage: } void -cmd_option_send(struct cmd *self, struct buffer *b) -{ - struct cmd_option_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); - cmd_send_string(b, data->option); - cmd_send_string(b, data->value); -} - -void -cmd_option_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_option_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); - data->option = cmd_recv_string(b); - data->value = cmd_recv_string(b); -} - -void cmd_option_free(struct cmd *self) { struct cmd_option_data *data = self->data; @@ -618,27 +530,6 @@ error: } void -cmd_pane_send(struct cmd *self, struct buffer *b) -{ - struct cmd_pane_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); - cmd_send_string(b, data->arg); -} - -void -cmd_pane_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_pane_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); - data->arg = cmd_recv_string(b); -} - -void cmd_pane_free(struct cmd *self) { struct cmd_pane_data *data = self->data; diff --git a/usr.bin/tmux/cmd-has-session.c b/usr.bin/tmux/cmd-has-session.c index 67df518007b..62c7c431b9f 100644 --- a/usr.bin/tmux/cmd-has-session.c +++ b/usr.bin/tmux/cmd-has-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-has-session.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-has-session.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_has_session_entry = { cmd_target_init, cmd_target_parse, cmd_has_session_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-if-shell.c b/usr.bin/tmux/cmd-if-shell.c index c50d8d998e6..77435382551 100644 --- a/usr.bin/tmux/cmd-if-shell.c +++ b/usr.bin/tmux/cmd-if-shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-if-shell.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-if-shell.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -30,8 +30,6 @@ int cmd_if_shell_parse(struct cmd *, int, char **, char **); int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *); -void cmd_if_shell_send(struct cmd *, struct buffer *); -void cmd_if_shell_recv(struct cmd *, struct buffer *); void cmd_if_shell_free(struct cmd *); void cmd_if_shell_init(struct cmd *, int); size_t cmd_if_shell_print(struct cmd *, char *, size_t); @@ -48,8 +46,6 @@ const struct cmd_entry cmd_if_shell_entry = { cmd_if_shell_init, cmd_if_shell_parse, cmd_if_shell_exec, - cmd_if_shell_send, - cmd_if_shell_recv, cmd_if_shell_free, cmd_if_shell_print }; @@ -127,27 +123,6 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_if_shell_send(struct cmd *self, struct buffer *b) -{ - struct cmd_if_shell_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->cmd); - cmd_send_string(b, data->sh_cmd); -} - -void -cmd_if_shell_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_if_shell_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->cmd = cmd_recv_string(b); - data->sh_cmd = cmd_recv_string(b); -} - -void cmd_if_shell_free(struct cmd *self) { struct cmd_if_shell_data *data = self->data; diff --git a/usr.bin/tmux/cmd-kill-pane.c b/usr.bin/tmux/cmd-kill-pane.c index 319da2bcbf6..c63125ce962 100644 --- a/usr.bin/tmux/cmd-kill-pane.c +++ b/usr.bin/tmux/cmd-kill-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-kill-pane.c,v 1.4 2009/07/19 13:21:40 nicm Exp $ */ +/* $OpenBSD: cmd-kill-pane.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_kill_pane_entry = { cmd_pane_init, cmd_pane_parse, cmd_kill_pane_exec, - cmd_pane_send, - cmd_pane_recv, cmd_pane_free, cmd_pane_print }; diff --git a/usr.bin/tmux/cmd-kill-server.c b/usr.bin/tmux/cmd-kill-server.c index 3c78a07aa49..59de2e58a35 100644 --- a/usr.bin/tmux/cmd-kill-server.c +++ b/usr.bin/tmux/cmd-kill-server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-kill-server.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-kill-server.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -37,8 +37,6 @@ const struct cmd_entry cmd_kill_server_entry = { NULL, cmd_kill_server_exec, NULL, - NULL, - NULL, NULL }; diff --git a/usr.bin/tmux/cmd-kill-session.c b/usr.bin/tmux/cmd-kill-session.c index c965b9b0ac7..896df6e8057 100644 --- a/usr.bin/tmux/cmd-kill-session.c +++ b/usr.bin/tmux/cmd-kill-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-kill-session.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-kill-session.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_kill_session_entry = { cmd_target_init, cmd_target_parse, cmd_kill_session_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-kill-window.c b/usr.bin/tmux/cmd-kill-window.c index f5ded5e6342..c6b7576f55a 100644 --- a/usr.bin/tmux/cmd-kill-window.c +++ b/usr.bin/tmux/cmd-kill-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-kill-window.c,v 1.4 2009/07/17 20:37:03 nicm Exp $ */ +/* $OpenBSD: cmd-kill-window.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_kill_window_entry = { cmd_target_init, cmd_target_parse, cmd_kill_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-last-window.c b/usr.bin/tmux/cmd-last-window.c index 9bd652cfc1c..973ff3c79af 100644 --- a/usr.bin/tmux/cmd-last-window.c +++ b/usr.bin/tmux/cmd-last-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-last-window.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-last-window.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_last_window_entry = { cmd_target_init, cmd_target_parse, cmd_last_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-link-window.c b/usr.bin/tmux/cmd-link-window.c index 4668cf8d876..53f413b99ca 100644 --- a/usr.bin/tmux/cmd-link-window.c +++ b/usr.bin/tmux/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-link-window.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-link-window.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_link_window_entry = { cmd_srcdst_init, cmd_srcdst_parse, cmd_link_window_exec, - cmd_srcdst_send, - cmd_srcdst_recv, cmd_srcdst_free, cmd_srcdst_print }; diff --git a/usr.bin/tmux/cmd-list-buffers.c b/usr.bin/tmux/cmd-list-buffers.c index 409cb93b411..7e1940cb5f0 100644 --- a/usr.bin/tmux/cmd-list-buffers.c +++ b/usr.bin/tmux/cmd-list-buffers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-buffers.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-list-buffers.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_list_buffers_entry = { cmd_target_init, cmd_target_parse, cmd_list_buffers_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-list-clients.c b/usr.bin/tmux/cmd-list-clients.c index 86115771331..d472d717f92 100644 --- a/usr.bin/tmux/cmd-list-clients.c +++ b/usr.bin/tmux/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-clients.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-list-clients.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -37,8 +37,6 @@ const struct cmd_entry cmd_list_clients_entry = { NULL, cmd_list_clients_exec, NULL, - NULL, - NULL, NULL }; diff --git a/usr.bin/tmux/cmd-list-commands.c b/usr.bin/tmux/cmd-list-commands.c index f7ea2301a15..5685af075a5 100644 --- a/usr.bin/tmux/cmd-list-commands.c +++ b/usr.bin/tmux/cmd-list-commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-commands.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-list-commands.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,8 +34,6 @@ const struct cmd_entry cmd_list_commands_entry = { NULL, cmd_list_commands_exec, NULL, - NULL, - NULL, NULL }; diff --git a/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c index 5cfa7ae6818..3b2cf857153 100644 --- a/usr.bin/tmux/cmd-list-keys.c +++ b/usr.bin/tmux/cmd-list-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-keys.c,v 1.4 2009/07/24 14:52:47 nicm Exp $ */ +/* $OpenBSD: cmd-list-keys.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_list_keys_entry = { NULL, cmd_list_keys_exec, NULL, - NULL, - NULL, NULL }; diff --git a/usr.bin/tmux/cmd-list-sessions.c b/usr.bin/tmux/cmd-list-sessions.c index ec35edeae12..9c03f5589ac 100644 --- a/usr.bin/tmux/cmd-list-sessions.c +++ b/usr.bin/tmux/cmd-list-sessions.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-sessions.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-list-sessions.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_list_sessions_entry = { NULL, cmd_list_sessions_exec, NULL, - NULL, - NULL, NULL }; diff --git a/usr.bin/tmux/cmd-list-windows.c b/usr.bin/tmux/cmd-list-windows.c index 62c4fdc5dd4..9802eb2110c 100644 --- a/usr.bin/tmux/cmd-list-windows.c +++ b/usr.bin/tmux/cmd-list-windows.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list-windows.c,v 1.3 2009/07/19 13:21:40 nicm Exp $ */ +/* $OpenBSD: cmd-list-windows.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_list_windows_entry = { cmd_target_init, cmd_target_parse, cmd_list_windows_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-list.c b/usr.bin/tmux/cmd-list.c index 2d778e25e31..6054ac53ae6 100644 --- a/usr.bin/tmux/cmd-list.c +++ b/usr.bin/tmux/cmd-list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-list.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: cmd-list.c,v 1.2 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -87,41 +87,6 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) } void -cmd_list_send(struct cmd_list *cmdlist, struct buffer *b) -{ - struct cmd *cmd; - u_int n; - - n = 0; - TAILQ_FOREACH(cmd, cmdlist, qentry) - n++; - - buffer_write(b, &n, sizeof n); - TAILQ_FOREACH(cmd, cmdlist, qentry) - cmd_send(cmd, b); -} - -struct cmd_list * -cmd_list_recv(struct buffer *b) -{ - struct cmd_list *cmdlist; - struct cmd *cmd; - u_int n; - - buffer_read(b, &n, sizeof n); - - cmdlist = xmalloc(sizeof *cmdlist); - TAILQ_INIT(cmdlist); - - while (n-- > 0) { - cmd = cmd_recv(b); - TAILQ_INSERT_TAIL(cmdlist, cmd, qentry); - } - - return (cmdlist); -} - -void cmd_list_free(struct cmd_list *cmdlist) { struct cmd *cmd; diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c index 226c832e72d..43bc7221b9a 100644 --- a/usr.bin/tmux/cmd-load-buffer.c +++ b/usr.bin/tmux/cmd-load-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -39,8 +39,6 @@ const struct cmd_entry cmd_load_buffer_entry = { cmd_buffer_init, cmd_buffer_parse, cmd_load_buffer_exec, - cmd_buffer_send, - cmd_buffer_recv, cmd_buffer_free, cmd_buffer_print }; diff --git a/usr.bin/tmux/cmd-lock-server.c b/usr.bin/tmux/cmd-lock-server.c index 6b8a1b7c23d..37d424af832 100644 --- a/usr.bin/tmux/cmd-lock-server.c +++ b/usr.bin/tmux/cmd-lock-server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-lock-server.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-lock-server.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -39,8 +39,6 @@ const struct cmd_entry cmd_lock_server_entry = { cmd_lock_server_exec, NULL, NULL, - NULL, - NULL, }; int diff --git a/usr.bin/tmux/cmd-move-window.c b/usr.bin/tmux/cmd-move-window.c index 6bd4883cd3a..a7301d94d1b 100644 --- a/usr.bin/tmux/cmd-move-window.c +++ b/usr.bin/tmux/cmd-move-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-move-window.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-move-window.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_move_window_entry = { cmd_srcdst_init, cmd_srcdst_parse, cmd_move_window_exec, - cmd_srcdst_send, - cmd_srcdst_recv, cmd_srcdst_free, cmd_srcdst_print }; diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index e1c83315222..a5ea55a3329 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.7 2009/07/23 15:47:56 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.8 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,8 +26,6 @@ int cmd_new_session_parse(struct cmd *, int, char **, char **); int cmd_new_session_exec(struct cmd *, struct cmd_ctx *); -void cmd_new_session_send(struct cmd *, struct buffer *); -void cmd_new_session_recv(struct cmd *, struct buffer *); void cmd_new_session_free(struct cmd *); void cmd_new_session_init(struct cmd *, int); size_t cmd_new_session_print(struct cmd *, char *, size_t); @@ -46,8 +44,6 @@ const struct cmd_entry cmd_new_session_entry = { cmd_new_session_init, cmd_new_session_parse, cmd_new_session_exec, - cmd_new_session_send, - cmd_new_session_recv, cmd_new_session_free, cmd_new_session_print }; @@ -229,29 +225,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_new_session_send(struct cmd *self, struct buffer *b) -{ - struct cmd_new_session_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->newname); - cmd_send_string(b, data->winname); - cmd_send_string(b, data->cmd); -} - -void -cmd_new_session_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_new_session_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->newname = cmd_recv_string(b); - data->winname = cmd_recv_string(b); - data->cmd = cmd_recv_string(b); -} - -void cmd_new_session_free(struct cmd *self) { struct cmd_new_session_data *data = self->data; diff --git a/usr.bin/tmux/cmd-new-window.c b/usr.bin/tmux/cmd-new-window.c index 07d6ba06bcf..fd55516f7c6 100644 --- a/usr.bin/tmux/cmd-new-window.c +++ b/usr.bin/tmux/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-window.c,v 1.4 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-new-window.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -28,8 +28,6 @@ int cmd_new_window_parse(struct cmd *, int, char **, char **); int cmd_new_window_exec(struct cmd *, struct cmd_ctx *); -void cmd_new_window_send(struct cmd *, struct buffer *); -void cmd_new_window_recv(struct cmd *, struct buffer *); void cmd_new_window_free(struct cmd *); void cmd_new_window_init(struct cmd *, int); size_t cmd_new_window_print(struct cmd *, char *, size_t); @@ -49,8 +47,6 @@ const struct cmd_entry cmd_new_window_entry = { cmd_new_window_init, cmd_new_window_parse, cmd_new_window_exec, - cmd_new_window_send, - cmd_new_window_recv, cmd_new_window_free, cmd_new_window_print }; @@ -174,29 +170,6 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_new_window_send(struct cmd *self, struct buffer *b) -{ - struct cmd_new_window_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); - cmd_send_string(b, data->name); - cmd_send_string(b, data->cmd); -} - -void -cmd_new_window_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_new_window_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); - data->name = cmd_recv_string(b); - data->cmd = cmd_recv_string(b); -} - -void cmd_new_window_free(struct cmd *self) { struct cmd_new_window_data *data = self->data; diff --git a/usr.bin/tmux/cmd-next-layout.c b/usr.bin/tmux/cmd-next-layout.c index d791344b86f..81a943233da 100644 --- a/usr.bin/tmux/cmd-next-layout.c +++ b/usr.bin/tmux/cmd-next-layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-next-layout.c,v 1.3 2009/07/19 13:21:40 nicm Exp $ */ +/* $OpenBSD: cmd-next-layout.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_next_layout_entry = { cmd_target_init, cmd_target_parse, cmd_next_layout_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-next-window.c b/usr.bin/tmux/cmd-next-window.c index f3bfae17f6e..455efe246f4 100644 --- a/usr.bin/tmux/cmd-next-window.c +++ b/usr.bin/tmux/cmd-next-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-next-window.c,v 1.4 2009/07/21 17:57:29 nicm Exp $ */ +/* $OpenBSD: cmd-next-window.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,8 +34,6 @@ const struct cmd_entry cmd_next_window_entry = { cmd_next_window_init, cmd_target_parse, cmd_next_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-paste-buffer.c b/usr.bin/tmux/cmd-paste-buffer.c index 7e078767b18..3e4e24a60c9 100644 --- a/usr.bin/tmux/cmd-paste-buffer.c +++ b/usr.bin/tmux/cmd-paste-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-paste-buffer.c,v 1.4 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-paste-buffer.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_paste_buffer_entry = { cmd_buffer_init, cmd_buffer_parse, cmd_paste_buffer_exec, - cmd_buffer_send, - cmd_buffer_recv, cmd_buffer_free, cmd_buffer_print }; diff --git a/usr.bin/tmux/cmd-previous-layout.c b/usr.bin/tmux/cmd-previous-layout.c index 032402846e5..9d87a2473d7 100644 --- a/usr.bin/tmux/cmd-previous-layout.c +++ b/usr.bin/tmux/cmd-previous-layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-previous-layout.c,v 1.3 2009/07/19 13:21:40 nicm Exp $ */ +/* $OpenBSD: cmd-previous-layout.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_previous_layout_entry = { cmd_target_init, cmd_target_parse, cmd_previous_layout_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-previous-window.c b/usr.bin/tmux/cmd-previous-window.c index ae0abdcee50..8b5a3e2806b 100644 --- a/usr.bin/tmux/cmd-previous-window.c +++ b/usr.bin/tmux/cmd-previous-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-previous-window.c,v 1.4 2009/07/21 17:57:29 nicm Exp $ */ +/* $OpenBSD: cmd-previous-window.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,8 +34,6 @@ const struct cmd_entry cmd_previous_window_entry = { cmd_previous_window_init, cmd_target_parse, cmd_previous_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-refresh-client.c b/usr.bin/tmux/cmd-refresh-client.c index b91ed6ec889..a7630b020ec 100644 --- a/usr.bin/tmux/cmd-refresh-client.c +++ b/usr.bin/tmux/cmd-refresh-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-refresh-client.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-refresh-client.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_refresh_client_entry = { cmd_target_init, cmd_target_parse, cmd_refresh_client_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-rename-session.c b/usr.bin/tmux/cmd-rename-session.c index 64fb445bdc1..f02dcbcff71 100644 --- a/usr.bin/tmux/cmd-rename-session.c +++ b/usr.bin/tmux/cmd-rename-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rename-session.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-rename-session.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_rename_session_entry = { cmd_target_init, cmd_target_parse, cmd_rename_session_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-rename-window.c b/usr.bin/tmux/cmd-rename-window.c index a262c8899ed..722e0394617 100644 --- a/usr.bin/tmux/cmd-rename-window.c +++ b/usr.bin/tmux/cmd-rename-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rename-window.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-rename-window.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_rename_window_entry = { cmd_target_init, cmd_target_parse, cmd_rename_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-resize-pane.c b/usr.bin/tmux/cmd-resize-pane.c index 6e9377ad134..a494e44aec4 100644 --- a/usr.bin/tmux/cmd-resize-pane.c +++ b/usr.bin/tmux/cmd-resize-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-resize-pane.c,v 1.4 2009/07/21 17:57:29 nicm Exp $ */ +/* $OpenBSD: cmd-resize-pane.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -37,8 +37,6 @@ const struct cmd_entry cmd_resize_pane_entry = { cmd_resize_pane_init, cmd_pane_parse, cmd_resize_pane_exec, - cmd_pane_send, - cmd_pane_recv, cmd_pane_free, cmd_pane_print }; diff --git a/usr.bin/tmux/cmd-respawn-window.c b/usr.bin/tmux/cmd-respawn-window.c index 4d450affa62..e9ac69d01c8 100644 --- a/usr.bin/tmux/cmd-respawn-window.c +++ b/usr.bin/tmux/cmd-respawn-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-respawn-window.c,v 1.4 2009/07/24 19:35:33 nicm Exp $ */ +/* $OpenBSD: cmd-respawn-window.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_respawn_window_entry = { cmd_target_init, cmd_target_parse, cmd_respawn_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-rotate-window.c b/usr.bin/tmux/cmd-rotate-window.c index d18f704d6d3..4fdc0a221b1 100644 --- a/usr.bin/tmux/cmd-rotate-window.c +++ b/usr.bin/tmux/cmd-rotate-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rotate-window.c,v 1.8 2009/07/21 17:57:29 nicm Exp $ */ +/* $OpenBSD: cmd-rotate-window.c,v 1.9 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,8 +34,6 @@ const struct cmd_entry cmd_rotate_window_entry = { cmd_rotate_window_init, cmd_target_parse, cmd_rotate_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c index b6ae18dc8e2..22ea1c48b00 100644 --- a/usr.bin/tmux/cmd-save-buffer.c +++ b/usr.bin/tmux/cmd-save-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-save-buffer.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-save-buffer.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -37,8 +37,6 @@ const struct cmd_entry cmd_save_buffer_entry = { cmd_buffer_init, cmd_buffer_parse, cmd_save_buffer_exec, - cmd_buffer_send, - cmd_buffer_recv, cmd_buffer_free, cmd_buffer_print }; diff --git a/usr.bin/tmux/cmd-scroll-mode.c b/usr.bin/tmux/cmd-scroll-mode.c index d5085b29d04..a9f7906c762 100644 --- a/usr.bin/tmux/cmd-scroll-mode.c +++ b/usr.bin/tmux/cmd-scroll-mode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-scroll-mode.c,v 1.4 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-scroll-mode.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,8 +34,6 @@ const struct cmd_entry cmd_scroll_mode_entry = { cmd_scroll_mode_init, cmd_target_parse, cmd_scroll_mode_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-select-layout.c b/usr.bin/tmux/cmd-select-layout.c index 0fbfa77f052..7278e473874 100644 --- a/usr.bin/tmux/cmd-select-layout.c +++ b/usr.bin/tmux/cmd-select-layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-layout.c,v 1.4 2009/07/21 17:57:29 nicm Exp $ */ +/* $OpenBSD: cmd-select-layout.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,8 +34,6 @@ const struct cmd_entry cmd_select_layout_entry = { cmd_select_layout_init, cmd_target_parse, cmd_select_layout_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-select-pane.c b/usr.bin/tmux/cmd-select-pane.c index 725d3bd4286..5e7d3509150 100644 --- a/usr.bin/tmux/cmd-select-pane.c +++ b/usr.bin/tmux/cmd-select-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-pane.c,v 1.5 2009/07/20 19:35:33 nicm Exp $ */ +/* $OpenBSD: cmd-select-pane.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_select_pane_entry = { cmd_pane_init, cmd_pane_parse, cmd_select_pane_exec, - cmd_pane_send, - cmd_pane_recv, cmd_pane_free, cmd_pane_print }; diff --git a/usr.bin/tmux/cmd-select-prompt.c b/usr.bin/tmux/cmd-select-prompt.c index 76618175484..5606ea733f0 100644 --- a/usr.bin/tmux/cmd-select-prompt.c +++ b/usr.bin/tmux/cmd-select-prompt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-prompt.c,v 1.4 2009/07/17 06:13:27 nicm Exp $ */ +/* $OpenBSD: cmd-select-prompt.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -37,8 +37,6 @@ const struct cmd_entry cmd_select_prompt_entry = { cmd_target_init, cmd_target_parse, cmd_select_prompt_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-select-window.c b/usr.bin/tmux/cmd-select-window.c index ea4daa6af85..b3794c1f707 100644 --- a/usr.bin/tmux/cmd-select-window.c +++ b/usr.bin/tmux/cmd-select-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-select-window.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-select-window.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_select_window_entry = { cmd_select_window_init, cmd_target_parse, cmd_select_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c index 10abebbf5c5..55eb22b0510 100644 --- a/usr.bin/tmux/cmd-send-keys.c +++ b/usr.bin/tmux/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-keys.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -28,8 +28,6 @@ int cmd_send_keys_parse(struct cmd *, int, char **, char **); int cmd_send_keys_exec(struct cmd *, struct cmd_ctx *); -void cmd_send_keys_send(struct cmd *, struct buffer *); -void cmd_send_keys_recv(struct cmd *, struct buffer *); void cmd_send_keys_free(struct cmd *); size_t cmd_send_keys_print(struct cmd *, char *, size_t); @@ -47,8 +45,6 @@ const struct cmd_entry cmd_send_keys_entry = { NULL, cmd_send_keys_parse, cmd_send_keys_exec, - cmd_send_keys_send, - cmd_send_keys_recv, cmd_send_keys_free, cmd_send_keys_print }; @@ -128,28 +124,6 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_send_keys_send(struct cmd *self, struct buffer *b) -{ - struct cmd_send_keys_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); - buffer_write(b, data->keys, data->nkeys * sizeof *data->keys); -} - -void -cmd_send_keys_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_send_keys_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); - data->keys = xcalloc(data->nkeys, sizeof *data->keys); - buffer_read(b, data->keys, data->nkeys * sizeof *data->keys); -} - -void cmd_send_keys_free(struct cmd *self) { struct cmd_send_keys_data *data = self->data; diff --git a/usr.bin/tmux/cmd-send-prefix.c b/usr.bin/tmux/cmd-send-prefix.c index 20898d3ab91..0bb750ff094 100644 --- a/usr.bin/tmux/cmd-send-prefix.c +++ b/usr.bin/tmux/cmd-send-prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-prefix.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-send-prefix.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_send_prefix_entry = { cmd_target_init, cmd_target_parse, cmd_send_prefix_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-server-info.c b/usr.bin/tmux/cmd-server-info.c index 8d71d57248c..eb909d7b99c 100644 --- a/usr.bin/tmux/cmd-server-info.c +++ b/usr.bin/tmux/cmd-server-info.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-server-info.c,v 1.3 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-server-info.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -41,8 +41,6 @@ const struct cmd_entry cmd_server_info_entry = { NULL, cmd_server_info_exec, NULL, - NULL, - NULL, NULL }; diff --git a/usr.bin/tmux/cmd-set-buffer.c b/usr.bin/tmux/cmd-set-buffer.c index 7e2596ee6c6..d3a853922f2 100644 --- a/usr.bin/tmux/cmd-set-buffer.c +++ b/usr.bin/tmux/cmd-set-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-buffer.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-set-buffer.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_set_buffer_entry = { cmd_buffer_init, cmd_buffer_parse, cmd_set_buffer_exec, - cmd_buffer_send, - cmd_buffer_recv, cmd_buffer_free, cmd_buffer_print }; diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index e4c094e82ee..1a98c35382d 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.8 2009/07/20 14:32:09 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.9 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_set_option_entry = { NULL, cmd_option_parse, cmd_set_option_exec, - cmd_option_send, - cmd_option_recv, cmd_option_free, cmd_option_print }; diff --git a/usr.bin/tmux/cmd-set-password.c b/usr.bin/tmux/cmd-set-password.c index b23725ac03e..0eddce7ad63 100644 --- a/usr.bin/tmux/cmd-set-password.c +++ b/usr.bin/tmux/cmd-set-password.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-password.c,v 1.3 2009/07/21 21:20:07 nicm Exp $ */ +/* $OpenBSD: cmd-set-password.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,8 +29,6 @@ int cmd_set_password_parse(struct cmd *, int, char **, char **); int cmd_set_password_exec(struct cmd *, struct cmd_ctx *); -void cmd_set_password_send(struct cmd *, struct buffer *); -void cmd_set_password_recv(struct cmd *, struct buffer *); void cmd_set_password_free(struct cmd *); void cmd_set_password_init(struct cmd *, int); size_t cmd_set_password_print(struct cmd *, char *, size_t); @@ -47,8 +45,6 @@ const struct cmd_entry cmd_set_password_entry = { cmd_set_password_init, cmd_set_password_parse, cmd_set_password_exec, - cmd_set_password_send, - cmd_set_password_recv, cmd_set_password_free, cmd_set_password_print }; @@ -123,25 +119,6 @@ cmd_set_password_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_set_password_send(struct cmd *self, struct buffer *b) -{ - struct cmd_set_password_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->password); -} - -void -cmd_set_password_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_set_password_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->password = cmd_recv_string(b); -} - -void cmd_set_password_free(struct cmd *self) { struct cmd_set_password_data *data = self->data; diff --git a/usr.bin/tmux/cmd-set-window-option.c b/usr.bin/tmux/cmd-set-window-option.c index e99c33a0e25..0ed1bda0cbd 100644 --- a/usr.bin/tmux/cmd-set-window-option.c +++ b/usr.bin/tmux/cmd-set-window-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-window-option.c,v 1.7 2009/07/20 09:15:18 nicm Exp $ */ +/* $OpenBSD: cmd-set-window-option.c,v 1.8 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_set_window_option_entry = { NULL, cmd_option_parse, cmd_set_window_option_exec, - cmd_option_send, - cmd_option_recv, cmd_option_free, cmd_option_print }; diff --git a/usr.bin/tmux/cmd-show-buffer.c b/usr.bin/tmux/cmd-show-buffer.c index 87be5325d0d..38bf9c89f0d 100644 --- a/usr.bin/tmux/cmd-show-buffer.c +++ b/usr.bin/tmux/cmd-show-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-show-buffer.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-show-buffer.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_show_buffer_entry = { cmd_buffer_init, cmd_buffer_parse, cmd_show_buffer_exec, - cmd_buffer_send, - cmd_buffer_recv, cmd_buffer_free, cmd_buffer_print }; diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c index 4a65acbe8ba..b3bd820f04d 100644 --- a/usr.bin/tmux/cmd-show-options.c +++ b/usr.bin/tmux/cmd-show-options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-show-options.c,v 1.4 2009/07/15 07:50:34 nicm Exp $ */ +/* $OpenBSD: cmd-show-options.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_show_options_entry = { cmd_target_init, cmd_target_parse, cmd_show_options_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-show-window-options.c b/usr.bin/tmux/cmd-show-window-options.c index 0f60512fba0..7674f20305a 100644 --- a/usr.bin/tmux/cmd-show-window-options.c +++ b/usr.bin/tmux/cmd-show-window-options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-show-window-options.c,v 1.4 2009/07/15 07:50:34 nicm Exp $ */ +/* $OpenBSD: cmd-show-window-options.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,8 +36,6 @@ const struct cmd_entry cmd_show_window_options_entry = { cmd_target_init, cmd_target_parse, cmd_show_window_options_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index f28c4f1000a..6193a4fafc7 100644 --- a/usr.bin/tmux/cmd-source-file.c +++ b/usr.bin/tmux/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-source-file.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -26,8 +26,6 @@ int cmd_source_file_parse(struct cmd *, int, char **, char **); int cmd_source_file_exec(struct cmd *, struct cmd_ctx *); -void cmd_source_file_send(struct cmd *, struct buffer *); -void cmd_source_file_recv(struct cmd *, struct buffer *); void cmd_source_file_free(struct cmd *); void cmd_source_file_init(struct cmd *, int); size_t cmd_source_file_print(struct cmd *, char *, size_t); @@ -43,8 +41,6 @@ const struct cmd_entry cmd_source_file_entry = { cmd_source_file_init, cmd_source_file_parse, cmd_source_file_exec, - cmd_source_file_send, - cmd_source_file_recv, cmd_source_file_free, cmd_source_file_print }; @@ -104,25 +100,6 @@ cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_source_file_send(struct cmd *self, struct buffer *b) -{ - struct cmd_source_file_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->path); -} - -void -cmd_source_file_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_source_file_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->path = cmd_recv_string(b); -} - -void cmd_source_file_free(struct cmd *self) { struct cmd_source_file_data *data = self->data; diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c index ad27dd08ec0..2585b1f15d4 100644 --- a/usr.bin/tmux/cmd-split-window.c +++ b/usr.bin/tmux/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-split-window.c,v 1.6 2009/07/22 21:34:36 nicm Exp $ */ +/* $OpenBSD: cmd-split-window.c,v 1.7 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,8 +29,6 @@ int cmd_split_window_parse(struct cmd *, int, char **, char **); int cmd_split_window_exec(struct cmd *, struct cmd_ctx *); -void cmd_split_window_send(struct cmd *, struct buffer *); -void cmd_split_window_recv(struct cmd *, struct buffer *); void cmd_split_window_free(struct cmd *); void cmd_split_window_init(struct cmd *, int); size_t cmd_split_window_print(struct cmd *, char *, size_t); @@ -51,8 +49,6 @@ const struct cmd_entry cmd_split_window_entry = { cmd_split_window_init, cmd_split_window_parse, cmd_split_window_exec, - cmd_split_window_send, - cmd_split_window_recv, cmd_split_window_free, cmd_split_window_print }; @@ -212,27 +208,6 @@ error: } void -cmd_split_window_send(struct cmd *self, struct buffer *b) -{ - struct cmd_split_window_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); - cmd_send_string(b, data->cmd); -} - -void -cmd_split_window_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_split_window_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); - data->cmd = cmd_recv_string(b); -} - -void cmd_split_window_free(struct cmd *self) { struct cmd_split_window_data *data = self->data; diff --git a/usr.bin/tmux/cmd-start-server.c b/usr.bin/tmux/cmd-start-server.c index 2a3855f2092..e8ecc029272 100644 --- a/usr.bin/tmux/cmd-start-server.c +++ b/usr.bin/tmux/cmd-start-server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-start-server.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-start-server.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -34,8 +34,6 @@ const struct cmd_entry cmd_start_server_entry = { NULL, cmd_start_server_exec, NULL, - NULL, - NULL, NULL }; diff --git a/usr.bin/tmux/cmd-suspend-client.c b/usr.bin/tmux/cmd-suspend-client.c index ac01d6eebe9..6d6fcd96237 100644 --- a/usr.bin/tmux/cmd-suspend-client.c +++ b/usr.bin/tmux/cmd-suspend-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-suspend-client.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-suspend-client.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -41,8 +41,6 @@ const struct cmd_entry cmd_suspend_client_entry = { cmd_target_init, cmd_target_parse, cmd_suspend_client_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-swap-pane.c b/usr.bin/tmux/cmd-swap-pane.c index bcc03be7ebe..7d5437516d8 100644 --- a/usr.bin/tmux/cmd-swap-pane.c +++ b/usr.bin/tmux/cmd-swap-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-swap-pane.c,v 1.6 2009/07/20 07:13:31 nicm Exp $ */ +/* $OpenBSD: cmd-swap-pane.c,v 1.7 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -28,8 +28,6 @@ int cmd_swap_pane_parse(struct cmd *, int, char **, char **); int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *); -void cmd_swap_pane_send(struct cmd *, struct buffer *); -void cmd_swap_pane_recv(struct cmd *, struct buffer *); void cmd_swap_pane_free(struct cmd *); void cmd_swap_pane_init(struct cmd *, int); size_t cmd_swap_pane_print(struct cmd *, char *, size_t); @@ -50,8 +48,6 @@ const struct cmd_entry cmd_swap_pane_entry = { cmd_swap_pane_init, cmd_swap_pane_parse, cmd_swap_pane_exec, - cmd_swap_pane_send, - cmd_swap_pane_recv, cmd_swap_pane_free, cmd_swap_pane_print }; @@ -235,25 +231,6 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_swap_pane_send(struct cmd *self, struct buffer *b) -{ - struct cmd_swap_pane_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->target); -} - -void -cmd_swap_pane_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_swap_pane_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->target = cmd_recv_string(b); -} - -void cmd_swap_pane_free(struct cmd *self) { struct cmd_swap_pane_data *data = self->data; diff --git a/usr.bin/tmux/cmd-swap-window.c b/usr.bin/tmux/cmd-swap-window.c index 40896d5c0de..e51609f6e47 100644 --- a/usr.bin/tmux/cmd-swap-window.c +++ b/usr.bin/tmux/cmd-swap-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-swap-window.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-swap-window.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -35,8 +35,6 @@ const struct cmd_entry cmd_swap_window_entry = { cmd_srcdst_init, cmd_srcdst_parse, cmd_swap_window_exec, - cmd_srcdst_send, - cmd_srcdst_recv, cmd_srcdst_free, cmd_srcdst_print }; diff --git a/usr.bin/tmux/cmd-switch-client.c b/usr.bin/tmux/cmd-switch-client.c index 3e3274ef427..a2573a9905d 100644 --- a/usr.bin/tmux/cmd-switch-client.c +++ b/usr.bin/tmux/cmd-switch-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-switch-client.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */ +/* $OpenBSD: cmd-switch-client.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,8 +29,6 @@ int cmd_switch_client_parse(struct cmd *, int, char **, char **); int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *); -void cmd_switch_client_send(struct cmd *, struct buffer *); -void cmd_switch_client_recv(struct cmd *, struct buffer *); void cmd_switch_client_free(struct cmd *); size_t cmd_switch_client_print(struct cmd *, char *, size_t); @@ -46,8 +44,6 @@ const struct cmd_entry cmd_switch_client_entry = { NULL, cmd_switch_client_parse, cmd_switch_client_exec, - cmd_switch_client_send, - cmd_switch_client_recv, cmd_switch_client_free, cmd_switch_client_print }; @@ -112,27 +108,6 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx) } void -cmd_switch_client_send(struct cmd *self, struct buffer *b) -{ - struct cmd_switch_client_data *data = self->data; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->name); - cmd_send_string(b, data->target); -} - -void -cmd_switch_client_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_switch_client_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->name = cmd_recv_string(b); - data->target = cmd_recv_string(b); -} - -void cmd_switch_client_free(struct cmd *self) { struct cmd_switch_client_data *data = self->data; diff --git a/usr.bin/tmux/cmd-unbind-key.c b/usr.bin/tmux/cmd-unbind-key.c index 5415c601833..63b8aa0f998 100644 --- a/usr.bin/tmux/cmd-unbind-key.c +++ b/usr.bin/tmux/cmd-unbind-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-unbind-key.c,v 1.3 2009/07/24 14:52:47 nicm Exp $ */ +/* $OpenBSD: cmd-unbind-key.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,8 +26,6 @@ int cmd_unbind_key_parse(struct cmd *, int, char **, char **); int cmd_unbind_key_exec(struct cmd *, struct cmd_ctx *); -void cmd_unbind_key_send(struct cmd *, struct buffer *); -void cmd_unbind_key_recv(struct cmd *, struct buffer *); void cmd_unbind_key_free(struct cmd *); struct cmd_unbind_key_data { @@ -41,8 +39,6 @@ const struct cmd_entry cmd_unbind_key_entry = { NULL, cmd_unbind_key_parse, cmd_unbind_key_exec, - cmd_unbind_key_send, - cmd_unbind_key_recv, cmd_unbind_key_free, NULL }; @@ -100,23 +96,6 @@ cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx) } void -cmd_unbind_key_send(struct cmd *self, struct buffer *b) -{ - struct cmd_unbind_key_data *data = self->data; - - buffer_write(b, data, sizeof *data); -} - -void -cmd_unbind_key_recv(struct cmd *self, struct buffer *b) -{ - struct cmd_unbind_key_data *data; - - self->data = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); -} - -void cmd_unbind_key_free(struct cmd *self) { struct cmd_unbind_key_data *data = self->data; diff --git a/usr.bin/tmux/cmd-unlink-window.c b/usr.bin/tmux/cmd-unlink-window.c index 181f75247de..ee21d121648 100644 --- a/usr.bin/tmux/cmd-unlink-window.c +++ b/usr.bin/tmux/cmd-unlink-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-unlink-window.c,v 1.3 2009/07/15 08:05:56 nicm Exp $ */ +/* $OpenBSD: cmd-unlink-window.c,v 1.4 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_unlink_window_entry = { cmd_target_init, cmd_target_parse, cmd_unlink_window_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd-up-pane.c b/usr.bin/tmux/cmd-up-pane.c index 86419b9933f..576ab456470 100644 --- a/usr.bin/tmux/cmd-up-pane.c +++ b/usr.bin/tmux/cmd-up-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-up-pane.c,v 1.5 2009/07/20 19:35:33 nicm Exp $ */ +/* $OpenBSD: cmd-up-pane.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,8 +33,6 @@ const struct cmd_entry cmd_up_pane_entry = { cmd_target_init, cmd_target_parse, cmd_up_pane_exec, - cmd_target_send, - cmd_target_recv, cmd_target_free, cmd_target_print }; diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index 15c6f0d232f..c63d2e01a19 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.9 2009/07/24 18:46:40 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.10 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -109,6 +109,64 @@ struct session *cmd_lookup_session(const char *, int *); struct winlink *cmd_lookup_window(struct session *, const char *, int *); int cmd_lookup_index(struct session *, const char *, int *); +int +cmd_pack_argv(int argc, char **argv, char *buf, size_t len) +{ + size_t arglen; + int i; + + *buf = '\0'; + for (i = 0; i < argc; i++) { + if (strlcpy(buf, argv[i], len) >= len) + return (-1); + arglen = strlen(argv[i]) + 1; + buf += arglen; + len -= arglen; + } + + return (0); +} + +int +cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv) +{ + int i; + size_t arglen; + + if (argc == 0) + return (0); + *argv = xcalloc(argc, sizeof **argv); + + buf[len - 1] = '\0'; + for (i = 0; i < argc; i++) { + if (len == 0) { + cmd_free_argv(argc, *argv); + return (-1); + } + + arglen = strlen(buf) + 1; + (*argv)[i] = xstrdup(buf); + buf += arglen; + len -= arglen; + } + + return (0); +} + +void +cmd_free_argv(int argc, char **argv) +{ + int i; + + if (argc == 0) + return; + for (i = 0; i < argc; i++) { + if (argv[i] != NULL) + xfree(argv[i]); + } + xfree(argv); +} + struct cmd * cmd_parse(int argc, char **argv, char **cause) { @@ -205,53 +263,6 @@ cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx) } void -cmd_send(struct cmd *cmd, struct buffer *b) -{ - const struct cmd_entry **entryp; - u_int n; - - n = 0; - for (entryp = cmd_table; *entryp != NULL; entryp++) { - if (*entryp == cmd->entry) - break; - n++; - } - if (*entryp == NULL) - fatalx("command not found"); - - buffer_write(b, &n, sizeof n); - - if (cmd->entry->send != NULL) - cmd->entry->send(cmd, b); -} - -struct cmd * -cmd_recv(struct buffer *b) -{ - const struct cmd_entry **entryp; - struct cmd *cmd; - u_int m, n; - - buffer_read(b, &m, sizeof m); - - n = 0; - for (entryp = cmd_table; *entryp != NULL; entryp++) { - if (n == m) - break; - n++; - } - if (*entryp == NULL) - fatalx("command not found"); - - cmd = xmalloc(sizeof *cmd); - cmd->entry = *entryp; - - if (cmd->entry->recv != NULL) - cmd->entry->recv(cmd, b); - return (cmd); -} - -void cmd_free(struct cmd *cmd) { if (cmd->data != NULL && cmd->entry->free != NULL) @@ -268,41 +279,6 @@ cmd_print(struct cmd *cmd, char *buf, size_t len) return (cmd->entry->print(cmd, buf, len)); } -void -cmd_send_string(struct buffer *b, const char *s) -{ - size_t n; - - if (s == NULL) { - n = 0; - buffer_write(b, &n, sizeof n); - return; - } - - n = strlen(s) + 1; - buffer_write(b, &n, sizeof n); - - buffer_write(b, s, n); -} - -char * -cmd_recv_string(struct buffer *b) -{ - char *s; - size_t n; - - buffer_read(b, &n, sizeof n); - - if (n == 0) - return (NULL); - - s = xmalloc(n); - buffer_read(b, s, n); - s[n - 1] = '\0'; - - return (s); -} - /* * Figure out the current session. Use: 1) the current session, if the command * context has one; 2) the session specified in the TMUX variable from the diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 8beef15e7e3..22ba7eeefa6 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.9 2009/07/20 14:37:51 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.10 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -48,6 +48,15 @@ server_fill_environ(struct session *s) } void +server_write_error(struct client *c, const char *msg) +{ + struct msg_print_data printdata; + + strlcpy(printdata.msg, msg, sizeof printdata.msg); + server_write_client(c, MSG_ERROR, &printdata, sizeof printdata); +} + +void server_write_client( struct client *c, enum hdrtype type, const void *buf, size_t len) { @@ -220,7 +229,7 @@ wrong: password_failures++; for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); - if (c == NULL || c->prompt_buffer == NULL) + if (c == NULL || c->prompt_buffer == NULL) continue; *c->prompt_buffer = '\0'; diff --git a/usr.bin/tmux/server-msg.c b/usr.bin/tmux/server-msg.c index 6abcaf23c64..475bad2bf1d 100644 --- a/usr.bin/tmux/server-msg.c +++ b/usr.bin/tmux/server-msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-msg.c,v 1.6 2009/07/23 21:19:11 nicm Exp $ */ +/* $OpenBSD: server-msg.c,v 1.7 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -83,46 +83,43 @@ server_msg_dispatch(struct client *c) void printflike2 server_msg_fn_command_error(struct cmd_ctx *ctx, const char *fmt, ...) { - va_list ap; - char *msg; + struct msg_print_data data; + va_list ap; va_start(ap, fmt); - xvasprintf(&msg, fmt, ap); + xvsnprintf(data.msg, sizeof data.msg, fmt, ap); va_end(ap); - server_write_client(ctx->cmdclient, MSG_ERROR, msg, strlen(msg)); - xfree(msg); + server_write_client(ctx->cmdclient, MSG_ERROR, &data, sizeof data); } void printflike2 server_msg_fn_command_print(struct cmd_ctx *ctx, const char *fmt, ...) { - va_list ap; - char *msg; + struct msg_print_data data; + va_list ap; va_start(ap, fmt); - xvasprintf(&msg, fmt, ap); + xvsnprintf(data.msg, sizeof data.msg, fmt, ap); va_end(ap); - server_write_client(ctx->cmdclient, MSG_PRINT, msg, strlen(msg)); - xfree(msg); + server_write_client(ctx->cmdclient, MSG_PRINT, &data, sizeof data); } void printflike2 server_msg_fn_command_info(struct cmd_ctx *ctx, const char *fmt, ...) { - va_list ap; - char *msg; + struct msg_print_data data; + va_list ap; if (be_quiet) return; va_start(ap, fmt); - xvasprintf(&msg, fmt, ap); + xvsnprintf(data.msg, sizeof data.msg, fmt, ap); va_end(ap); - server_write_client(ctx->cmdclient, MSG_PRINT, msg, strlen(msg)); - xfree(msg); + server_write_client(ctx->cmdclient, MSG_PRINT, &data, sizeof data); } void @@ -130,14 +127,15 @@ server_msg_fn_command(struct hdr *hdr, struct client *c) { struct msg_command_data data; struct cmd_ctx ctx; - struct cmd_list *cmdlist; + struct cmd_list *cmdlist = NULL; struct cmd *cmd; + int argc; + char **argv, *cause; if (hdr->size < sizeof data) fatalx("bad MSG_COMMAND size"); buffer_read(c->in, &data, sizeof data); - cmdlist = cmd_list_recv(c->in); server_activity = time(NULL); ctx.error = server_msg_fn_command_error; @@ -150,15 +148,33 @@ server_msg_fn_command(struct hdr *hdr, struct client *c) ctx.cmdclient = c; + argc = data.argc; + data.argv[(sizeof data.argv) - 1] = '\0'; + if (cmd_unpack_argv(data.argv, sizeof data.argv, argc, &argv) != 0) { + server_msg_fn_command_error(&ctx, "command too long"); + goto error; + } + + if (argc == 0) { + argc = 1; + argv = xcalloc(1, sizeof *argv); + *argv = xstrdup("new-session"); + } + + if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) { + server_msg_fn_command_error(&ctx, "%s", cause); + cmd_free_argv(argc, argv); + goto error; + } + cmd_free_argv(argc, argv); + if (data.pid != -1) { TAILQ_FOREACH(cmd, cmdlist, qentry) { if (cmd->entry->flags & CMD_CANTNEST) { server_msg_fn_command_error(&ctx, "sessions should be nested with care. " "unset $TMUX to force"); - cmd_list_free(cmdlist); - server_write_client(c, MSG_EXIT, NULL, 0); - return; + goto error; } } } @@ -166,27 +182,28 @@ server_msg_fn_command(struct hdr *hdr, struct client *c) if (cmd_list_exec(cmdlist, &ctx) != 1) server_write_client(c, MSG_EXIT, NULL, 0); cmd_list_free(cmdlist); + return; + +error: + if (cmdlist != NULL) + cmd_list_free(cmdlist); + server_write_client(c, MSG_EXIT, NULL, 0); } void server_msg_fn_identify(struct hdr *hdr, struct client *c) { struct msg_identify_data data; - char *term; if (hdr->size < sizeof data) fatalx("bad MSG_IDENTIFY size"); buffer_read(c->in, &data, sizeof data); - term = cmd_recv_string(c->in); log_debug("identify msg from client: %u,%u (%d)", data.sx, data.sy, data.version); if (data.version != PROTOCOL_VERSION) { -#define MSG "protocol version mismatch" - server_write_client(c, MSG_ERROR, MSG, (sizeof MSG) - 1); -#undef MSG - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_error(c, "protocol version mismatch"); return; } @@ -199,7 +216,8 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c) c->cwd = xstrdup(data.cwd); data.tty[(sizeof data.tty) - 1] = '\0'; - tty_init(&c->tty, data.tty, term); + data.term[(sizeof data.term) - 1] = '\0'; + tty_init(&c->tty, data.tty, data.term); if (data.flags & IDENTIFY_UTF8) c->tty.flags |= TTY_UTF8; if (data.flags & IDENTIFY_256COLOURS) @@ -209,9 +227,6 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c) if (data.flags & IDENTIFY_HASDEFAULTS) c->tty.term_flags |= TERM_HASDEFAULTS; - if (term != NULL) - xfree(term); - c->flags |= CLIENT_TERMINAL; } @@ -262,24 +277,20 @@ server_msg_fn_exiting(struct hdr *hdr, struct client *c) void server_msg_fn_unlock(struct hdr *hdr, struct client *c) { - char *pass; + struct msg_unlock_data data; - if (hdr->size == 0) + if (hdr->size != sizeof data) fatalx("bad MSG_UNLOCK size"); - pass = cmd_recv_string(c->in); + buffer_read(c->in, &data, sizeof data); log_debug("unlock msg from client"); - if (server_unlock(pass) != 0) { -#define MSG "bad password" - server_write_client(c, MSG_ERROR, MSG, (sizeof MSG) - 1); -#undef MSG - } + data.pass[(sizeof data.pass) - 1] = '\0'; + if (server_unlock(data.pass) != 0) + server_write_error(c, "bad password"); + memset(&data, 0, sizeof data); server_write_client(c, MSG_EXIT, NULL, 0); - - memset(pass, 0, strlen(pass)); - xfree(pass); } void diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index da3c7ab15ec..1f2910aa480 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.20 2009/07/22 21:58:56 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.21 2009/07/26 12:58:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -57,6 +57,8 @@ char *socket_path; __dead void usage(void); char *makesockpath(const char *); +int prepare_unlock(enum hdrtype *, void **, size_t *, int); +int prepare_cmd(enum hdrtype *, void **, size_t *, int, char **); __dead void usage(void) @@ -201,18 +203,69 @@ makesockpath(const char *label) } int +prepare_unlock(enum hdrtype *msg, void **buf, size_t *len, int argc) +{ + static struct msg_unlock_data unlockdata; + char *pass; + + if (argc != 0) { + log_warnx("can't specify a command when unlocking"); + return (-1); + } + + if ((pass = getpass("Password: ")) == NULL) + return (-1); + + if (strlen(pass) >= sizeof unlockdata.pass) { + log_warnx("password too long"); + return (-1); + } + + strlcpy(unlockdata.pass, pass, sizeof unlockdata.pass); + memset(pass, 0, strlen(pass)); + + *buf = &unlockdata; + *len = sizeof unlockdata; + + *msg = MSG_UNLOCK; + return (0); +} + +int +prepare_cmd(enum hdrtype *msg, void **buf, size_t *len, int argc, char **argv) +{ + static struct msg_command_data cmddata; + + client_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) { struct client_ctx cctx; - struct msg_command_data cmddata; - struct buffer *b; struct cmd_list *cmdlist; struct cmd *cmd; struct pollfd pfd; + enum hdrtype msg; struct hdr hdr; struct passwd *pw; - char *s, *path, *label, *cause, *home, *pass = NULL; + struct msg_print_data printdata; + char *s, *path, *label, *home, *cause; char cwd[MAXPATHLEN]; + void *buf; + size_t len; int retcode, opt, flags, unlock, cmdflags = 0; unlock = flags = 0; @@ -364,7 +417,7 @@ main(int argc, char **argv) exit(1); } } - + if (label == NULL) label = xstrdup("default"); if (path == NULL && (path = makesockpath(label)) == NULL) { @@ -383,36 +436,35 @@ main(int argc, char **argv) options_set_string(&global_s_options, "default-path", "%s", cwd); if (unlock) { - if (argc != 0) { - log_warnx("can't specify a command when unlocking"); + if (prepare_unlock(&msg, &buf, &len, argc) != 0) exit(1); - } - cmdlist = NULL; - if ((pass = getpass("Password: ")) == NULL) + } else { + if (prepare_cmd(&msg, &buf, &len, argc, argv) != 0) exit(1); + } + + if (unlock) cmdflags &= ~CMD_STARTSERVER; - } else { - if (argc == 0) { - cmd = xmalloc(sizeof *cmd); - cmd->entry = &cmd_new_session_entry; - cmd->entry->init(cmd, 0); - - cmdlist = xmalloc(sizeof *cmdlist); - TAILQ_INIT(cmdlist); - TAILQ_INSERT_HEAD(cmdlist, cmd, qentry); - } else { - cmdlist = cmd_list_parse(argc, argv, &cause); - if (cmdlist == NULL) { - log_warnx("%s", cause); - exit(1); - } + else if (argc == 0) + cmdflags |= CMD_STARTSERVER; + else { + /* + * It sucks parsing the command string twice (in client and + * later in server) but it is necessary to get the start server + * flag. + */ + if ((cmdlist = cmd_list_parse(argc, argv, &cause)) == NULL) { + log_warnx("%s", cause); + exit(1); } + cmdflags &= ~CMD_STARTSERVER; TAILQ_FOREACH(cmd, cmdlist, qentry) { if (cmd->entry->flags & CMD_STARTSERVER) { cmdflags |= CMD_STARTSERVER; break; } } + cmd_list_free(cmdlist); } memset(&cctx, 0, sizeof cctx); @@ -420,20 +472,8 @@ main(int argc, char **argv) exit(1); xfree(path); - b = buffer_create(BUFSIZ); - if (unlock) { - cmd_send_string(b, pass); - memset(pass, 0, strlen(pass)); - client_write_server( - &cctx, MSG_UNLOCK, BUFFER_OUT(b), BUFFER_USED(b)); - } else { - cmd_list_send(cmdlist, b); - cmd_list_free(cmdlist); - client_fill_session(&cmddata); - client_write_server2(&cctx, MSG_COMMAND, - &cmddata, sizeof cmddata, BUFFER_OUT(b), BUFFER_USED(b)); - } - buffer_destroy(b); + client_write_server(&cctx, msg, buf, len); + memset(buf, 0, len); retcode = 0; for (;;) { @@ -467,12 +507,12 @@ main(int argc, char **argv) retcode = 1; /* FALLTHROUGH */ case MSG_PRINT: - if (hdr.size > INT_MAX - 1) + if (hdr.size < sizeof printdata) fatalx("bad MSG_PRINT size"); - log_info("%.*s", - (int) hdr.size, BUFFER_OUT(cctx.srv_in)); - if (hdr.size != 0) - buffer_remove(cctx.srv_in, hdr.size); + buffer_read(cctx.srv_in, &printdata, sizeof printdata); + + printdata.msg[(sizeof printdata.msg) - 1] = '\0'; + log_info("%s", printdata.msg); goto restart; case MSG_READY: retcode = client_main(&cctx); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 6dc712b1546..4013b76792f 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -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 <nicm@users.sourceforge.net> @@ -19,7 +19,7 @@ #ifndef TMUX_H #define TMUX_H -#define PROTOCOL_VERSION -14 +#define PROTOCOL_VERSION -15 #include <sys/param.h> #include <sys/time.h> @@ -62,6 +62,14 @@ extern char *__progname; /* 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 @@ enum hdrtype { 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 @@ struct msg_identify_data { char cwd[MAXPATHLEN]; + char term[TERMINAL_LENGTH]; + #define IDENTIFY_UTF8 0x1 #define IDENTIFY_256COLOURS 0x2 #define IDENTIFY_88COLOURS 0x4 @@ -320,8 +342,6 @@ struct msg_identify_data { u_int sx; u_int sy; - - size_t termlen; }; struct msg_resize_data { @@ -329,6 +349,10 @@ struct msg_resize_data { u_int sy; }; +struct msg_unlock_data { + char pass[PASS_MAX]; +}; + /* Editing keys. */ enum mode_key_cmd { MODEKEYCMD_BACKSPACE = 0x1000, @@ -907,8 +931,6 @@ struct cmd_entry { 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 @@ int paste_replace(struct paste_stack *, u_int, char *); 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 @@ extern const struct cmd_entry cmd_up_pane_entry; /* 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 @@ size_t cmd_prarg(char *, size_t, const char *, char *); #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 @@ size_t cmd_target_print(struct cmd *, char *, size_t); #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 @@ size_t cmd_srcdst_print(struct cmd *, char *, size_t); #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 @@ size_t cmd_buffer_print(struct cmd *, char *, size_t); #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 @@ size_t cmd_option_print(struct cmd *, char *, size_t); #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 @@ int client_msg_dispatch(struct client_ctx *); /* 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 @@ int server_msg_dispatch(struct client *); /* 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( |