67 lines
2.0 KiB
Diff
67 lines
2.0 KiB
Diff
From e5d2d44fff9214725506cbc84e7b3c035ec0eae9 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Thu, 12 Dec 2019 11:06:36 +0000
|
|
Subject: [PATCH] server: Allow -D debug flags to contain dots for namespacing.
|
|
|
|
This is just a convenience. Either of:
|
|
|
|
-D myplugin.foo_bar=1
|
|
-D myplugin.foo.bar=1
|
|
|
|
correspond to the same plugin variable "myplugin_debug_foo_bar".
|
|
|
|
(cherry picked from commit a895fa84aaa50f52af68319523020046394c789f)
|
|
---
|
|
docs/nbdkit-plugin.pod | 8 ++++++++
|
|
server/debug-flags.c | 10 +++++++++-
|
|
2 files changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/docs/nbdkit-plugin.pod b/docs/nbdkit-plugin.pod
|
|
index b69cb82..879ddf0 100644
|
|
--- a/docs/nbdkit-plugin.pod
|
|
+++ b/docs/nbdkit-plugin.pod
|
|
@@ -1298,6 +1298,14 @@ You should only use this feature for debug settings. For general
|
|
settings use ordinary plugin parameters. Debug Flags can only be C
|
|
ints. They are not supported by non-C language plugins.
|
|
|
|
+For convenience C<'.'> characters are replaced with C<'_'> characters
|
|
+in the variable name, so both of these parameters:
|
|
+
|
|
+ -D myplugin.foo_bar=1
|
|
+ -D myplugin.foo.bar=1
|
|
+
|
|
+correspond to the plugin variable C<myplugin_debug_foo_bar>.
|
|
+
|
|
=head1 INSTALLING THE PLUGIN
|
|
|
|
The plugin is a C<*.so> file and possibly a manual page. You can of
|
|
diff --git a/server/debug-flags.c b/server/debug-flags.c
|
|
index 9344d85..5e06f5e 100644
|
|
--- a/server/debug-flags.c
|
|
+++ b/server/debug-flags.c
|
|
@@ -56,12 +56,20 @@ static char *
|
|
symbol_of_debug_flag (const char *name, const char *flag)
|
|
{
|
|
char *var;
|
|
+ size_t i;
|
|
+ int len;
|
|
|
|
- if (asprintf (&var, "%s_debug_%s", name, flag) == -1) {
|
|
+ if ((len = asprintf (&var, "%s_debug_%s", name, flag)) == -1) {
|
|
perror ("asprintf");
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
+ /* If there are any '.'s remaining in the name, convert them to '_'. */
|
|
+ for (i = 0; i < (size_t) len; ++i) {
|
|
+ if (var[i] == '.')
|
|
+ var[i] = '_';
|
|
+ }
|
|
+
|
|
return var; /* caller frees */
|
|
}
|
|
|
|
--
|
|
2.18.2
|
|
|