From: phk Date: Sat, 19 Aug 2006 20:28:30 +0000 (+0000) Subject: Add two new CLI commands: param.set and param.show. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b81e3f0be7ddfd3a87aa3fbd47d82cbe5c0dab9;p=varnish Add two new CLI commands: param.set and param.show. Eliminate requirement that "help" be first, I was just lazy I guess. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@837 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/Makefile.am b/varnish-cache/bin/varnishd/Makefile.am index 72e82c7f..41586d9f 100644 --- a/varnish-cache/bin/varnishd/Makefile.am +++ b/varnish-cache/bin/varnishd/Makefile.am @@ -31,6 +31,7 @@ varnishd_SOURCES = \ mgt_child.c \ mgt_cli.c \ mgt_event.c \ + mgt_param.c \ mgt_vcc.c \ rfc2616.c \ shmlog.c \ diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index 046c9446..1a835540 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -104,8 +104,8 @@ mcf_passthru(struct cli *cli, char **av, void *priv) static struct cli_proto *cli_proto; +/* XXX: what order should this list be in ? */ static struct cli_proto mgt_cli_proto[] = { - { CLI_HELP, cli_func_help, NULL }, /* must be first */ { CLI_PING, cli_func_ping }, { CLI_SERVER_START, mcf_server_startstop, NULL }, { CLI_SERVER_STOP, mcf_server_startstop, &cli_proto }, @@ -115,6 +115,9 @@ static struct cli_proto mgt_cli_proto[] = { { CLI_CONFIG_USE, mcf_config_use, NULL }, { CLI_CONFIG_DISCARD, mcf_config_discard, NULL }, { CLI_CONFIG_LIST, mcf_config_list, NULL }, + { CLI_PARAM_SHOW, mcf_param_show, NULL }, + { CLI_PARAM_SET, mcf_param_set, NULL }, + { CLI_HELP, cli_func_help, NULL }, #if 0 { CLI_SERVER_RESTART }, { CLI_ZERO }, @@ -163,8 +166,12 @@ mgt_cli_init(void) } /* Fixup the entry for 'help' entry */ - assert(!strcmp(cli_proto[0].request, "help")); - cli_proto[0].priv = cli_proto; + for (u = 0; cli_proto[u].request != NULL; u++) { + if (!strcmp(cli_proto[u].request, "help")) { + cli_proto[u].priv = cli_proto; + break; + } + } } /*-------------------------------------------------------------------- diff --git a/varnish-cache/bin/varnishd/mgt_cli.h b/varnish-cache/bin/varnishd/mgt_cli.h index 0c8f280b..5b1e76a6 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.h +++ b/varnish-cache/bin/varnishd/mgt_cli.h @@ -5,6 +5,10 @@ /* mgt_child.c */ cli_func_t mcf_server_startstop; +/* mgt_param.c */ +cli_func_t mcf_param_show; +cli_func_t mcf_param_set; + /* mgt_vcc.c */ cli_func_t mcf_config_load; cli_func_t mcf_config_inline; diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c new file mode 100644 index 00000000..59537ec2 --- /dev/null +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -0,0 +1,28 @@ +/* + * $Id$ + */ + +#include + +#include "cli_priv.h" +#include "mgt.h" +#include "mgt_cli.h" + +void +mcf_param_show(struct cli *cli, char **av, void *priv) +{ + + (void)cli; + (void)av; + (void)priv; +} + +void +mcf_param_set(struct cli *cli, char **av, void *priv) +{ + + (void)cli; + (void)av; + (void)priv; +} + diff --git a/varnish-cache/include/cli.h b/varnish-cache/include/cli.h index 319ec64d..31fc17ec 100644 --- a/varnish-cache/include/cli.h +++ b/varnish-cache/include/cli.h @@ -77,6 +77,18 @@ "\tSwitch to the named configuration immediately.", \ 1, 1 +#define CLI_PARAM_SHOW \ + "param.show", \ + "param.show []", \ + "\tShow parameters and their values.", \ + 0, 1 + +#define CLI_PARAM_SET \ + "param.set", \ + "param.set ", \ + "\tSet parameter value.", \ + 2,2 + #define CLI_SERVER_FREEZE \ "server.freeze", \ "server.freeze", \