diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-05 16:35:32 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-05 16:35:32 +0000 |
commit | 642c0b00ab43079cd251ec9616963b8a806b3464 (patch) | |
tree | 40f2bcf2f39d93feb21481a8547f267166f627f0 /cmd-bind-key.c | |
parent | 7325fea37dd75ac89828c6cfdfbcbd8d54548241 (diff) |
Easy bits of arg printing for list-keys.
Diffstat (limited to 'cmd-bind-key.c')
-rw-r--r-- | cmd-bind-key.c | 36 |
1 files changed, 18 insertions, 18 deletions
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); |