Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
0cba6f82
Commit
0cba6f82
authored
May 22, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert the parameter array to a list of parameters.
parent
71dfce88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
38 deletions
+47
-38
mgt_param.c
bin/varnishd/mgt/mgt_param.c
+47
-38
No files found.
bin/varnishd/mgt/mgt_param.c
View file @
0cba6f82
...
...
@@ -46,9 +46,16 @@
#include "mgt_cli.h"
struct
plist
{
unsigned
magic
;
#define PLIST_MAGIC 0xbfc3ea16
VTAILQ_ENTRY
(
plist
)
list
;
struct
parspec
*
spec
;
};
static
VTAILQ_HEAD
(,
plist
)
phead
=
VTAILQ_HEAD_INITIALIZER
(
phead
);
struct
params
mgt_param
;
static
int
nparspec
;
static
struct
parspec
**
parspecs
;
static
const
int
margin1
=
8
;
static
int
margin2
=
0
;
static
const
int
wrap_at
=
72
;
...
...
@@ -94,21 +101,42 @@ static const char ONLY_ROOT_TEXT[] =
"
\n\n
"
"NB: This parameter only works if varnishd is run as root."
;
/*--------------------------------------------------------------------*/
static
struct
parspec
*
mcf_findpar
(
const
char
*
name
)
{
int
i
;
struct
plist
*
pl
;
AN
(
name
);
for
(
i
=
0
;
i
<
nparspec
;
i
++
)
if
(
!
strcmp
(
p
arspecs
[
i
]
->
name
,
name
))
return
(
p
arspecs
[
i
]
);
VTAILQ_FOREACH
(
pl
,
&
phead
,
list
)
if
(
!
strcmp
(
p
l
->
spec
->
name
,
name
))
return
(
p
l
->
spec
);
return
(
NULL
);
}
static
void
mcf_addpar
(
struct
parspec
*
ps
)
{
struct
plist
*
pl
,
*
pl2
;
int
i
;
ALLOC_OBJ
(
pl
,
PLIST_MAGIC
);
AN
(
pl
);
pl
->
spec
=
ps
;
VTAILQ_FOREACH
(
pl2
,
&
phead
,
list
)
{
i
=
strcmp
(
pl2
->
spec
->
name
,
pl
->
spec
->
name
);
if
(
i
==
0
)
{
fprintf
(
stderr
,
"Duplicate param: %s
\n
"
,
ps
->
name
);
exit
(
4
);
}
else
if
(
i
>
0
)
{
VTAILQ_INSERT_BEFORE
(
pl2
,
pl
,
list
);
return
;
}
}
VTAILQ_INSERT_TAIL
(
&
phead
,
pl
,
list
);
}
/*--------------------------------------------------------------------
* Wrap the text nicely.
* Lines are allowed to contain to TABS and we render that as a table
...
...
@@ -205,7 +233,8 @@ mcf_wrap(struct cli *cli, const char *text)
void
mcf_param_show
(
struct
cli
*
cli
,
const
char
*
const
*
av
,
void
*
priv
)
{
int
i
,
n
;
int
n
;
struct
plist
*
pl
;
const
struct
parspec
*
pp
;
int
lfmt
=
0
,
chg
=
0
;
struct
vsb
*
vsb
;
...
...
@@ -219,8 +248,8 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
lfmt
=
1
;
n
=
0
;
for
(
i
=
0
;
i
<
nparspec
;
i
++
)
{
pp
=
p
arspecs
[
i
]
;
VTAILQ_FOREACH
(
pl
,
&
phead
,
list
)
{
pp
=
p
l
->
spec
;
if
(
lfmt
&&
strcmp
(
pp
->
name
,
av
[
2
])
&&
strcmp
(
"-l"
,
av
[
2
]))
continue
;
n
++
;
...
...
@@ -364,22 +393,12 @@ mcf_param_set(struct cli *cli, const char * const *av, void *priv)
* Add a group of parameters to the global set and sort by name.
*/
static
int
mcf_parspec_cmp
(
const
void
*
a
,
const
void
*
b
)
{
struct
parspec
*
const
*
pa
=
a
;
struct
parspec
*
const
*
pb
=
b
;
return
(
strcmp
((
*
pa
)
->
name
,
(
*
pb
)
->
name
));
}
void
MCF_AddParams
(
struct
parspec
*
ps
)
{
struct
parspec
*
pp
;
const
char
*
s
;
int
n
;
n
=
0
;
for
(
pp
=
ps
;
pp
->
name
!=
NULL
;
pp
++
)
{
AN
(
pp
->
func
);
s
=
strchr
(
pp
->
descr
,
'\0'
);
...
...
@@ -388,23 +407,12 @@ MCF_AddParams(struct parspec *ps)
"Param->descr has trailing space: %s
\n
"
,
pp
->
name
);
exit
(
4
);
}
if
(
mcf_findpar
(
pp
->
name
)
!=
NULL
)
{
fprintf
(
stderr
,
"Duplicate param: %s
\n
"
,
pp
->
name
);
exit
(
4
);
}
mcf_addpar
(
pp
);
if
(
strlen
(
pp
->
name
)
+
1
>
margin2
)
margin2
=
strlen
(
pp
->
name
)
+
1
;
n
++
;
}
parspecs
=
realloc
(
parspecs
,
(
1L
+
nparspec
+
n
)
*
sizeof
*
parspecs
);
XXXAN
(
parspecs
);
for
(
pp
=
ps
;
pp
->
name
!=
NULL
;
pp
++
)
parspecs
[
nparspec
++
]
=
pp
;
parspecs
[
nparspec
]
=
NULL
;
qsort
(
parspecs
,
nparspec
,
sizeof
parspecs
[
0
],
mcf_parspec_cmp
);
}
/*--------------------------------------------------------------------
* Wash a min/max/default value
*/
...
...
@@ -443,14 +451,14 @@ mcf_wash_param(struct cli *cli, const struct parspec *pp, const char **val,
void
MCF_InitParams
(
struct
cli
*
cli
)
{
struct
plist
*
pl
;
struct
parspec
*
pp
;
int
i
;
struct
vsb
*
vsb
;
vsb
=
VSB_new_auto
();
AN
(
vsb
);
for
(
i
=
0
;
i
<
nparspec
;
i
++
)
{
pp
=
p
arspecs
[
i
]
;
VTAILQ_FOREACH
(
pl
,
&
phead
,
list
)
{
pp
=
p
l
->
spec
;
if
(
pp
->
min
!=
NULL
)
mcf_wash_param
(
cli
,
pp
,
&
pp
->
min
,
"minimum"
,
vsb
);
...
...
@@ -515,14 +523,15 @@ MCF_SetMaximum(const char *param, const char *new_max)
void
MCF_DumpRstParam
(
void
)
{
struct
plist
*
pl
;
const
struct
parspec
*
pp
;
const
char
*
p
,
*
q
,
*
t1
,
*
t2
;
int
i
,
j
;
int
j
;
printf
(
"
\n
.. The following is the autogenerated "
"output from varnishd -x dumprstparam
\n\n
"
);
for
(
i
=
0
;
i
<
nparspec
;
i
++
)
{
pp
=
p
arspecs
[
i
]
;
VTAILQ_FOREACH
(
pl
,
&
phead
,
list
)
{
pp
=
p
l
->
spec
;
printf
(
".. _ref_param_%s:
\n\n
"
,
pp
->
name
);
printf
(
"%s
\n
"
,
pp
->
name
);
for
(
j
=
0
;
j
<
strlen
(
pp
->
name
);
j
++
)
...
...
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