Easy bits of arg printing for list-keys.

This commit is contained in:
Nicholas Marriott
2008-06-05 16:35:32 +00:00
parent 7325fea37d
commit 642c0b00ab
39 changed files with 485 additions and 407 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-window-option.c,v 1.2 2008-06-04 18:32:20 nicm Exp $ */
/* $Id: cmd-set-window-option.c,v 1.3 2008-06-05 16:35:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -28,12 +28,11 @@
* Set a window option.
*/
int cmd_set_window_option_parse(
struct cmd *, void **, int, char **, char **);
void cmd_set_window_option_exec(void *, struct cmd_ctx *);
void cmd_set_window_option_send(void *, struct buffer *);
void cmd_set_window_option_recv(void **, struct buffer *);
void cmd_set_window_option_free(void *);
int cmd_set_window_option_parse(struct cmd *, int, char **, char **);
void cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *);
void cmd_set_window_option_send(struct cmd *, struct buffer *);
void cmd_set_window_option_recv(struct cmd *, struct buffer *);
void cmd_set_window_option_free(struct cmd *);
struct cmd_set_window_option_data {
char *cname;
@ -52,18 +51,19 @@ const struct cmd_entry cmd_set_window_option_entry = {
cmd_set_window_option_send,
cmd_set_window_option_recv,
cmd_set_window_option_free,
NULL,
NULL
};
int
cmd_set_window_option_parse(
struct cmd *self, void **ptr, int argc, char **argv, char **cause)
struct cmd *self, int argc, char **argv, char **cause)
{
struct cmd_set_window_option_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;
@ -110,14 +110,14 @@ usage:
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
error:
cmd_set_window_option_free(data);
self->entry->free(self);
return (-1);
}
void
cmd_set_window_option_exec(void *ptr, unused struct cmd_ctx *ctx)
cmd_set_window_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
{
struct cmd_set_window_option_data *data = ptr;
struct cmd_set_window_option_data *data = self->data;
struct winlink *wl;
struct session *s;
const char *errstr;
@ -183,9 +183,9 @@ cmd_set_window_option_exec(void *ptr, unused struct cmd_ctx *ctx)
}
void
cmd_set_window_option_send(void *ptr, struct buffer *b)
cmd_set_window_option_send(struct cmd *self, struct buffer *b)
{
struct cmd_set_window_option_data *data = ptr;
struct cmd_set_window_option_data *data = self->data;
buffer_write(b, data, sizeof *data);
cmd_send_string(b, data->cname);
@ -195,11 +195,11 @@ cmd_set_window_option_send(void *ptr, struct buffer *b)
}
void
cmd_set_window_option_recv(void **ptr, struct buffer *b)
cmd_set_window_option_recv(struct cmd *self, struct buffer *b)
{
struct cmd_set_window_option_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);
@ -208,9 +208,9 @@ cmd_set_window_option_recv(void **ptr, struct buffer *b)
}
void
cmd_set_window_option_free(void *ptr)
cmd_set_window_option_free(struct cmd *self)
{
struct cmd_set_window_option_data *data = ptr;
struct cmd_set_window_option_data *data = self->data;
if (data->cname != NULL)
xfree(data->cname);