diff options
39 files changed, 485 insertions, 407 deletions
@@ -1,3 +1,8 @@ +05 June 2008 + +* Infrastructure for printing arguments in list-keys output. Easy ones only for + now. + 04 June 2008 * Add some vi(1) key bindings in copy mode, and support binding ^[, ^\, ^] @@ -403,4 +408,4 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.109 2008-06-04 20:01:35 nicm Exp $ +$Id: CHANGES,v 1.110 2008-06-05 16:35:31 nicm Exp $ diff --git a/cmd-attach-session.c b/cmd-attach-session.c index 3a456a24..d4d3367e 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-attach-session.c,v 1.15 2008-06-03 16:55:09 nicm Exp $ */ +/* $Id: cmd-attach-session.c,v 1.16 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,11 +26,11 @@ * Attach existing session to the current terminal. */ -int cmd_attach_session_parse(struct cmd *, void **, int, char **, char **); -void cmd_attach_session_exec(void *, struct cmd_ctx *); -void cmd_attach_session_send(void *, struct buffer *); -void cmd_attach_session_recv(void **, struct buffer *); -void cmd_attach_session_free(void *); +int cmd_attach_session_parse(struct cmd *, int, char **, char **); +void cmd_attach_session_exec(struct cmd *, struct cmd_ctx *); +void cmd_attach_session_send(struct cmd *, struct buffer *); +void cmd_attach_session_recv(struct cmd *, struct buffer *); +void cmd_attach_session_free(struct cmd *); struct cmd_attach_session_data { char *cname; @@ -47,17 +47,17 @@ const struct cmd_entry cmd_attach_session_entry = { cmd_attach_session_send, cmd_attach_session_recv, cmd_attach_session_free, + NULL, NULL }; int -cmd_attach_session_parse( - struct cmd *self, void **ptr, int argc, char **argv, char **cause) +cmd_attach_session_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_attach_session_data *data; int opt; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); data->cname = NULL; data->sname = NULL; data->flag_detach = 0; @@ -93,14 +93,14 @@ cmd_attach_session_parse( usage: xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage); - cmd_attach_session_free(data); + self->entry->free(self); return (-1); } void -cmd_attach_session_exec(void *ptr, struct cmd_ctx *ctx) +cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_attach_session_data *data = ptr; + struct cmd_attach_session_data *data = self->data; struct session *s; char *cause; @@ -131,9 +131,9 @@ cmd_attach_session_exec(void *ptr, struct cmd_ctx *ctx) } void -cmd_attach_session_send(void *ptr, struct buffer *b) +cmd_attach_session_send(struct cmd *self, struct buffer *b) { - struct cmd_attach_session_data *data = ptr; + struct cmd_attach_session_data *data = self->data; buffer_write(b, data, sizeof *data); cmd_send_string(b, data->cname); @@ -141,20 +141,20 @@ cmd_attach_session_send(void *ptr, struct buffer *b) } void -cmd_attach_session_recv(void **ptr, struct buffer *b) +cmd_attach_session_recv(struct cmd *self, struct buffer *b) { struct cmd_attach_session_data *data; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); buffer_read(b, data, sizeof *data); data->cname = cmd_recv_string(b); data->sname = cmd_recv_string(b); } void -cmd_attach_session_free(void *ptr) +cmd_attach_session_free(struct cmd *self) { - struct cmd_attach_session_data *data = ptr; + struct cmd_attach_session_data *data = self->data; if (data->cname != NULL) xfree(data->cname); diff --git a/cmd-bind-key.c b/cmd-bind-key.c index f02c440b..03d38744 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-bind-key.c,v 1.12 2008-06-03 05:35:50 nicm Exp $ */ +/* $Id: cmd-bind-key.c,v 1.13 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -26,11 +26,11 @@ * Bind a key to a command, this recurses through cmd_*. */ -int cmd_bind_key_parse(struct cmd *, void **, int, char **, char **); -void cmd_bind_key_exec(void *, struct cmd_ctx *); -void cmd_bind_key_send(void *, struct buffer *); -void cmd_bind_key_recv(void **, struct buffer *); -void cmd_bind_key_free(void *); +int cmd_bind_key_parse(struct cmd *, int, char **, char **); +void 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 *); struct cmd_bind_key_data { int key; @@ -46,17 +46,17 @@ const struct cmd_entry cmd_bind_key_entry = { cmd_bind_key_send, cmd_bind_key_recv, cmd_bind_key_free, + NULL, NULL }; int -cmd_bind_key_parse( - struct cmd *self, void **ptr, int argc, char **argv, char **cause) +cmd_bind_key_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_bind_key_data *data; int opt; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); data->cmd = NULL; while ((opt = getopt(argc, argv, "")) != EOF) { @@ -86,14 +86,14 @@ usage: xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage); error: - cmd_bind_key_free(data); + self->entry->free(self); return (-1); } void -cmd_bind_key_exec(void *ptr, struct cmd_ctx *ctx) +cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_bind_key_data *data = ptr; + struct cmd_bind_key_data *data = self->data; if (data == NULL) return; @@ -106,28 +106,28 @@ cmd_bind_key_exec(void *ptr, struct cmd_ctx *ctx) } void -cmd_bind_key_send(void *ptr, struct buffer *b) +cmd_bind_key_send(struct cmd *self, struct buffer *b) { - struct cmd_bind_key_data *data = ptr; + struct cmd_bind_key_data *data = self->data; buffer_write(b, data, sizeof *data); cmd_send(data->cmd, b); } void -cmd_bind_key_recv(void **ptr, struct buffer *b) +cmd_bind_key_recv(struct cmd *self, struct buffer *b) { struct cmd_bind_key_data *data; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); buffer_read(b, data, sizeof *data); data->cmd = cmd_recv(b); } void -cmd_bind_key_free(void *ptr) +cmd_bind_key_free(struct cmd *self) { - struct cmd_bind_key_data *data = ptr; + struct cmd_bind_key_data *data = self->data; if (data->cmd != NULL) cmd_free(data->cmd); diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index 88123043..37bb4a2f 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-copy-mode.c,v 1.8 2008-06-03 05:35:50 nicm Exp $ */ +/* $Id: cmd-copy-mode.c,v 1.9 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Enter copy mode. Only valid when bound to a key. */ -void cmd_copy_mode_exec(void *, struct cmd_ctx *); +void cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_copy_mode_entry = { "copy-mode", NULL, @@ -35,15 +35,16 @@ const struct cmd_entry cmd_copy_mode_entry = { cmd_windowonly_send, cmd_windowonly_recv, cmd_windowonly_free, + NULL, NULL }; void -cmd_copy_mode_exec(void *ptr, struct cmd_ctx *ctx) +cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx) { struct winlink *wl; - if ((wl = cmd_windowonly_get(ptr, ctx, NULL)) == NULL) + if ((wl = cmd_windowonly_get(self, ctx, NULL)) == NULL) return; window_set_mode(wl->window, &window_copy_mode); diff --git a/cmd-detach-client.c b/cmd-detach-client.c index 934f948d..04ee1831 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-detach-client.c,v 1.4 2008-06-03 05:35:50 nicm Exp $ */ +/* $Id: cmd-detach-client.c,v 1.5 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Detach a client. */ -void cmd_detach_client_exec(void *, struct cmd_ctx *); +void cmd_detach_client_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_detach_client_entry = { "detach-client", "detach", @@ -35,15 +35,16 @@ const struct cmd_entry cmd_detach_client_entry = { cmd_clientonly_send, cmd_clientonly_recv, cmd_clientonly_free, - NULL + NULL, + cmd_clientonly_print }; void -cmd_detach_client_exec(void *ptr, struct cmd_ctx *ctx) +cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx) { struct client *c; - if ((c = cmd_clientonly_get(ptr, ctx)) == NULL) + if ((c = cmd_clientonly_get(self, ctx)) == NULL) return; server_write_client(c, MSG_DETACH, NULL, 0); diff --git a/cmd-generic.c b/cmd-generic.c index a5dad562..b045a7ee 100644 --- a/cmd-generic.c +++ b/cmd-generic.c @@ -1,4 +1,4 @@ -/* $Id: cmd-generic.c,v 1.5 2008-06-04 16:11:52 nicm Exp $ */ +/* $Id: cmd-generic.c,v 1.6 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,13 +24,12 @@ #include "tmux.h" int -cmd_clientonly_parse( - struct cmd *self, void **ptr, int argc, char **argv, char **cause) +cmd_clientonly_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_clientonly_data *data; int opt; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); data->cname = NULL; while ((opt = getopt(argc, argv, "c:")) != EOF) { @@ -53,33 +52,33 @@ cmd_clientonly_parse( usage: xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage); - self->entry->free(data); + self->entry->free(self); return (-1); } void -cmd_clientonly_send(void *ptr, struct buffer *b) +cmd_clientonly_send(struct cmd *self, struct buffer *b) { - struct cmd_clientonly_data *data = ptr; + struct cmd_clientonly_data *data = self->data; buffer_write(b, data, sizeof *data); cmd_send_string(b, data->cname); } void -cmd_clientonly_recv(void **ptr, struct buffer *b) +cmd_clientonly_recv(struct cmd *self, struct buffer *b) { struct cmd_clientonly_data *data; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); buffer_read(b, data, sizeof *data); data->cname = cmd_recv_string(b); } void -cmd_clientonly_free(void *ptr) +cmd_clientonly_free(struct cmd *self) { - struct cmd_clientonly_data *data = ptr; + struct cmd_clientonly_data *data = self->data; if (data->cname != NULL) xfree(data->cname); @@ -87,23 +86,35 @@ cmd_clientonly_free(void *ptr) } struct client * -cmd_clientonly_get(void *ptr, struct cmd_ctx *ctx) +cmd_clientonly_get(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_clientonly_data *data = ptr; + struct cmd_clientonly_data *data = self->data; if (data != NULL) return (cmd_find_client(ctx, data->cname)); return (cmd_find_client(ctx, NULL)); } +void +cmd_clientonly_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_clientonly_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s ", self->entry->name); + if (data == NULL) + return; + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, "-c %s ", data->cname); +} + int -cmd_sessiononly_parse( - struct cmd *self, void **ptr, int argc, char **argv, char **cause) +cmd_sessiononly_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_sessiononly_data *data; int opt; - - *ptr = data = xmalloc(sizeof *data); + + self->data = data = xmalloc(sizeof *data); data->cname = NULL; data->sname = NULL; @@ -135,14 +146,14 @@ cmd_sessiononly_parse( usage: xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage); - self->entry->free(data); + self->entry->free(self); return (-1); } void -cmd_sessiononly_send(void *ptr, struct buffer *b) +cmd_sessiononly_send(struct cmd *self, struct buffer *b) { - struct cmd_sessiononly_data *data = ptr; + struct cmd_sessiononly_data *data = self->data; buffer_write(b, data, sizeof *data); cmd_send_string(b, data->cname); @@ -150,20 +161,20 @@ cmd_sessiononly_send(void *ptr, struct buffer *b) } void -cmd_sessiononly_recv(void **ptr, struct buffer *b) +cmd_sessiononly_recv(struct cmd *self, struct buffer *b) { struct cmd_sessiononly_data *data; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); buffer_read(b, data, sizeof *data); data->cname = cmd_recv_string(b); data->sname = cmd_recv_string(b); } void -cmd_sessiononly_free(void *ptr) +cmd_sessiononly_free(struct cmd *self) { - struct cmd_sessiononly_data *data = ptr; + struct cmd_sessiononly_data *data = self->data; if (data->cname != NULL) xfree(data->cname); @@ -173,24 +184,38 @@ cmd_sessiononly_free(void *ptr) } struct session * -cmd_sessiononly_get(void *ptr, struct cmd_ctx *ctx) +cmd_sessiononly_get(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_sessiononly_data *data = ptr; + struct cmd_sessiononly_data *data = self->data; if (data != NULL) return (cmd_find_session(ctx, data->cname, data->sname)); return (cmd_find_session(ctx, NULL, NULL)); } +void +cmd_sessiononly_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_sessiononly_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s ", self->entry->name); + if (data == NULL) + return; + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, "-c %s ", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, "-s %s ", data->sname); +} + int -cmd_windowonly_parse( - struct cmd *self, void **ptr, int argc, char **argv, char **cause) +cmd_windowonly_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_windowonly_data *data; int opt; const char *errstr; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); data->cname = NULL; data->sname = NULL; data->idx = -1; @@ -231,14 +256,14 @@ usage: xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage); error: - self->entry->free(data); + self->entry->free(self); return (-1); } void -cmd_windowonly_send(void *ptr, struct buffer *b) +cmd_windowonly_send(struct cmd *self, struct buffer *b) { - struct cmd_windowonly_data *data = ptr; + struct cmd_windowonly_data *data = self->data; buffer_write(b, data, sizeof *data); cmd_send_string(b, data->cname); @@ -246,20 +271,20 @@ cmd_windowonly_send(void *ptr, struct buffer *b) } void -cmd_windowonly_recv(void **ptr, struct buffer *b) +cmd_windowonly_recv(struct cmd *self, struct buffer *b) { struct cmd_windowonly_data *data; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); buffer_read(b, data, sizeof *data); data->cname = cmd_recv_string(b); data->sname = cmd_recv_string(b); } void -cmd_windowonly_free(void *ptr) +cmd_windowonly_free(struct cmd *self) { - struct cmd_windowonly_data *data = ptr; + struct cmd_windowonly_data *data = self->data; if (data->cname != NULL) xfree(data->cname); @@ -269,15 +294,32 @@ cmd_windowonly_free(void *ptr) } struct winlink * -cmd_windowonly_get(void *ptr, struct cmd_ctx *ctx, struct session **sp) +cmd_windowonly_get(struct cmd *self, struct cmd_ctx *ctx, struct session **sp) { - struct cmd_windowonly_data *data = ptr; + struct cmd_windowonly_data *data = self->data; struct winlink *wl; if (data == NULL) { wl = cmd_find_window(ctx, NULL, NULL, -1, sp); return (wl); } - + return (cmd_find_window(ctx, data->cname, data->sname, data->idx, sp)); } + +void +cmd_windowonly_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_windowonly_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s ", self->entry->name); + if (data == NULL) + return; + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, "-c %s ", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, "-s %s ", data->sname); + if (off < len && data->idx != -1) + off += xsnprintf(buf + off, len - off, "-i %d ", data->idx); +} diff --git a/cmd-has-session.c b/cmd-has-session.c index fade7de7..df4951b4 100644 --- a/cmd-has-session.c +++ b/cmd-has-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-has-session.c,v 1.7 2008-06-03 05:35:50 nicm Exp $ */ +/* $Id: cmd-has-session.c,v 1.8 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Cause client to report an error and exit with 1 if session doesn't exist. */ -void cmd_has_session_exec(void *, struct cmd_ctx *); +void cmd_has_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_has_session_entry = { "has-session", "has", @@ -35,15 +35,16 @@ const struct cmd_entry cmd_has_session_entry = { cmd_sessiononly_send, cmd_sessiononly_recv, cmd_sessiononly_free, - NULL + NULL, + cmd_sessiononly_print }; void -cmd_has_session_exec(void *ptr, struct cmd_ctx *ctx) +cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx) { struct session *s; - if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL) + if ((s = cmd_sessiononly_get(self, ctx)) == NULL) return; if (ctx->cmdclient != NULL) diff --git a/cmd-kill-server.c b/cmd-kill-server.c index c4b3f7a6..a4d7c27c 100644 --- a/cmd-kill-server.c +++ b/cmd-kill-server.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-server.c,v 1.3 2008-06-03 18:13:54 nicm Exp $ */ +/* $Id: cmd-kill-server.c,v 1.4 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -27,7 +27,7 @@ * Kill the server and do nothing else. */ -void cmd_kill_server_exec(void *, struct cmd_ctx *); +void cmd_kill_server_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_kill_server_entry = { "kill-server", NULL, @@ -38,11 +38,12 @@ const struct cmd_entry cmd_kill_server_entry = { NULL, NULL, NULL, + NULL, NULL }; void -cmd_kill_server_exec(unused void *ptr, struct cmd_ctx *ctx) +cmd_kill_server_exec(unused struct cmd *self, struct cmd_ctx *ctx) { sigterm = 1; diff --git a/cmd-kill-session.c b/cmd-kill-session.c index abca8ca1..1a4fbaa0 100644 --- a/cmd-kill-session.c +++ b/cmd-kill-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-session.c,v 1.8 2008-06-03 05:35:51 nicm Exp $ */ +/* $Id: cmd-kill-session.c,v 1.9 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -27,7 +27,7 @@ * Note this deliberately has no alias to make it hard to hit by accident. */ -void cmd_kill_session_exec(void *, struct cmd_ctx *); +void cmd_kill_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_kill_session_entry = { "kill-session", NULL, @@ -38,17 +38,18 @@ const struct cmd_entry cmd_kill_session_entry = { cmd_sessiononly_send, cmd_sessiononly_recv, cmd_sessiononly_free, - NULL + NULL, + cmd_sessiononly_print }; void -cmd_kill_session_exec(void *ptr, struct cmd_ctx *ctx) +cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx) { struct session *s; struct client *c; u_int i; - if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL) + if ((s = cmd_sessiononly_get(self, ctx)) == NULL) return; for (i = 0; i < ARRAY_LENGTH(&clients); i++) { diff --git a/cmd-kill-window.c b/cmd-kill-window.c index 6fd3de3a..2d34217d 100644 --- a/cmd-kill-window.c +++ b/cmd-kill-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-window.c,v 1.11 2008-06-03 05:35:51 nicm Exp $ */ +/* $Id: cmd-kill-window.c,v 1.12 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Destroy window. */ -void cmd_kill_window_exec(void *, struct cmd_ctx *); +void cmd_kill_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_kill_window_entry = { "kill-window", "killw", @@ -35,11 +35,12 @@ const struct cmd_entry cmd_kill_window_entry = { cmd_windowonly_send, cmd_windowonly_recv, cmd_windowonly_free, + NULL, NULL }; void -cmd_kill_window_exec(void *ptr, struct cmd_ctx *ctx) +cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct winlink *wl; struct session *s; @@ -47,7 +48,7 @@ cmd_kill_window_exec(void *ptr, struct cmd_ctx *ctx) u_int i; int destroyed; - if ((wl = cmd_windowonly_get(ptr, ctx, &s)) == NULL) + if ((wl = cmd_windowonly_get(self, ctx, &s)) == NULL) return; destroyed = session_detach(s, wl); diff --git a/cmd-last-window.c b/cmd-last-window.c index 8d55a23c..a9deef03 100644 --- a/cmd-last-window.c +++ b/cmd-last-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-last-window.c,v 1.9 2008-06-03 05:35:51 nicm Exp $ */ +/* $Id: cmd-last-window.c,v 1.10 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,7 +24,7 @@ * Move to last window. */ -void cmd_last_window_exec(void *, struct cmd_ctx *); +void cmd_last_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_last_window_entry = { "last-window", "last", @@ -35,15 +35,16 @@ const struct cmd_entry cmd_last_window_entry = { cmd_sessiononly_send, cmd_sessiononly_recv, cmd_sessiononly_free, - NULL + NULL, + cmd_sessiononly_print }; void -cmd_last_window_exec(void *ptr, struct cmd_ctx *ctx) +cmd_last_window_exec(struct cmd *self, struct cmd_ctx *ctx) { struct session *s; - if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL) + if ((s = cmd_sessiononly_get(self, ctx)) == NULL) return; if (session_last(s) == 0) diff --git a/cmd-link-window.c b/cmd-link-window.c index e43c9ad9..9888d389 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-link-window.c,v 1.16 2008-06-04 16:46:23 nicm Exp $ */ +/* $Id: cmd-link-window.c,v 1.17 2008-06-05 16:35:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -27,11 +27,11 @@ * Link a window into another session. */ -int cmd_link_window_parse(struct cmd *, void **, int, char **, char **); -void cmd_link_window_exec(void *, struct cmd_ctx *); -void cmd_link_window_send(void *, struct buffer *); -void cmd_link_window_recv(void **, struct buffer *); -void cmd_link_window_free(void *); +int cmd_link_window_parse(struct cmd *, int, char **, char **); +void cmd_link_window_exec(struct cmd *, struct cmd_ctx *); +void cmd_link_window_send(struct cmd *, struct buffer *); +void cmd_link_window_recv(struct cmd *, struct buffer *); +void cmd_link_window_free(struct cmd *); struct cmd_link_window_data { char *cname; @@ -52,18 +52,18 @@ const struct cmd_entry cmd_link_window_entry = { cmd_link_window_send, cmd_link_window_recv, cmd_link_window_free, + NULL, NULL }; int -cmd_link_window_parse( - struct cmd *self, void **ptr, int argc, char **argv, char **cause) +cmd_link_window_parse(struct cmd *self, int argc, char **argv, char **cause) { struct cmd_link_window_data *data; const char *errstr; int opt; - *ptr = data = xmalloc(sizeof *data); + self->data = data = xmalloc(sizeof *data); data->cname = NULL; data->sname = NULL; data->flag_detached = 0; @@ -121,14 +121,14 @@ usage: xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage); error: - cmd_link_window_free(data); + self->entry->free(self); return (-1); } void -cmd_link_window_exec(void *ptr, struct cmd_ctx *ctx) +cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_link_window_data *data = ptr; + struct cmd_link_window_data *data = self->data; struct session *s, *src; struct winlink *wl, *wl2; @@ -202,9 +202,9 @@ cmd_link_window_exec(void *ptr, struct cmd_ctx *ctx) } void -cmd_link_window_send(void *ptr, struct buffer *b) +cmd_link_window_send(struct cmd *self, struct buffer *b) { - struct cmd_link_window_data *data = ptr; + struct cmd_link_window_data *data = self->data; buffer_write(b, data, sizeof *data); cmd_send_string(b, data->cname); @@ -213,11 +213,11 @@ cmd_link_window_send(void *ptr, struct buffer *b) } void -cmd_link_window_recv(void **ptr, struct buffer *b) +cmd_link_window_recv(struct cmd *self, struct buffer *b) { struct cmd_link_window_data *data; |