diff options
82 files changed, 253 insertions, 780 deletions
diff --git a/client-fn.c b/client-fn.c index 3f42a105..b7a9b1f0 100644 --- a/client-fn.c +++ b/client-fn.c @@ -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/client-msg.c b/client-msg.c index 5a95ff62..845f10b0 100644 --- a/client-msg.c +++ b/client-msg.c @@ -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); } @@ -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/cmd-attach-session.c b/cmd-attach-session.c index 2d930560..3278ea7f 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -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/cmd-bind-key.c b/cmd-bind-key.c index 82ab14b0..41d8eeb8 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -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/cmd-break-pane.c b/cmd-break-pane.c index 8eeb7f42..6a237c6d 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -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/cmd-choose-session.c b/cmd-choose-session.c index 09c8216d..cf5e3c82 100644 --- a/cmd-choose-session.c +++ b/cmd-choose-session.c @@ -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/cmd-choose-window.c b/cmd-choose-window.c index 80a2518e..9386c5fa 100644 --- a/cmd-choose-window.c +++ b/cmd-choose-window.c @@ -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/cmd-clear-history.c b/cmd-clear-history.c index de24ac57..2e4c118d 100644 --- a/cmd-clear-history.c +++ b/cmd-clear-history.c @@ -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/cmd-clock-mode.c b/cmd-clock-mode.c index 4399b7ba..0fc43a54 100644 --- a/cmd-clock-mode.c +++ b/cmd-clock-mode.c @@ -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/cmd-command-prompt.c b/cmd-command-prompt.c index 872fa326..f729a66e 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -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/cmd-confirm-before.c b/cmd-confirm-before.c index f1f5bfe1..db799a4b 100644 --- a/cmd-confirm-before.c +++ b/cmd-confirm-before.c @@ -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/cmd-copy-buffer.c b/cmd-copy-buffer.c index 544cf1c6..7cef21ef 100644 --- a/cmd-copy-buffer.c +++ b/cmd-copy-buffer.c @@ -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/cmd-copy-mode.c b/cmd-copy-mode.c index e9891179..3e6b2228 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -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/cmd-delete-buffer.c b/cmd-delete-buffer.c index 81b69417..b193438c 100644 --- a/cmd-delete-buffer.c +++ b/cmd-delete-buffer.c @@ -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/cmd-detach-client.c b/cmd-detach-client.c index 0a28cdc7..dd480226 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -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/cmd-display-message.c b/cmd-display-message.c index 332b6e28..20758daa 100644 --- a/cmd-display-message.c +++ b/cmd-display-message.c @@ -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/cmd-down-pane.c b/cmd-down-pane.c index c3c12dba..242c6ac3 100644 --- a/cmd-down-pane.c +++ b/cmd-down-pane.c @@ -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/cmd-find-window.c b/cmd-find-window.c index 34ea75ec..0a1c38da 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -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/cmd-generic.c b/cmd-generic.c index ea0d4d16..39c18d51 100644 --- a/cmd-generic.c +++ b/cmd-generic.c @@ -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); |