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