[master] ab0b3e2 Namespace cleanup: More cli_ -> VCLI_
Poul-Henning Kamp
phk at varnish-cache.org
Tue May 31 13:15:06 CEST 2011
commit ab0b3e26111677b77624c47a4fb5e4808cd26759
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue May 31 10:44:16 2011 +0000
Namespace cleanup: More cli_ -> VCLI_
diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c
index 74e3359..64e3937 100644
--- a/bin/varnishd/cache_acceptor.c
+++ b/bin/varnishd/cache_acceptor.c
@@ -428,7 +428,7 @@ ccf_listen_address(struct cli *cli, const char * const *av, void *priv)
if (ls->sock < 0)
continue;
VTCP_myname(ls->sock, h, sizeof h, p, sizeof p);
- cli_out(cli, "%s %s\n", h, p);
+ VCLI_Out(cli, "%s %s\n", h, p);
}
}
@@ -474,15 +474,15 @@ VCA_tweak_waiter(struct cli *cli, const char *arg)
if (arg == NULL) {
if (vca_act == NULL)
- cli_out(cli, "default");
+ VCLI_Out(cli, "default");
else
- cli_out(cli, "%s", vca_act->name);
+ VCLI_Out(cli, "%s", vca_act->name);
- cli_out(cli, " (");
+ VCLI_Out(cli, " (");
for (i = 0; vca_waiters[i] != NULL; i++)
- cli_out(cli, "%s%s", i == 0 ? "" : ", ",
+ VCLI_Out(cli, "%s%s", i == 0 ? "" : ", ",
vca_waiters[i]->name);
- cli_out(cli, ")");
+ VCLI_Out(cli, ")");
return;
}
if (!strcmp(arg, "default")) {
@@ -495,6 +495,6 @@ VCA_tweak_waiter(struct cli *cli, const char *arg)
return;
}
}
- cli_out(cli, "Unknown waiter");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Unknown waiter");
+ VCLI_SetResult(cli, CLIS_PARAM);
}
diff --git a/bin/varnishd/cache_backend_cfg.c b/bin/varnishd/cache_backend_cfg.c
index 44f5cd8..68ffcdb 100644
--- a/bin/varnishd/cache_backend_cfg.c
+++ b/bin/varnishd/cache_backend_cfg.c
@@ -285,7 +285,7 @@ cli_debug_backend(struct cli *cli, const char * const *av, void *priv)
ASSERT_CLI();
VTAILQ_FOREACH(b, &backends, list) {
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
- cli_out(cli, "%p %s(%s,%s,:%s) %d %d\n",
+ VCLI_Out(cli, "%p %s(%s,%s,:%s) %d %d\n",
b, b->vcl_name, b->ipv4_addr, b->ipv6_addr, b->port,
b->refcount, b->n_conn);
}
diff --git a/bin/varnishd/cache_backend_poll.c b/bin/varnishd/cache_backend_poll.c
index ce55e39..d6de0fe 100644
--- a/bin/varnishd/cache_backend_poll.c
+++ b/bin/varnishd/cache_backend_poll.c
@@ -370,12 +370,12 @@ vbp_bitmap(struct cli *cli, char c, uint64_t map, const char *lbl)
for (i = 0; i < 64; i++) {
if (map & u)
- cli_out(cli, "%c", c);
+ VCLI_Out(cli, "%c", c);
else
- cli_out(cli, "-");
+ VCLI_Out(cli, "-");
map <<= 1;
}
- cli_out(cli, " %s\n", lbl);
+ VCLI_Out(cli, " %s\n", lbl);
}
/*lint -e{506} constant value boolean */
@@ -384,16 +384,16 @@ static void
vbp_health_one(struct cli *cli, const struct vbp_target *vt)
{
- cli_out(cli, "Backend %s is %s\n",
+ VCLI_Out(cli, "Backend %s is %s\n",
vt->backend->vcl_name,
vt->backend->healthy ? "Healthy" : "Sick");
- cli_out(cli, "Current states good: %2u threshold: %2u window: %2u\n",
+ VCLI_Out(cli, "Current states good: %2u threshold: %2u window: %2u\n",
vt->good, vt->probe.threshold, vt->probe.window);
- cli_out(cli, "Average responsetime of good probes: %.6f\n", vt->avg);
- cli_out(cli,
+ VCLI_Out(cli, "Average responsetime of good probes: %.6f\n", vt->avg);
+ VCLI_Out(cli,
"Oldest "
" Newest\n");
- cli_out(cli,
+ VCLI_Out(cli,
"============================="
"===================================\n");
diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c
index a75314c..28a36cd 100644
--- a/bin/varnishd/cache_ban.c
+++ b/bin/varnishd/cache_ban.c
@@ -298,8 +298,8 @@ ban_parse_regexp(struct cli *cli, const struct ban *b, const char *a3)
re = pcre_compile(a3, 0, &error, &erroroffset, NULL);
if (re == NULL) {
VSL(SLT_Debug, 0, "REGEX: <%s>", error);
- cli_out(cli, "%s", error);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "%s", error);
+ VCLI_SetResult(cli, CLIS_PARAM);
return (-1);
}
rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &sz);
@@ -325,8 +325,8 @@ BAN_AddTest(struct cli *cli, struct ban *b, const char *a1, const char *a2,
if (!strncmp(a1, pv->name, strlen(pv->name)))
break;
if (pv->name == NULL) {
- cli_out(cli, "unknown or unsupported field \"%s\"", a1);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "unknown or unsupported field \"%s\"", a1);
+ VCLI_SetResult(cli, CLIS_PARAM);
return (-1);
}
@@ -353,9 +353,9 @@ BAN_AddTest(struct cli *cli, struct ban *b, const char *a1, const char *a2,
} else if (!strcmp(a2, "!=")) {
VSB_putc(b->vsb, BAN_OPER_NEQ);
} else {
- cli_out(cli,
+ VCLI_Out(cli,
"expected conditional (~, !~, == or !=) got \"%s\"", a2);
- cli_result(cli, CLIS_PARAM);
+ VCLI_SetResult(cli, CLIS_PARAM);
return (-1);
}
return (0);
@@ -845,22 +845,22 @@ ccf_ban(struct cli *cli, const char * const *av, void *priv)
for (narg = 0; av[narg + 2] != NULL; narg++)
continue;
if ((narg % 4) != 3) {
- cli_out(cli, "Wrong number of arguments");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Wrong number of arguments");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
for (i = 3; i < narg; i += 4) {
if (strcmp(av[i + 2], "&&")) {
- cli_out(cli, "Found \"%s\" expected &&", av[i + 2]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Found \"%s\" expected &&", av[i + 2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
}
b = BAN_New();
if (b == NULL) {
- cli_out(cli, "Out of Memory");
- cli_result(cli, CLIS_CANT);
+ VCLI_Out(cli, "Out of Memory");
+ VCLI_SetResult(cli, CLIS_CANT);
return;
}
for (i = 0; i < narg; i += 4)
@@ -898,30 +898,30 @@ ban_render(struct cli *cli, const uint8_t *bs)
ban_iter(&bs, &bt);
switch (bt.arg1) {
case BAN_ARG_URL:
- cli_out(cli, "req.url");
+ VCLI_Out(cli, "req.url");
break;
case BAN_ARG_REQHTTP:
- cli_out(cli, "req.http.%.*s",
+ VCLI_Out(cli, "req.http.%.*s",
bt.arg1_spec[0] - 1, bt.arg1_spec + 1);
break;
case BAN_ARG_OBJHTTP:
- cli_out(cli, "obj.http.%.*s",
+ VCLI_Out(cli, "obj.http.%.*s",
bt.arg1_spec[0] - 1, bt.arg1_spec + 1);
break;
default:
INCOMPL();
}
switch (bt.oper) {
- case BAN_OPER_EQ: cli_out(cli, " == "); break;
- case BAN_OPER_NEQ: cli_out(cli, " != "); break;
- case BAN_OPER_MATCH: cli_out(cli, " ~ "); break;
- case BAN_OPER_NMATCH: cli_out(cli, " !~ "); break;
+ case BAN_OPER_EQ: VCLI_Out(cli, " == "); break;
+ case BAN_OPER_NEQ: VCLI_Out(cli, " != "); break;
+ case BAN_OPER_MATCH: VCLI_Out(cli, " ~ "); break;
+ case BAN_OPER_NMATCH: VCLI_Out(cli, " !~ "); break;
default:
INCOMPL();
}
- cli_out(cli, "%s", bt.arg2);
+ VCLI_Out(cli, "%s", bt.arg2);
if (bs < be)
- cli_out(cli, " && ");
+ VCLI_Out(cli, " && ");
}
}
@@ -939,11 +939,11 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv)
VTAILQ_FOREACH(b, &ban_head, list) {
if (b == bl)
break;
- cli_out(cli, "%p %10.6f %5u%s\t", b, ban_time(b->spec),
+ VCLI_Out(cli, "%p %10.6f %5u%s\t", b, ban_time(b->spec),
bl == b ? b->refcount - 1 : b->refcount,
b->flags & BAN_F_GONE ? "G" : " ");
ban_render(cli, b->spec);
- cli_out(cli, "\n");
+ VCLI_Out(cli, "\n");
}
BAN_TailDeref(&bl);
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 4f69e47..e2fb980 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -1547,7 +1547,7 @@ cli_debug_xid(struct cli *cli, const char * const *av, void *priv)
(void)priv;
if (av[2] != NULL)
xids = strtoul(av[2], NULL, 0);
- cli_out(cli, "XID is %u", xids);
+ VCLI_Out(cli, "XID is %u", xids);
}
/*
@@ -1564,7 +1564,7 @@ cli_debug_srandom(struct cli *cli, const char * const *av, void *priv)
seed = strtoul(av[2], NULL, 0);
srandom(seed);
srand48(random());
- cli_out(cli, "Random(3) seeded with %lu", seed);
+ VCLI_Out(cli, "Random(3) seeded with %lu", seed);
}
static struct cli_proto debug_cmds[] = {
diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c
index 754788b..7ef1bb3 100644
--- a/bin/varnishd/cache_cli.c
+++ b/bin/varnishd/cache_cli.c
@@ -107,7 +107,7 @@ CLI_Run(void)
add_check = 1;
- AN(VCLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL));
+ AN(VCLS_AddFd(cls, heritage.cli_in, heritage.VCLI_Out, NULL, NULL));
do {
i = VCLS_Poll(cls, -1);
@@ -124,7 +124,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
(void)av;
(void)priv;
-#define SZOF(foo) cli_out(cli, \
+#define SZOF(foo) VCLI_Out(cli, \
"sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo));
SZOF(struct ws);
SZOF(struct http);
diff --git a/bin/varnishd/cache_vcl.c b/bin/varnishd/cache_vcl.c
index 9137acd..7777304 100644
--- a/bin/varnishd/cache_vcl.c
+++ b/bin/varnishd/cache_vcl.c
@@ -141,7 +141,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
ASSERT_CLI();
vcl = vcl_find(name);
if (vcl != NULL) {
- cli_out(cli, "Config '%s' already loaded", name);
+ VCLI_Out(cli, "Config '%s' already loaded", name);
return (1);
}
@@ -151,13 +151,13 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
vcl->dlh = dlopen(fn, RTLD_NOW | RTLD_LOCAL);
if (vcl->dlh == NULL) {
- cli_out(cli, "dlopen(%s): %s\n", fn, dlerror());
+ VCLI_Out(cli, "dlopen(%s): %s\n", fn, dlerror());
FREE_OBJ(vcl);
return (1);
}
cnf = dlsym(vcl->dlh, "VCL_conf");
if (cnf == NULL) {
- cli_out(cli, "Internal error: No VCL_conf symbol\n");
+ VCLI_Out(cli, "Internal error: No VCL_conf symbol\n");
(void)dlclose(vcl->dlh);
FREE_OBJ(vcl);
return (1);
@@ -165,14 +165,14 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
memcpy(vcl->conf, cnf, sizeof *cnf);
if (vcl->conf->magic != VCL_CONF_MAGIC) {
- cli_out(cli, "Wrong VCL_CONF_MAGIC\n");
+ VCLI_Out(cli, "Wrong VCL_CONF_MAGIC\n");
(void)dlclose(vcl->dlh);
FREE_OBJ(vcl);
return (1);
}
REPLACE(vcl->name, name);
VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
- cli_out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
+ VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
vcl->conf->init_vcl(cli);
(void)vcl->conf->init_func(NULL);
Lck_Lock(&vcl_mtx);
@@ -238,7 +238,7 @@ ccf_config_list(struct cli *cli, const char * const *av, void *priv)
flg = "discarded";
} else
flg = "available";
- cli_out(cli, "%-10s %6u %s\n",
+ VCLI_Out(cli, "%-10s %6u %s\n",
flg,
vcl->conf->busy,
vcl->name);
@@ -253,7 +253,7 @@ ccf_config_load(struct cli *cli, const char * const *av, void *priv)
(void)priv;
ASSERT_CLI();
if (VCL_Load(av[3], av[2], cli))
- cli_result(cli, CLIS_PARAM);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
@@ -267,15 +267,15 @@ ccf_config_discard(struct cli *cli, const char * const *av, void *priv)
(void)priv;
vcl = vcl_find(av[2]);
if (vcl == NULL) {
- cli_result(cli, CLIS_PARAM);
- cli_out(cli, "VCL '%s' unknown", av[2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "VCL '%s' unknown", av[2]);
return;
}
Lck_Lock(&vcl_mtx);
if (vcl == vcl_active) {
Lck_Unlock(&vcl_mtx);
- cli_result(cli, CLIS_PARAM);
- cli_out(cli, "VCL %s is the active VCL", av[2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "VCL %s is the active VCL", av[2]);
return;
}
VSC_C_main->n_vcl_discard++;
@@ -296,8 +296,8 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv)
(void)priv;
vcl = vcl_find(av[2]);
if (vcl == NULL) {
- cli_out(cli, "No VCL named '%s'", av[2]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "No VCL named '%s'", av[2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
Lck_Lock(&vcl_mtx);
diff --git a/bin/varnishd/cache_vrt_vmod.c b/bin/varnishd/cache_vrt_vmod.c
index 1afa459..7d03fac 100644
--- a/bin/varnishd/cache_vrt_vmod.c
+++ b/bin/varnishd/cache_vrt_vmod.c
@@ -139,7 +139,7 @@ ccf_debug_vmod(struct cli *cli, const char * const *av, void *priv)
(void)priv;
ASSERT_CLI();
VTAILQ_FOREACH(v, &vmods, list)
- cli_out(cli, "%5d %s (%s)\n", v->ref, v->nm, v->path);
+ VCLI_Out(cli, "%5d %s (%s)\n", v->ref, v->nm, v->path);
}
static struct cli_proto vcl_cmds[] = {
diff --git a/bin/varnishd/hash_critbit.c b/bin/varnishd/hash_critbit.c
index 0eb426c..4dff8db 100644
--- a/bin/varnishd/hash_critbit.c
+++ b/bin/varnishd/hash_critbit.c
@@ -309,14 +309,14 @@ dumptree(struct cli *cli, uintptr_t p, int indent)
return;
if (hcb_is_node(p)) {
oh = hcb_l_node(p);
- cli_out(cli, "%*.*sN %d r%u <%02x%02x%02x...>\n",
+ VCLI_Out(cli, "%*.*sN %d r%u <%02x%02x%02x...>\n",
indent, indent, "", indent / 2, oh->refcnt,
oh->digest[0], oh->digest[1], oh->digest[2]);
return;
}
assert(hcb_is_y(p));
y = hcb_l_y(p);
- cli_out(cli, "%*.*sY c %u p %u b %02x i %d\n",
+ VCLI_Out(cli, "%*.*sY c %u p %u b %02x i %d\n",
indent, indent, "",
y->critbit, y->ptr, y->bitmask, indent / 2);
indent += 2;
@@ -330,9 +330,9 @@ hcb_dump(struct cli *cli, const char * const *av, void *priv)
(void)priv;
(void)av;
- cli_out(cli, "HCB dump:\n");
+ VCLI_Out(cli, "HCB dump:\n");
dumptree(cli, hcb_root.origo, 0);
- cli_out(cli, "Coollist:\n");
+ VCLI_Out(cli, "Coollist:\n");
}
static struct cli_proto hcb_cmds[] = {
diff --git a/bin/varnishd/heritage.h b/bin/varnishd/heritage.h
index ad3b363..fb94043 100644
--- a/bin/varnishd/heritage.h
+++ b/bin/varnishd/heritage.h
@@ -44,7 +44,7 @@ struct heritage {
/* Two pipe(2)'s for CLI connection between cache and mgt. */
int cli_in;
- int cli_out;
+ int VCLI_Out;
/* File descriptor for stdout/stderr */
int std_fd;
diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c
index 4dc5c67..4397cd3 100644
--- a/bin/varnishd/mgt_child.c
+++ b/bin/varnishd/mgt_child.c
@@ -61,7 +61,7 @@ pid_t child_pid = -1;
static struct vbitmap *fd_map;
static int child_cli_in = -1;
-static int child_cli_out = -1;
+static int child_VCLI_Out = -1;
static int child_output = -1;
static enum {
@@ -282,8 +282,8 @@ start_child(struct cli *cli)
if (open_sockets() != 0) {
child_state = CH_STOPPED;
if (cli != NULL) {
- cli_result(cli, CLIS_CANT);
- cli_out(cli, "Could not open sockets");
+ VCLI_SetResult(cli, CLIS_CANT);
+ VCLI_Out(cli, "Could not open sockets");
return;
}
REPORT0(LOG_ERR,
@@ -297,12 +297,12 @@ start_child(struct cli *cli)
AZ(pipe(cp));
heritage.cli_in = cp[0];
mgt_child_inherit(heritage.cli_in, "cli_in");
- child_cli_out = cp[1];
+ child_VCLI_Out = cp[1];
/* Open pipe for child->mgr CLI */
AZ(pipe(cp));
- heritage.cli_out = cp[1];
- mgt_child_inherit(heritage.cli_out, "cli_out");
+ heritage.VCLI_Out = cp[1];
+ mgt_child_inherit(heritage.VCLI_Out, "VCLI_Out");
child_cli_in = cp[0];
/*
@@ -354,8 +354,8 @@ start_child(struct cli *cli)
mgt_child_inherit(heritage.cli_in, NULL);
closex(&heritage.cli_in);
- mgt_child_inherit(heritage.cli_out, NULL);
- closex(&heritage.cli_out);
+ mgt_child_inherit(heritage.VCLI_Out, NULL);
+ closex(&heritage.VCLI_Out);
close_sockets();
@@ -382,7 +382,7 @@ start_child(struct cli *cli)
ev_poker = e;
}
- mgt_cli_start_child(child_cli_in, child_cli_out);
+ mgt_cli_start_child(child_cli_in, child_VCLI_Out);
child_pid = pid;
if (mgt_push_vcls_and_start(&u, &p)) {
REPORT(LOG_ERR, "Pushing vcls failed: %s", p);
@@ -414,7 +414,7 @@ mgt_stop_child(void)
mgt_cli_stop_child();
/* We tell the child to die gracefully by closing the CLI */
- closex(&child_cli_out);
+ closex(&child_VCLI_Out);
closex(&child_cli_in);
}
@@ -505,7 +505,7 @@ mgt_sigchld(const struct vev *e, int what)
if (child_state == CH_RUNNING) {
child_state = CH_DIED;
mgt_cli_stop_child();
- closex(&child_cli_out);
+ closex(&child_VCLI_Out);
closex(&child_cli_in);
}
@@ -619,12 +619,12 @@ mcf_server_startstop(struct cli *cli, const char * const *av, void *priv)
if (mgt_has_vcl()) {
start_child(cli);
} else {
- cli_result(cli, CLIS_CANT);
- cli_out(cli, "No VCL available");
+ VCLI_SetResult(cli, CLIS_CANT);
+ VCLI_Out(cli, "No VCL available");
}
} else {
- cli_result(cli, CLIS_CANT);
- cli_out(cli, "Child in state %s", ch_state[child_state]);
+ VCLI_SetResult(cli, CLIS_CANT);
+ VCLI_Out(cli, "Child in state %s", ch_state[child_state]);
}
}
@@ -635,7 +635,7 @@ mcf_server_status(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
(void)priv;
- cli_out(cli, "Child in state %s", ch_state[child_state]);
+ VCLI_Out(cli, "Child in state %s", ch_state[child_state]);
}
void
@@ -645,12 +645,12 @@ mcf_panic_show(struct cli *cli, const char * const *av, void *priv)
(void)priv;
if (!child_panic) {
- cli_result(cli, CLIS_CANT);
- cli_out(cli, "Child has not panicked or panic has been cleared");
+ VCLI_SetResult(cli, CLIS_CANT);
+ VCLI_Out(cli, "Child has not panicked or panic has been cleared");
return;
}
- cli_out(cli, "%s\n", VSB_data(child_panic));
+ VCLI_Out(cli, "%s\n", VSB_data(child_panic));
}
void
@@ -660,8 +660,8 @@ mcf_panic_clear(struct cli *cli, const char * const *av, void *priv)
(void)priv;
if (!child_panic) {
- cli_result(cli, CLIS_CANT);
- cli_out(cli, "No panic to clear");
+ VCLI_SetResult(cli, CLIS_CANT);
+ VCLI_Out(cli, "No panic to clear");
return;
}
diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c
index 3a3f1da..f155c0f 100644
--- a/bin/varnishd/mgt_cli.c
+++ b/bin/varnishd/mgt_cli.c
@@ -76,16 +76,16 @@ mcf_banner(struct cli *cli, const char *const *av, void *priv)
(void)av;
(void)priv;
- cli_out(cli, "-----------------------------\n");
- cli_out(cli, "Varnish Cache CLI 1.0\n");
- cli_out(cli, "-----------------------------\n");
- cli_out(cli, "%s\n", VSB_data(vident) + 1);
- cli_out(cli, "\n");
- cli_out(cli, "Type 'help' for command list.\n");
- cli_out(cli, "Type 'quit' to close CLI session.\n");
+ VCLI_Out(cli, "-----------------------------\n");
+ VCLI_Out(cli, "Varnish Cache CLI 1.0\n");
+ VCLI_Out(cli, "-----------------------------\n");
+ VCLI_Out(cli, "%s\n", VSB_data(vident) + 1);
+ VCLI_Out(cli, "\n");
+ VCLI_Out(cli, "Type 'help' for command list.\n");
+ VCLI_Out(cli, "Type 'quit' to close CLI session.\n");
if (child_pid < 0)
- cli_out(cli, "Type 'start' to launch worker process.\n");
- cli_result(cli, CLIS_OK);
+ VCLI_Out(cli, "Type 'start' to launch worker process.\n");
+ VCLI_SetResult(cli, CLIS_OK);
}
/*--------------------------------------------------------------------*/
@@ -145,11 +145,11 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv)
*/
if (cli_o <= 0) {
if (!strcmp(av[1], "help")) {
- cli_out(cli, "No help from child, (not running).\n");
+ VCLI_Out(cli, "No help from child, (not running).\n");
return;
}
- cli_result(cli, CLIS_UNKNOWN);
- cli_out(cli,
+ VCLI_SetResult(cli, CLIS_UNKNOWN);
+ VCLI_Out(cli,
"Unknown request in manager process "
"(child not running).\n"
"Type 'help' for more info.");
@@ -165,15 +165,15 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv)
i = write(cli_o, VSB_data(vsb), VSB_len(vsb));
if (i != VSB_len(vsb)) {
VSB_delete(vsb);
- cli_result(cli, CLIS_COMMS);
- cli_out(cli, "CLI communication error");
+ VCLI_SetResult(cli, CLIS_COMMS);
+ VCLI_Out(cli, "CLI communication error");
MGT_Child_Cli_Fail();
return;
}
VSB_delete(vsb);
(void)VCLI_ReadResult(cli_i, &u, &q, params->cli_timeout);
- cli_result(cli, u);
- cli_out(cli, "%s", q);
+ VCLI_SetResult(cli, u);
+ VCLI_Out(cli, "%s", q);
free(q);
}
@@ -262,9 +262,9 @@ mgt_cli_challenge(struct cli *cli)
cli->challenge[i] = (random() % 26) + 'a';
cli->challenge[i++] = '\n';
cli->challenge[i] = '\0';
- cli_out(cli, "%s", cli->challenge);
- cli_out(cli, "\nAuthentication required.\n");
- cli_result(cli, CLIS_AUTH);
+ VCLI_Out(cli, "%s", cli->challenge);
+ VCLI_Out(cli, "\nAuthentication required.\n");
+ VCLI_SetResult(cli, CLIS_AUTH);
}
/*--------------------------------------------------------------------
@@ -280,15 +280,15 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv)
AN(av[2]);
(void)priv;
if (secret_file == NULL) {
- cli_out(cli, "Secret file not configured\n");
- cli_result(cli, CLIS_CANT);
+ VCLI_Out(cli, "Secret file not configured\n");
+ VCLI_SetResult(cli, CLIS_CANT);
return;
}
fd = open(secret_file, O_RDONLY);
if (fd < 0) {
- cli_out(cli, "Cannot open secret file (%s)\n",
+ VCLI_Out(cli, "Cannot open secret file (%s)\n",
strerror(errno));
- cli_result(cli, CLIS_CANT);
+ VCLI_SetResult(cli, CLIS_CANT);
return;
}
mgt_got_fd(fd);
@@ -300,7 +300,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv)
}
cli->auth = MCF_AUTH;
memset(cli->challenge, 0, sizeof cli->challenge);
- cli_result(cli, CLIS_OK);
+ VCLI_SetResult(cli, CLIS_OK);
mcf_banner(cli, av, priv);
}
diff --git a/bin/varnishd/mgt_param.c b/bin/varnishd/mgt_param.c
index 7810212..8b82350 100644
--- a/bin/varnishd/mgt_param.c
+++ b/bin/varnishd/mgt_param.c
@@ -80,13 +80,13 @@ tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg)
if (arg != NULL) {
u = strtoul(arg, NULL, 0);
if (u == 0) {
- cli_out(cli, "Timeout must be greater than zero\n");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Timeout must be greater than zero\n");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
*dst = u;
} else
- cli_out(cli, "%u", *dst);
+ VCLI_Out(cli, "%u", *dst);
}
/*--------------------------------------------------------------------*/
@@ -111,22 +111,22 @@ tweak_timeout_double(struct cli *cli, const struct parspec *par,
if (arg != NULL) {
u = strtod(arg, NULL);
if (u < par->min) {
- cli_out(cli,
+ VCLI_Out(cli,
"Timeout must be greater or equal to %.g\n",
par->min);
- cli_result(cli, CLIS_PARAM);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
if (u > par->max) {
- cli_out(cli,
+ VCLI_Out(cli,
"Timeout must be less than or equal to %.g\n",
par->max);
- cli_result(cli, CLIS_PARAM);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
*dest = u;
} else
- cli_out(cli, "%.6f", *dest);
+ VCLI_Out(cli, "%.6f", *dest);
}
/*--------------------------------------------------------------------*/
@@ -142,22 +142,22 @@ tweak_generic_double(struct cli *cli, const struct parspec *par,
if (arg != NULL) {
u = strtod(arg, NULL);
if (u < par->min) {
- cli_out(cli,
+ VCLI_Out(cli,
"Must be greater or equal to %.g\n",
par->min);
- cli_result(cli, CLIS_PARAM);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
if (u > par->max) {
- cli_out(cli,
+ VCLI_Out(cli,
"Must be less than or equal to %.g\n",
par->max);
- cli_result(cli, CLIS_PARAM);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
*dest = u;
} else
- cli_out(cli, "%f", *dest);
+ VCLI_Out(cli, "%f", *dest);
}
/*--------------------------------------------------------------------*/
@@ -183,12 +183,12 @@ tweak_generic_bool(struct cli *cli, volatile unsigned *dest, const char *arg)
else if (!strcasecmp(arg, "true"))
*dest = 1;
else {
- cli_out(cli, "use \"on\" or \"off\"\n");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "use \"on\" or \"off\"\n");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
} else
- cli_out(cli, *dest ? "on" : "off");
+ VCLI_Out(cli, *dest ? "on" : "off");
}
/*--------------------------------------------------------------------*/
@@ -216,20 +216,20 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg,
else
u = strtoul(arg, NULL, 0);
if (u < min) {
- cli_out(cli, "Must be at least %u\n", min);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Must be at least %u\n", min);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
if (u > max) {
- cli_out(cli, "Must be no more than %u\n", max);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Must be no more than %u\n", max);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
*dest = u;
} else if (*dest == UINT_MAX) {
- cli_out(cli, "unlimited", *dest);
+ VCLI_Out(cli, "unlimited", *dest);
} else {
- cli_out(cli, "%u", *dest);
+ VCLI_Out(cli, "%u", *dest);
}
}
@@ -269,8 +269,8 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
} else
pw = getpwnam(arg);
if (pw == NULL) {
- cli_out(cli, "Unknown user");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Unknown user");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
REPLACE(master.user, pw->pw_name);
@@ -283,9 +283,9 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
gr->gr_gid == pw->pw_gid)
REPLACE(master.group, gr->gr_name);
} else if (master.user) {
- cli_out(cli, "%s (%d)", master.user, (int)master.uid);
+ VCLI_Out(cli, "%s (%d)", master.user, (int)master.uid);
} else {
- cli_out(cli, "%d", (int)master.uid);
+ VCLI_Out(cli, "%d", (int)master.uid);
}
}
@@ -311,16 +311,16 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
} else
gr = getgrnam(arg);
if (gr == NULL) {
- cli_out(cli, "Unknown group");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Unknown group");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
REPLACE(master.group, gr->gr_name);
master.gid = gr->gr_gid;
} else if (master.group) {
- cli_out(cli, "%s (%d)", master.group, (int)master.gid);
+ VCLI_Out(cli, "%s (%d)", master.group, (int)master.gid);
} else {
- cli_out(cli, "%d", (int)master.gid);
+ VCLI_Out(cli, "%d", (int)master.gid);
}
}
@@ -350,25 +350,25 @@ tweak_listen_address(struct cli *cli, const struct parspec *par,
(void)par;
if (arg == NULL) {
- cli_quote(cli, master.listen_address);
+ VCLI_Quote(cli, master.listen_address);
return;
}
av = VAV_Parse(arg, NULL, ARGV_COMMA);
if (av == NULL) {
- cli_out(cli, "Parse error: out of memory");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Parse error: out of memory");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
if (av[0] != NULL) {
- cli_out(cli, "Parse error: %s", av[0]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Parse error: %s", av[0]);
+ VCLI_SetResult(cli, CLIS_PARAM);
VAV_Free(av);
return;
}
if (av[1] == NULL) {
- cli_out(cli, "Empty listen address");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Empty listen address");
+ VCLI_SetResult(cli, CLIS_PARAM);
VAV_Free(av);
return;
}
@@ -379,9 +379,9 @@ tweak_listen_address(struct cli *cli, const struct parspec *par,
n = VSS_resolve(av[i], "http", &ta);
if (n == 0) {
- cli_out(cli, "Invalid listen address ");
- cli_quote(cli, av[i]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Invalid listen address ");
+ VCLI_Quote(cli, av[i]);
+ VCLI_SetResult(cli, CLIS_PARAM);
break;
}
for (j = 0; j < n; ++j) {
@@ -424,7 +424,7 @@ tweak_string(struct cli *cli, const struct parspec *par, const char *arg)
AN(p);
/* XXX should have tweak_generic_string */
if (arg == NULL) {
- cli_quote(cli, *p);
+ VCLI_Quote(cli, *p);
} else {
REPLACE(*p, arg);
}
@@ -453,7 +453,7 @@ tweak_diag_bitmap(struct cli *cli, const struct parspec *par, const char *arg)
u = strtoul(arg, NULL, 0);
master.diag_bitmap = u;
} else {
- cli_out(cli, "0x%x", master.diag_bitmap);
+ VCLI_Out(cli, "0x%x", master.diag_bitmap);
}
}
@@ -955,7 +955,7 @@ mcf_wrap(struct cli *cli, const char *text)
q--;
AN(q);
}
- cli_out(cli, "%*s %.*s\n", margin, "", (int)(q - p), p);
+ VCLI_Out(cli, "%*s %.*s\n", margin, "", (int)(q - p), p);
p = q;
if (*p == ' ' || *p == '\n')
p++;
@@ -978,9 +978,9 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
pp = parspec[i];
if (av[2] != NULL && !lfmt && strcmp(pp->name, av[2]))
continue;
- cli_out(cli, "%-*s ", margin, pp->name);
+ VCLI_Out(cli, "%-*s ", margin, pp->name);
if (pp->func == NULL) {
- cli_out(cli, "Not implemented.\n");
+ VCLI_Out(cli, "Not implemented.\n");
if (av[2] != NULL && !lfmt)
return;
else
@@ -988,11 +988,11 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
}
pp->func(cli, pp, NULL);
if (pp->units != NULL)
- cli_out(cli, " [%s]\n", pp->units);
+ VCLI_Out(cli, " [%s]\n", pp->units);
else
- cli_out(cli, "\n");
+ VCLI_Out(cli, "\n");
if (av[2] != NULL) {
- cli_out(cli, "%-*s Default is %s\n",
+ VCLI_Out(cli, "%-*s Default is %s\n",
margin, "", pp->def);
mcf_wrap(cli, pp->descr);
if (pp->flags & DELAYED_EFFECT)
@@ -1008,12 +1008,12 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
if (!lfmt)
return;
else
- cli_out(cli, "\n");
+ VCLI_Out(cli, "\n");
}
}
if (av[2] != NULL && !lfmt) {
- cli_result(cli, CLIS_PARAM);
- cli_out(cli, "Unknown parameter \"%s\".", av[2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Unknown parameter \"%s\".", av[2]);
}
}
@@ -1037,20 +1037,20 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val)
if (pp != NULL) {
pp->func(cli, pp, val);
if (cli->result != CLIS_OK) {
- cli_out(cli, "(attempting to set param %s to %s)\n",
+ VCLI_Out(cli, "(attempting to set param %s to %s)\n",
pp->name, val);
} else if (child_pid >= 0 && pp->flags & MUST_RESTART) {
- cli_out(cli, "Change will take effect"
+ VCLI_Out(cli, "Change will take effect"
" when child is restarted");
} else if (pp->flags & MUST_RELOAD) {
- cli_out(cli, "Change will take effect"
+ VCLI_Out(cli, "Change will take effect"
" when VCL script is reloaded");
}
MCF_ParamSync();
return;
}
- cli_result(cli, CLIS_PARAM);
- cli_out(cli, "Unknown parameter \"%s\".", param);
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Unknown parameter \"%s\".", param);
}
@@ -1111,7 +1111,7 @@ MCF_SetDefaults(struct cli *cli)
for (i = 0; i < nparspec; i++) {
pp = parspec[i];
if (cli != NULL)
- cli_out(cli,
+ VCLI_Out(cli,
"Set Default for %s = %s\n", pp->name, pp->def);
pp->func(cli, pp, pp->def);
if (cli != NULL && cli->result != CLIS_OK)
diff --git a/bin/varnishd/mgt_vcc.c b/bin/varnishd/mgt_vcc.c
index 2e1c9a5..d793a0e 100644
--- a/bin/varnishd/mgt_vcc.c
+++ b/bin/varnishd/mgt_vcc.c
@@ -482,25 +482,25 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv)
vp = mgt_vcc_byname(av[2]);
if (vp != NULL) {
- cli_out(cli, "Already a VCL program named %s", av[2]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Already a VCL program named %s", av[2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
vf = mgt_VccCompile(&sb, av[3], 0);
if (VSB_len(sb) > 0)
- cli_out(cli, "%s\n", VSB_data(sb));
+ VCLI_Out(cli, "%s\n", VSB_data(sb));
VSB_delete(sb);
if (vf == NULL) {
- cli_out(cli, "VCL compilation failed");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "VCL compilation failed");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
- cli_out(cli, "VCL compiled.");
+ VCLI_Out(cli, "VCL compiled.");
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "vcl.load %s %s\n", av[2], vf)) {
- cli_result(cli, status);
- cli_out(cli, "%s", p);
+ VCLI_SetResult(cli, status);
+ VCLI_Out(cli, "%s", p);
} else {
(void)mgt_vcc_add(av[2], vf);
}
@@ -519,15 +519,15 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv)
(void)priv;
vp = mgt_vcc_byname(av[2]);
if (vp != NULL) {
- cli_out(cli, "Already a VCL program named %s", av[2]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Already a VCL program named %s", av[2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
vcl = vreadfile(mgt_vcl_dir, av[3], NULL);
if (vcl == NULL) {
- cli_out(cli, "Cannot open '%s'", av[3]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Cannot open '%s'", av[3]);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
@@ -535,18 +535,18 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv)
free(vcl);
if (VSB_len(sb) > 0)
- cli_out(cli, "%s", VSB_data(sb));
+ VCLI_Out(cli, "%s", VSB_data(sb));
VSB_delete(sb);
if (vf == NULL) {
- cli_out(cli, "VCL compilation failed");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "VCL compilation failed");
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
- cli_out(cli, "VCL compiled.");
+ VCLI_Out(cli, "VCL compiled.");
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "vcl.load %s %s\n", av[2], vf)) {
- cli_result(cli, status);
- cli_out(cli, "%s", p);
+ VCLI_SetResult(cli, status);
+ VCLI_Out(cli, "%s", p);
} else {
(void)mgt_vcc_add(av[2], vf);
}
@@ -561,8 +561,8 @@ mcf_find_vcl(struct cli *cli, const char *name)
vp = mgt_vcc_byname(name);
if (vp != NULL)
return (vp);
- cli_result(cli, CLIS_PARAM);
- cli_out(cli, "No configuration named %s known.", name);
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "No configuration named %s known.", name);
return (NULL);
}
@@ -581,8 +581,8 @@ mcf_config_use(struct cli *cli, const char * const *av, void *priv)
return;
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) {
- cli_result(cli, status);
- cli_out(cli, "%s", p);
+ VCLI_SetResult(cli, status);
+ VCLI_Out(cli, "%s", p);
} else {
vp->active = 2;
VTAILQ_FOREACH(vp, &vclhead, list) {
@@ -605,14 +605,14 @@ mcf_config_discard(struct cli *cli, const char * const *av, void *priv)
(void)priv;
vp = mcf_find_vcl(cli, av[2]);
if (vp != NULL && vp->active) {
- cli_result(cli, CLIS_PARAM);
- cli_out(cli, "Cannot discard active VCL program\n");
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Cannot discard active VCL program\n");
} else if (vp != NULL) {
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p,
"vcl.discard %s\n", av[2])) {
- cli_result(cli, status);
- cli_out(cli, "%s", p);
+ VCLI_SetResult(cli, status);
+ VCLI_Out(cli, "%s", p);
} else {
AZ(mgt_vcc_delbyname(av[2]));
}
@@ -632,8 +632,8 @@ mcf_config_list(struct cli *cli, const char * const *av, void *priv)
(void)priv;
if (child_pid >= 0) {
if (!mgt_cli_askchild(&status, &p, "vcl.list\n")) {
- cli_result(cli, status);
- cli_out(cli, "%s", p);
+ VCLI_SetResult(cli, status);
+ VCLI_Out(cli, "%s", p);
}
free(p);
} else {
@@ -642,7 +642,7 @@ mcf_config_list(struct cli *cli, const char * const *av, void *priv)
flg = "active";
} else
flg = "available";
- cli_out(cli, "%-10s %6s %s\n",
+ VCLI_Out(cli, "%-10s %6s %s\n",
flg, "N/A", vp->name);
}
}
@@ -663,18 +663,18 @@ mcf_config_show(struct cli *cli, const char * const *av, void *priv)
(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",
+ VCLI_Out(cli, "failed to load %s: %s\n",
vp->name, dlerror());
- cli_result(cli, CLIS_CANT);
+ VCLI_SetResult(cli, CLIS_CANT);
} else if ((sym = dlsym(dlh, "srcbody")) == NULL) {
- cli_out(cli, "failed to locate source for %s: %s\n",
+ VCLI_Out(cli, "failed to locate source for %s: %s\n",
vp->name, dlerror());
- cli_result(cli, CLIS_CANT);
+ VCLI_SetResult(cli, CLIS_CANT);
AZ(dlclose(dlh));
} else {
src = sym;
- cli_out(cli, "%s", src[0]);
- /* cli_out(cli, src[1]); */
+ VCLI_Out(cli, "%s", src[0]);
+ /* VCLI_Out(cli, src[1]); */
AZ(dlclose(dlh));
}
}
diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c
index a14e011..256c994 100644
--- a/bin/varnishd/stevedore.c
+++ b/bin/varnishd/stevedore.c
@@ -526,11 +526,11 @@ stv_cli_list(struct cli *cli, const char * const *av, void *priv)
ASSERT_MGT();
(void)av;
(void)priv;
- cli_out(cli, "Storage devices:\n");
+ VCLI_Out(cli, "Storage devices:\n");
stv = stv_transient;
- cli_out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name);
+ VCLI_Out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name);
VTAILQ_FOREACH(stv, &stevedores, list)
- cli_out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name);
+ VCLI_Out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c
index d37ef45..427f687 100644
--- a/bin/varnishd/storage_persistent.c
+++ b/bin/varnishd/storage_persistent.c
@@ -580,22 +580,22 @@ debug_report_silo(struct cli *cli, const struct smp_sc *sc, int objs)
struct smp_seg *sg;
struct objcore *oc;
- cli_out(cli, "Silo: %s (%s)\n",
+ VCLI_Out(cli, "Silo: %s (%s)\n",
sc->stevedore->ident, sc->filename);
VTAILQ_FOREACH(sg, &sc->segments, list) {
- cli_out(cli, " Seg: [0x%jx ... +0x%jx]\n",
+ VCLI_Out(cli, " Seg: [0x%jx ... +0x%jx]\n",
(uintmax_t)sg->p.offset, (uintmax_t)sg->p.length);
if (sg == sc->cur_seg)
- cli_out(cli,
+ VCLI_Out(cli,
" Alloc: [0x%jx ... 0x%jx] = 0x%jx free\n",
(uintmax_t)(sc->next_bot),
(uintmax_t)(sc->next_top),
(uintmax_t)(sc->next_top - sc->next_bot));
- cli_out(cli, " %u nobj, %u alloc, %u lobjlist, %u fixed\n",
+ VCLI_Out(cli, " %u nobj, %u alloc, %u lobjlist, %u fixed\n",
sg->nobj, sg->nalloc, sg->p.lobjlist, sg->nfixed);
if (objs) {
VTAILQ_FOREACH(oc, &sg->lru->lru_head, lru_list)
- cli_out(cli, " OC %p\n", oc);
+ VCLI_Out(cli, " OC %p\n", oc);
}
}
}
@@ -616,8 +616,8 @@ debug_persistent(struct cli *cli, const char * const * av, void *priv)
if (!strcmp(av[2], sc->stevedore->ident))
break;
if (sc == NULL) {
- cli_out(cli, "Silo <%s> not found\n", av[2]);
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Silo <%s> not found\n", av[2]);
+ VCLI_SetResult(cli, CLIS_PARAM);
return;
}
if (av[3] == NULL) {
@@ -631,8 +631,8 @@ debug_persistent(struct cli *cli, const char * const * av, void *priv)
} else if (!strcmp(av[3], "dump")) {
debug_report_silo(cli, sc, 1);
} else {
- cli_out(cli, "Unknown operation\n");
- cli_result(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Unknown operation\n");
+ VCLI_SetResult(cli, CLIS_PARAM);
}
Lck_Unlock(&sc->mtx);
}
diff --git a/include/cli_priv.h b/include/cli_priv.h
index 9d35181..ae0343b 100644
--- a/include/cli_priv.h
+++ b/include/cli_priv.h
@@ -52,6 +52,6 @@ struct cli_proto {
};
/* The implementation must provide these functions */
-void cli_out(struct cli *cli, const char *fmt, ...);
-void cli_quote(struct cli *cli, const char *str);
-void cli_result(struct cli *cli, unsigned r);
+void VCLI_Out(struct cli *cli, const char *fmt, ...);
+void VCLI_Quote(struct cli *cli, const char *str);
+void VCLI_SetResult(struct cli *cli, unsigned r);
diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index 84c69c3..56a849a 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -52,7 +52,7 @@
/*lint -e{818} cli could be const */
void
-cli_out(struct cli *cli, const char *fmt, ...)
+VCLI_Out(struct cli *cli, const char *fmt, ...)
{
va_list ap;
@@ -66,14 +66,14 @@ cli_out(struct cli *cli, const char *fmt, ...)
/*lint -e{818} cli could be const */
void
-cli_quote(struct cli *cli, const char *s)
+VCLI_Quote(struct cli *cli, const char *s)
{
VSB_quote(cli->sb, s, -1, 0);
}
void
-cli_result(struct cli *cli, unsigned res)
+VCLI_SetResult(struct cli *cli, unsigned res)
{
if (cli != NULL)
diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c
index f94494b..3b32866 100644
--- a/lib/libvarnish/cli_serve.c
+++ b/lib/libvarnish/cli_serve.c
@@ -88,8 +88,8 @@ VCLS_func_close(struct cli *cli, const char *const *av, void *priv)
(void)av;
(void)priv;
- cli_out(cli, "Closing CLI connection");
- cli_result(cli, CLIS_CLOSE);
+ VCLI_Out(cli, "Closing CLI connection");
+ VCLI_SetResult(cli, CLIS_CLOSE);
}
/*--------------------------------------------------------------------*/
@@ -102,7 +102,7 @@ VCLS_func_ping(struct cli *cli, const char * const *av, void *priv)
(void)priv;
(void)av;
t = time(NULL);
- cli_out(cli, "PONG %ld 1.0", t);
+ VCLI_Out(cli, "PONG %ld 1.0", t);
}
/*--------------------------------------------------------------------*/
@@ -133,7 +133,7 @@ VCLS_func_help(struct cli *cli, const char * const *av, void *priv)
continue;
for (cp = cfn->clp; cp->request != NULL; cp++) {
if (!strcmp(cp->request, av[2])) {
- cli_out(cli, "%s\n%s\n",
+ VCLI_Out(cli, "%s\n%s\n",
cp->syntax, cp->help);
return;
}
@@ -145,8 +145,8 @@ VCLS_func_help(struct cli *cli, const char * const *av, void *priv)
}
}
}
- cli_out(cli, "Unknown request.\nType 'help' for more info.\n");
- cli_result(cli, CLIS_UNKNOWN);
+ VCLI_Out(cli, "Unknown request.\nType 'help' for more info.\n");
+ VCLI_SetResult(cli, CLIS_UNKNOWN);
return;
}
VTAILQ_FOREACH(cfn, &cs->funcs, list) {
@@ -180,7 +180,7 @@ VCLS_func_help(struct cli *cli, const char * const *av, void *priv)
if (h && !all)
continue;
if (cp->syntax != NULL)
- cli_out(cli, "%s\n", cp->syntax);
+ VCLI_Out(cli, "%s\n", cp->syntax);
}
}
}
@@ -206,20 +206,20 @@ cls_dispatch(struct cli *cli, struct cli_proto *clp, char * const * av,
return (0);
if (cp->func == NULL) {
- cli_out(cli, "Unimplemented\n");
- cli_result(cli, CLIS_UNIMPL);
+ VCLI_Out(cli, "Unimplemented\n");
+ VCLI_SetResult(cli, CLIS_UNIMPL);
return(1);
}
if (ac - 1 < cp->minarg) {
- cli_out(cli, "Too few parameters\n");
- cli_result(cli, CLIS_TOOFEW);
+ VCLI_Out(cli, "Too few parameters\n");
+ VCLI_SetResult(cli, CLIS_TOOFEW);
return(1);
}
if (ac - 1> cp->maxarg) {
- cli_out(cli, "Too many parameters\n");
- cli_result(cli, CLIS_TOOMANY);
+ VCLI_Out(cli, "Too many parameters\n");
+ VCLI_SetResult(cli, CLIS_TOOMANY);
return(1);
}
@@ -254,21 +254,21 @@ cls_vlu2(void *priv, char * const *av)
cli->result = CLIS_UNKNOWN;
VSB_clear(cli->sb);
- cli_out(cli, "Unknown request.\nType 'help' for more info.\n");
+ VCLI_Out(cli, "Unknown request.\nType 'help' for more info.\n");
if (cs->before != NULL)
cs->before(cli);
do {
if (av[0] != NULL) {
- cli_out(cli, "Syntax Error: %s\n", av[0]);
- cli_result(cli, CLIS_SYNTAX);
+ VCLI_Out(cli, "Syntax Error: %s\n", av[0]);
+ VCLI_SetResult(cli, CLIS_SYNTAX);
break;
}
if (isupper(av[1][0])) {
- cli_out(cli, "all commands are in lower-case.\n");
- cli_result(cli, CLIS_UNKNOWN);
+ VCLI_Out(cli, "all commands are in lower-case.\n");
+ VCLI_SetResult(cli, CLIS_UNKNOWN);
break;
}
More information about the varnish-commit
mailing list