From ee1a7fded7653ffc2ba68a4188c89a7cb6e1bf1d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 5 Jun 2008 17:12:11 +0000 Subject: Print for the less easy commands. --- cmd-set-option.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'cmd-set-option.c') diff --git a/cmd-set-option.c b/cmd-set-option.c index 1b985103..a1ac9a9f 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.23 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-set-option.c,v 1.24 2008-06-05 17:12:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,6 +33,7 @@ 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 *); +void cmd_set_option_print(struct cmd *, char *, size_t); struct cmd_set_option_data { char *cname; @@ -52,7 +53,7 @@ const struct cmd_entry cmd_set_option_entry = { cmd_set_option_recv, cmd_set_option_free, NULL, - NULL + cmd_set_option_print }; int @@ -315,3 +316,18 @@ cmd_set_option_free(struct cmd *self) xfree(data->value); xfree(data); } + +void +cmd_set_option_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_set_option_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + if (off < len && data->option != NULL) + off += xsnprintf(buf + off, len - off, " %s", data->option); + if (off < len && data->value != NULL) + off += xsnprintf(buf + off, len - off, " %s", data->value); +} -- cgit