Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
rwmjones committed Dec 12, 2019
1 parent 5317291 commit a895fa8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/nbdkit-plugin.pod
Expand Up @@ -1329,6 +1329,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
Expand Down
10 changes: 9 additions & 1 deletion server/debug-flags.c
Expand Up @@ -47,12 +47,20 @@ static char *
name_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 */
}

Expand Down

0 comments on commit a895fa8

Please sign in to comment.