Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
7ea81655
Commit
7ea81655
authored
May 31, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace cleanup: cli -> VCLI and cls -> VCLS
parent
e8c859b8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
70 additions
and
70 deletions
+70
-70
varnishadm.c
bin/varnishadm/varnishadm.c
+6
-6
cache_cli.c
bin/varnishd/cache_cli.c
+1
-1
mgt_cli.c
bin/varnishd/mgt_cli.c
+5
-5
vtc_varnish.c
bin/varnishtest/vtc_varnish.c
+11
-11
cli.h
include/cli.h
+1
-1
cli_common.h
include/cli_common.h
+6
-6
cli_serve.h
include/cli_serve.h
+7
-7
cli_auth.c
lib/libvarnish/cli_auth.c
+1
-1
cli_common.c
lib/libvarnish/cli_common.c
+2
-2
cli_serve.c
lib/libvarnish/cli_serve.c
+30
-30
No files found.
bin/varnishadm/varnishadm.c
View file @
7ea81655
...
...
@@ -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
);
V
CLI_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
);
...
...
bin/varnishd/cache_cli.c
View file @
7ea81655
...
...
@@ -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:
...
...
bin/varnishd/mgt_cli.c
View file @
7ea81655
...
...
@@ -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
);
V
CLI_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
();
...
...
bin/varnishtest/vtc_varnish.c
View file @
7ea81655
...
...
@@ -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
);
V
CLI_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
);
...
...
include/cli.h
View file @
7ea81655
...
...
@@ -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
,
...
...
include/cli_common.h
View file @
7ea81655
...
...
@@ -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
V
CLI_response
(
int
S_fd
,
const
char
*
challenge
,
char
reponse
[
CLI_AUTH_RESPONSE_LEN
]);
include/cli_serve.h
View file @
7ea81655
...
...
@@ -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
;
...
...
lib/libvarnish/cli_auth.c
View file @
7ea81655
...
...
@@ -39,7 +39,7 @@
void
CLI_response
(
int
S_fd
,
const
char
*
challenge
,
V
CLI_response
(
int
S_fd
,
const
char
*
challenge
,
char
response
[
CLI_AUTH_RESPONSE_LEN
])
{
SHA256_CTX
ctx
;
...
...
lib/libvarnish/cli_common.c
View file @
7ea81655
...
...
@@ -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
;
...
...
lib/libvarnish/cli_serve.c
View file @
7ea81655
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment