Mailing List Archive

[master] 7cb016a3d param: Introduce the notion of string parameters
commit 7cb016a3d5cfce51c603174fee8b8f4d2f96f06f
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Wed Oct 21 17:28:19 2020 +0200

param: Introduce the notion of string parameters

Following the model of simple parameters, it is possible to find a home
for string parameters in params.h too. A new PARAM_STRING() macro deals
with the specificities of such parameters.

Since string parameters are typically not inherited by the cache process
they are guarded by a PARAM_ALL macro that defines whether a subset or
the whole list of parameters is processed when params.h is #include'd.

Refs #3250

diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c
index 4122a1cfd..4ee4e23f3 100644
--- a/bin/varnishd/mgt/mgt_param_tbl.c
+++ b/bin/varnishd/mgt/mgt_param_tbl.c
@@ -39,33 +39,10 @@


struct parspec mgt_parspec[] = {
+#define PARAM_ALL
#define PARAM(ty, nm, ...) { #nm, __VA_ARGS__ },
#include "tbl/params.h"

- { "cc_command", tweak_string, &mgt_cc_cmd,
- NULL, NULL, VCC_CC,
- NULL,
- "Command used for compiling the C source code to a "
- "dlopen(3) loadable object. Any occurrence of %s in "
- "the string will be replaced with the source file name, "
- "and %o will be replaced with the output file name.",
- MUST_RELOAD,
- NULL, NULL, "defined when Varnish is built" },
- { "vcl_path", tweak_string, &mgt_vcl_path,
- NULL, NULL, VARNISH_VCL_DIR,
- NULL,
- "Directory (or colon separated list of directories) "
- "from which relative VCL filenames (vcl.load and "
- "include) are to be found. By default Varnish searches "
- "VCL files in both the system configuration and shared "
- "data directories to allow packages to drop their VCL "
- "files in a standard location where relative includes "
- "would work." },
- { "vmod_path", tweak_string, &mgt_vmod_path,
- NULL, NULL, VARNISH_VMOD_DIR,
- NULL,
- "Directory (or colon separated list of directories) "
- "where VMODs are to be found." },
{ "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref,
NULL, NULL, "on",
"bool",
diff --git a/include/tbl/params.h b/include/tbl/params.h
index 13211986d..4209669d9 100644
--- a/include/tbl/params.h
+++ b/include/tbl/params.h
@@ -1260,6 +1260,57 @@ PARAM_SIMPLE(

#undef MEMPOOL_TEXT

+#if defined(PARAM_ALL)
+
+/*--------------------------------------------------------------------
+ * String parameters
+ */
+
+# define PARAM_STRING(nm, pv, def, ...) \
+ PARAM(, nm, tweak_string, pv, NULL, NULL, def, NULL, __VA_ARGS__)
+
+PARAM_STRING(
+ /* name */ cc_command,
+ /* priv */ &mgt_cc_cmd,
+ /* def */ VCC_CC,
+ /* descr */
+ "Command used for compiling the C source code to a "
+ "dlopen(3) loadable object. Any occurrence of %s in "
+ "the string will be replaced with the source file name, "
+ "and %o will be replaced with the output file name.",
+ /* flags */ MUST_RELOAD
+)
+
+PARAM_STRING(
+ /* name */ vcl_path,
+ /* priv */ &mgt_vcl_path,
+ /* def */ VARNISH_VCL_DIR,
+ /* descr */
+ "Directory (or colon separated list of directories) "
+ "from which relative VCL filenames (vcl.load and "
+ "include) are to be found. By default Varnish searches "
+ "VCL files in both the system configuration and shared "
+ "data directories to allow packages to drop their VCL "
+ "files in a standard location where relative includes "
+ "would work."
+)
+
+PARAM_STRING(
+ /* name */ vmod_path,
+ /* priv */ &mgt_vmod_path,
+ /* def */ VARNISH_VMOD_DIR,
+ /* descr */
+ "Directory (or colon separated list of directories) "
+ "where VMODs are to be found."
+)
+
+# undef PARAM_ALL
+# undef PARAM_STRING
+#endif /* defined(PARAM_ALL) */
+
+#undef PARAM_SIMPLE
+#undef PARAM
+
#if 0 /* NOT ACTUALLY DEFINED HERE */
/* actual location mgt_param_bits.c*/
/* see tbl/debug_bits.h */
@@ -1637,7 +1688,4 @@ PARAM(
)
#endif /* NOT ACTUALLY DEFINED HERE */

-#undef PARAM_SIMPLE
-#undef PARAM
-
/*lint -restore */
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit