From 9242c5de0045683d5fd33455d7a88b37a1b6f823 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 22 Apr 2007 22:57:43 +0200 Subject: [PATCH] perl plugin: Added the "IncludeDir" config option. "IncludeDir " adds to the @INC array. A segfault when parsing unknown config options has been fixed and documentation about the perl plugin has been added to collectd.conf.pod. Signed-off-by: Sebastian Harl --- src/collectd.conf.in | 1 + src/collectd.conf.pod | 21 +++++++++++++++++++++ src/perl.c | 7 ++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 4cfa694a..2986edf3 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -149,6 +149,7 @@ # # +# IncludeDir "/my/include/path" # BaseName "Collectd::Plugin" # LoadPlugin foo # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index da50a346..32f74cd7 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -437,6 +437,27 @@ L. =back +=head2 Plugin C + +=over 4 + +=item B I + +Loads the Perl plugin I. This does basically the same as B would +do in a Perl program. + +=item B I + +Prepends IB<::> to all plugin names loaded after this option. This is +provided for convenience to keep plugin names short. + +=item B I + +Adds I to the B<@INC> array. This is the same as using the B<-IDir> +command line option or B in the source code. + +=back + =head2 Plugin C =over 4 diff --git a/src/perl.c b/src/perl.c index f42708d7..c9977496 100644 --- a/src/perl.c +++ b/src/perl.c @@ -85,7 +85,7 @@ static const char *config_keys[] = { "LoadPlugin", "BaseName", - NULL + "IncludeDir" }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); @@ -973,6 +973,11 @@ static int perl_config (const char *key, const char *value) strncpy (base_name, value, sizeof (base_name)); base_name[sizeof (base_name) - 1] = '\0'; } + else if (0 == strcasecmp (key, "IncludeDir")) { + Perl_av_unshift (perl, GvAVn (PL_incgv), 1); + Perl_av_store (perl, GvAVn (PL_incgv), + 0, Perl_newSVpv (perl, value, strlen (value))); + } else { return -1; } -- 2.11.0