Commit 4692a9d4 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Add a 'vcl.show' command which displays the source code for a given VCL

script.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1626 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f14327a0
......@@ -148,6 +148,7 @@ static struct cli_proto mgt_cli_proto[] = {
{ CLI_VCL_USE, mcf_config_use, NULL },
{ CLI_VCL_DISCARD, mcf_config_discard, NULL },
{ CLI_VCL_LIST, mcf_config_list, NULL },
{ CLI_VCL_SHOW, mcf_config_show, NULL },
{ CLI_PARAM_SHOW, mcf_param_show, NULL },
{ CLI_PARAM_SET, mcf_param_set, NULL },
{ CLI_HELP, cli_func_help, NULL },
......
......@@ -42,3 +42,4 @@ cli_func_t mcf_config_inline;
cli_func_t mcf_config_use;
cli_func_t mcf_config_discard;
cli_func_t mcf_config_list;
cli_func_t mcf_config_show;
......@@ -573,3 +573,29 @@ mcf_config_list(struct cli *cli, char **av, void *priv)
}
}
void
mcf_config_show(struct cli *cli, char **av, void *priv)
{
struct vclprog *vp;
void *dlh, *sym;
const char **src;
(void)priv;
if ((vp = mcf_find_vcl(cli, av[2])) != NULL) {
if ((dlh = dlopen(vp->fname, RTLD_NOW | RTLD_LOCAL)) == NULL) {
cli_out(cli, "failed to load %s: %s\n",
vp->name, dlerror());
cli_result(cli, CLIS_CANT);
} else if ((sym = dlsym(dlh, "srcbody")) == NULL) {
cli_out(cli, "failed to locate source for %s: %s\n",
vp->name, dlerror());
cli_result(cli, CLIS_CANT);
dlclose(dlh);
} else {
src = sym;
cli_out(cli, src[0]);
/* cli_out(cli, src[1]); */
dlclose(dlh);
}
}
}
......@@ -79,14 +79,14 @@
"\tCompile and load the VCL file under the name provided.", \
2, 2
#define CLI_VCL_INLINE \
"vcl.inline", \
"vcl.inline <configname> <quoted_VCLstring>", \
#define CLI_VCL_INLINE \
"vcl.inline", \
"vcl.inline <configname> <quoted_VCLstring>", \
"\tCompile and load the VCL data under the name provided.", \
2, 2
#define CLI_VCL_DISCARD \
"vcl.discard", \
#define CLI_VCL_DISCARD \
"vcl.discard", \
"vcl.discard <configname>", \
"\tUnload the named configuration (when possible).", \
1, 1
......@@ -97,9 +97,15 @@
"\tList all loaded configuration.", \
0, 0
#define CLI_VCL_SHOW \
"vcl.show", \
"vcl.show <configname>", \
"\tDisplay the source code for the specified configuration.", \
1, 1
#define CLI_VCL_USE \
"vcl.use", \
"vcl.use <configname>", \
"vcl.use <configname>", \
"\tSwitch to the named configuration immediately.", \
1, 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment