[master] 7ea8165 Namespace cleanup: cli -> VCLI and cls -> VCLS
Poul-Henning Kamp
phk at varnish-cache.org
Tue May 31 13:15:05 CEST 2011
commit 7ea81655df8e84d36f939a2d5640a135b83732dc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue May 31 10:30:03 2011 +0000
Namespace cleanup: cli -> VCLI and cls -> VCLS
diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index f280b31..e460367 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -96,7 +96,7 @@ cli_sock(const char *T_arg, const char *S_arg)
return (-1);
}
- (void)cli_readres(sock, &status, &answer, timeout);
+ (void)VCLI_ReadResult(sock, &status, &answer, timeout);
if (status == CLIS_AUTH) {
if (S_arg == NULL) {
fprintf(stderr, "Authentication required\n");
@@ -110,14 +110,14 @@ cli_sock(const char *T_arg, const char *S_arg)
AZ(close(sock));
return (-1);
}
- CLI_response(fd, answer, buf);
+ VCLI_response(fd, answer, buf);
AZ(close(fd));
free(answer);
cli_write(sock, "auth ");
cli_write(sock, buf);
cli_write(sock, "\n");
- (void)cli_readres(sock, &status, &answer, timeout);
+ (void)VCLI_ReadResult(sock, &status, &answer, timeout);
}
if (status != CLIS_OK) {
fprintf(stderr, "Rejected %u\n%s\n", status, answer);
@@ -127,7 +127,7 @@ cli_sock(const char *T_arg, const char *S_arg)
free(answer);
cli_write(sock, "ping\n");
- (void)cli_readres(sock, &status, &answer, timeout);
+ (void)VCLI_ReadResult(sock, &status, &answer, timeout);
if (status != CLIS_OK || strstr(answer, "PONG") == NULL) {
fprintf(stderr, "No pong received from server\n");
AZ(close(sock));
@@ -154,7 +154,7 @@ do_args(int sock, int argc, char * const *argv)
}
cli_write(sock, "\n");
- (void)cli_readres(sock, &status, &answer, 2000);
+ (void)VCLI_ReadResult(sock, &status, &answer, 2000);
/* XXX: AZ() ? */
(void)close(sock);
@@ -221,7 +221,7 @@ pass(int sock)
if (fds[0].revents & POLLIN) {
/* Get rid of the prompt, kinda hackish */
u = write(1, "\r \r", 13);
- u = cli_readres(fds[0].fd, &status, &answer, timeout);
+ u = VCLI_ReadResult(fds[0].fd, &status, &answer, timeout);
if (u) {
if (status == CLIS_COMMS)
RL_EXIT(0);
diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c
index 7905c17..754788b 100644
--- a/bin/varnishd/cache_cli.c
+++ b/bin/varnishd/cache_cli.c
@@ -55,7 +55,7 @@
pthread_t cli_thread;
static struct lock cli_mtx;
static int add_check;
-static struct cls *cls;
+static struct VCLS *cls;
/*
* The CLI commandlist is split in three:
diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c
index 360bd03..3a3f1da 100644
--- a/bin/varnishd/mgt_cli.c
+++ b/bin/varnishd/mgt_cli.c
@@ -62,7 +62,7 @@
#include "mgt_cli.h"
static int cli_i = -1, cli_o = -1;
-static struct cls *cls;
+static struct VCLS *cls;
static const char *secret_file;
#define MCF_NOAUTH 0 /* NB: zero disables here-documents */
@@ -171,7 +171,7 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv)
return;
}
VSB_delete(vsb);
- (void)cli_readres(cli_i, &u, &q, params->cli_timeout);
+ (void)VCLI_ReadResult(cli_i, &u, &q, params->cli_timeout);
cli_result(cli, u);
cli_out(cli, "%s", q);
free(q);
@@ -220,7 +220,7 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) {
return (CLIS_COMMS);
}
- (void)cli_readres(cli_i, &u, resp, params->cli_timeout);
+ (void)VCLI_ReadResult(cli_i, &u, resp, params->cli_timeout);
if (status != NULL)
*status = u;
if (u == CLIS_COMMS)
@@ -292,7 +292,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv)
return;
}
mgt_got_fd(fd);
- CLI_response(fd, cli->challenge, buf);
+ VCLI_response(fd, cli->challenge, buf);
AZ(close(fd));
if (strcasecmp(buf, av[2])) {
mgt_cli_challenge(cli);
@@ -400,7 +400,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, mgt_cli_close_f
mcf_banner(cli, NULL, NULL);
}
AZ(VSB_finish(cli->sb));
- (void)cli_writeres(fdo, cli);
+ (void)VCLI_WriteResult(fdo, cli);
ev = vev_new();
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 856d872..3cd6431 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -85,7 +85,7 @@ static VTAILQ_HEAD(, varnish) varnishes =
* Ask a question over CLI
*/
-static enum cli_status_e
+static enum VCLI_status_e
varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl)
{
int i;
@@ -99,11 +99,11 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl)
i = write(v->cli_fd, "\n", 1);
assert(i == 1);
}
- i = cli_readres(v->cli_fd, &retval, &r, 20.0);
+ i = VCLI_ReadResult(v->cli_fd, &retval, &r, 20.0);
if (i != 0) {
vtc_log(v->vl, 0, "CLI failed (%s) = %d %u %s",
cmd, i, retval, r);
- return ((enum cli_status_e)retval);
+ return ((enum VCLI_status_e)retval);
}
assert(i == 0);
vtc_log(v->vl, 3, "CLI RX %u", retval);
@@ -112,7 +112,7 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl)
*repl = r;
else
free(r);
- return ((enum cli_status_e)retval);
+ return ((enum VCLI_status_e)retval);
}
/**********************************************************************
@@ -235,7 +235,7 @@ varnish_launch(struct varnish *v)
struct vss_addr **ap;
char abuf[128], pbuf[128];
struct pollfd fd[2];
- enum cli_status_e u;
+ enum VCLI_status_e u;
char *r;
v->vd = VSM_New();
@@ -341,7 +341,7 @@ varnish_launch(struct varnish *v)
assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 6);
strcpy(abuf, "auth ");
- CLI_response(nfd, r, abuf + 5);
+ VCLI_response(nfd, r, abuf + 5);
AZ(close(nfd));
free(r);
strcat(abuf, "\n");
@@ -364,7 +364,7 @@ varnish_launch(struct varnish *v)
static void
varnish_start(struct varnish *v)
{
- enum cli_status_e u;
+ enum VCLI_status_e u;
char *resp, *h, *p, *q;
if (v->cli_fd < 0)
@@ -478,7 +478,7 @@ varnish_wait(struct varnish *v)
static void
varnish_cli(struct varnish *v, const char *cli, unsigned exp)
{
- enum cli_status_e u;
+ enum VCLI_status_e u;
if (v->cli_fd < 0)
varnish_launch(v);
@@ -495,10 +495,10 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp)
*/
static void
-varnish_vcl(struct varnish *v, const char *vcl, enum cli_status_e expect)
+varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect)
{
struct vsb *vsb;
- enum cli_status_e u;
+ enum VCLI_status_e u;
if (v->cli_fd < 0)
varnish_launch(v);
@@ -539,7 +539,7 @@ static void
varnish_vclbackend(struct varnish *v, const char *vcl)
{
struct vsb *vsb, *vsb2;
- enum cli_status_e u;
+ enum VCLI_status_e u;
if (v->cli_fd < 0)
varnish_launch(v);
diff --git a/include/cli.h b/include/cli.h
index a82178a..1ee035f 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -190,7 +190,7 @@
* Status/return codes in the CLI protocol
*/
-enum cli_status_e {
+enum VCLI_status_e {
CLIS_SYNTAX = 100,
CLIS_UNKNOWN = 101,
CLIS_UNIMPL = 102,
diff --git a/include/cli_common.h b/include/cli_common.h
index 68e7acd..5041f6d 100644
--- a/include/cli_common.h
+++ b/include/cli_common.h
@@ -29,25 +29,25 @@
*/
struct vlu;
-struct cls;
+struct VCLS;
struct cli {
unsigned magic;
#define CLI_MAGIC 0x4038d570
struct vsb *sb;
- enum cli_status_e result;
+ enum VCLI_status_e result;
char *cmd;
unsigned auth;
char challenge[34];
char *ident;
struct vlu *vlu;
- struct cls *cls;
+ struct VCLS *cls;
};
-int cli_writeres(int fd, const struct cli *cli);
-int cli_readres(int fd, unsigned *status, char **ptr, double tmo);
+int VCLI_WriteResult(int fd, const struct cli *cli);
+int VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo);
#define CLI_AUTH_RESPONSE_LEN 65 /* 64 hex + NUL */
-void CLI_response(int S_fd, const char *challenge,
+void VCLI_response(int S_fd, const char *challenge,
char reponse[CLI_AUTH_RESPONSE_LEN]);
diff --git a/include/cli_serve.h b/include/cli_serve.h
index 9f6a645..5874efa 100644
--- a/include/cli_serve.h
+++ b/include/cli_serve.h
@@ -27,16 +27,16 @@
*
*/
-struct cls;
+struct VCLS;
typedef void cls_cb_f(void *priv);
typedef void cls_cbc_f(const struct cli*);
-struct cls *VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen);
-struct cli *VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc,
+struct VCLS *VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen);
+struct cli *VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc,
void *priv);
-int VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp);
-int VCLS_Poll(struct cls *cs, int timeout);
-int VCLS_PollFd(struct cls *cs, int fd, int timeout);
-void VCLS_Destroy(struct cls **);
+int VCLS_AddFunc(struct VCLS *cs, unsigned auth, struct cli_proto *clp);
+int VCLS_Poll(struct VCLS *cs, int timeout);
+int VCLS_PollFd(struct VCLS *cs, int fd, int timeout);
+void VCLS_Destroy(struct VCLS **);
/* From libvarnish/cli.c */
cli_func_t VCLS_func_close;
diff --git a/lib/libvarnish/cli_auth.c b/lib/libvarnish/cli_auth.c
index b726eba..3d9f44e 100644
--- a/lib/libvarnish/cli_auth.c
+++ b/lib/libvarnish/cli_auth.c
@@ -39,7 +39,7 @@
void
-CLI_response(int S_fd, const char *challenge,
+VCLI_response(int S_fd, const char *challenge,
char response[CLI_AUTH_RESPONSE_LEN])
{
SHA256_CTX ctx;
diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index ca47482..84c69c3 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -83,7 +83,7 @@ cli_result(struct cli *cli, unsigned res)
}
int
-cli_writeres(int fd, const struct cli *cli)
+VCLI_WriteResult(int fd, const struct cli *cli)
{
int i, l;
struct iovec iov[3];
@@ -142,7 +142,7 @@ read_tmo(int fd, char *ptr, unsigned len, double tmo)
}
int
-cli_readres(int fd, unsigned *status, char **ptr, double tmo)
+VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo)
{
char res[CLI_LINE0_LEN]; /* For NUL */
int i, j;
diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c
index 86cb893..f94494b 100644
--- a/lib/libvarnish/cli_serve.c
+++ b/lib/libvarnish/cli_serve.c
@@ -48,20 +48,20 @@
#include <libvarnish.h>
#include <miniobj.h>
-struct cls_func {
+struct VCLS_func {
unsigned magic;
#define VCLS_FUNC_MAGIC 0x7d280c9b
- VTAILQ_ENTRY(cls_func) list;
+ VTAILQ_ENTRY(VCLS_func) list;
unsigned auth;
struct cli_proto *clp;
};
-struct cls_fd {
+struct VCLS_fd {
unsigned magic;
#define VCLS_FD_MAGIC 0x010dbd1e
- VTAILQ_ENTRY(cls_fd) list;
+ VTAILQ_ENTRY(VCLS_fd) list;
int fdi, fdo;
- struct cls *cls;
+ struct VCLS *cls;
struct cli *cli, clis;
cls_cb_f *closefunc;
void *priv;
@@ -70,12 +70,12 @@ struct cls_fd {
char **argv;
};
-struct cls {
+struct VCLS {
unsigned magic;
#define VCLS_MAGIC 0x60f044a3
- VTAILQ_HEAD(,cls_fd) fds;
+ VTAILQ_HEAD(,VCLS_fd) fds;
unsigned nfd;
- VTAILQ_HEAD(,cls_func) funcs;
+ VTAILQ_HEAD(,VCLS_func) funcs;
cls_cbc_f *before, *after;
unsigned maxlen;
};
@@ -111,9 +111,9 @@ void
VCLS_func_help(struct cli *cli, const char * const *av, void *priv)
{
struct cli_proto *cp;
- struct cls_func *cfn;
+ struct VCLS_func *cfn;
unsigned all, debug, u, d, h, i, wc;
- struct cls *cs;
+ struct VCLS *cs;
(void)priv;
cs = cli->cls;
@@ -236,9 +236,9 @@ cls_dispatch(struct cli *cli, struct cli_proto *clp, char * const * av,
static int
cls_vlu2(void *priv, char * const *av)
{
- struct cls_fd *cfd;
- struct cls *cs;
- struct cls_func *cfn;
+ struct VCLS_fd *cfd;
+ struct VCLS *cs;
+ struct VCLS_func *cfn;
struct cli *cli;
unsigned na;
@@ -293,7 +293,7 @@ cls_vlu2(void *priv, char * const *av)
cli->cls = NULL;
- if (cli_writeres(cfd->fdo, cli) || cli->result == CLIS_CLOSE)
+ if (VCLI_WriteResult(cfd->fdo, cli) || cli->result == CLIS_CLOSE)
return (1);
return (0);
@@ -302,7 +302,7 @@ cls_vlu2(void *priv, char * const *av)
static int
cls_vlu(void *priv, const char *p)
{
- struct cls_fd *cfd;
+ struct VCLS_fd *cfd;
struct cli *cli;
int i;
char **av;
@@ -374,10 +374,10 @@ cls_vlu(void *priv, const char *p)
}
}
-struct cls *
+struct VCLS *
VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen)
{
- struct cls *cs;
+ struct VCLS *cs;
ALLOC_OBJ(cs, VCLS_MAGIC);
AN(cs);
@@ -390,9 +390,9 @@ VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen)
}
struct cli *
-VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv)
+VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv)
{
- struct cls_fd *cfd;
+ struct VCLS_fd *cfd;
CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC);
assert(fdi >= 0);
@@ -415,7 +415,7 @@ VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv)
}
static void
-cls_close_fd(struct cls *cs, struct cls_fd *cfd)
+cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd)
{
CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC);
@@ -439,9 +439,9 @@ cls_close_fd(struct cls *cs, struct cls_fd *cfd)
int
-VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp)
+VCLS_AddFunc(struct VCLS *cs, unsigned auth, struct cli_proto *clp)
{
- struct cls_func *cfn;
+ struct VCLS_func *cfn;
CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC);
ALLOC_OBJ(cfn, VCLS_FUNC_MAGIC);
@@ -453,9 +453,9 @@ VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp)
}
int
-VCLS_PollFd(struct cls *cs, int fd, int timeout)
+VCLS_PollFd(struct VCLS *cs, int fd, int timeout)
{
- struct cls_fd *cfd;
+ struct VCLS_fd *cfd;
struct pollfd pfd[1];
int i, j, k;
@@ -492,9 +492,9 @@ VCLS_PollFd(struct cls *cs, int fd, int timeout)
}
int
-VCLS_Poll(struct cls *cs, int timeout)
+VCLS_Poll(struct VCLS *cs, int timeout)
{
- struct cls_fd *cfd, *cfd2;
+ struct VCLS_fd *cfd, *cfd2;
int i, j, k;
CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC);
@@ -535,11 +535,11 @@ VCLS_Poll(struct cls *cs, int timeout)
}
void
-VCLS_Destroy(struct cls **csp)
+VCLS_Destroy(struct VCLS **csp)
{
- struct cls *cs;
- struct cls_fd *cfd, *cfd2;
- struct cls_func *cfn;
+ struct VCLS *cs;
+ struct VCLS_fd *cfd, *cfd2;
+ struct VCLS_func *cfn;
cs = *csp;
*csp = NULL;
More information about the varnish-commit
mailing list