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-option.c,v 1.22 2008-06-04 18:34:56 nicm Exp $ */
/* $Id: cmd-set-option.c,v 1.23 2008-06-05 16:35:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -28,11 +28,11 @@
* Set an option.
*/
int cmd_set_option_parse(struct cmd *, void **, int, char **, char **);
void cmd_set_option_exec(void *, struct cmd_ctx *);
void cmd_set_option_send(void *, struct buffer *);
void cmd_set_option_recv(void **, struct buffer *);
void cmd_set_option_free(void *);
int cmd_set_option_parse(struct cmd *, int, char **, char **);
void cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
void cmd_set_option_send(struct cmd *, struct buffer *);
void cmd_set_option_recv(struct cmd *, struct buffer *);
void cmd_set_option_free(struct cmd *);
struct cmd_set_option_data {
char *cname;
@ -51,17 +51,17 @@ const struct cmd_entry cmd_set_option_entry = {
cmd_set_option_send,
cmd_set_option_recv,
cmd_set_option_free,
NULL,
NULL
};
int
cmd_set_option_parse(
struct cmd *self, void **ptr, int argc, char **argv, char **cause)
cmd_set_option_parse(struct cmd *self, int argc, char **argv, char **cause)
{
struct cmd_set_option_data *data;
int opt;
*ptr = data = xmalloc(sizeof *data);
self->data = data = xmalloc(sizeof *data);
data->cname = NULL;
data->sname = NULL;
data->flag_global = 1;
@ -102,14 +102,14 @@ cmd_set_option_parse(
usage:
xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage);
cmd_set_option_free(data);
self->entry->free(self);
return (-1);
}
void
cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
{
struct cmd_set_option_data *data = ptr;
struct cmd_set_option_data *data = self->data;
struct client *c;
struct session *s;
struct options *oo;
@ -276,9 +276,9 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
}
void
cmd_set_option_send(void *ptr, struct buffer *b)
cmd_set_option_send(struct cmd *self, struct buffer *b)
{
struct cmd_set_option_data *data = ptr;
struct cmd_set_option_data *data = self->data;
buffer_write(b, data, sizeof *data);
cmd_send_string(b, data->cname);
@ -288,11 +288,11 @@ cmd_set_option_send(void *ptr, struct buffer *b)
}
void
cmd_set_option_recv(void **ptr, struct buffer *b)
cmd_set_option_recv(struct cmd *self, struct buffer *b)
{
struct cmd_set_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);
@ -301,9 +301,9 @@ cmd_set_option_recv(void **ptr, struct buffer *b)
}
void
cmd_set_option_free(void *ptr)
cmd_set_option_free(struct cmd *self)
{
struct cmd_set_option_data *data = ptr;
struct cmd_set_option_data *data = self->data;
if (data->cname != NULL)
xfree(data->cname);