From: octo Date: Tue, 13 Dec 2005 21:50:01 +0000 (+0000) Subject: Added defines `SYSCONFDIR' and `CONFIGFILE' to `collectd.h' X-Git-Tag: collectd-3.5.0~7^2~10 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=3454b5396956be55d89e2dfe5f3a7627233aff4f;p=collectd.git Added defines `SYSCONFDIR' and `CONFIGFILE' to `collectd.h' Added function `plugin_exists (char *type)' to `plugin.[ch]' --- diff --git a/src/Makefile.am b/src/Makefile.am index 207288d5..f4ac403c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,7 +14,7 @@ collectd_SOURCES = collectd.c collectd.h \ plugin.c plugin.h \ configfile.c configfile.h #collectd_CFLAGS = -DPLUGINDIR='"$(pkglibdir)"' -collectd_CPPFLAGS = -DLOCALSTATEDIR='"$(localstatedir)"' -DPLUGINDIR='"$(pkglibdir)"' +collectd_CPPFLAGS = -DLOCALSTATEDIR='"$(localstatedir)"' -DSYSCONFDIR='"$(sysconfdir)"' -DPLUGINDIR='"$(pkglibdir)"' collectd_LDFLAGS = -export-dynamic collectd_CFLAGS = -Werror collectd_LDADD = $(LIBLTDL) libconfig/libconfig.la "-dlopen" self diff --git a/src/collectd.h b/src/collectd.h index c7aa925a..32b9735d 100644 --- a/src/collectd.h +++ b/src/collectd.h @@ -162,6 +162,14 @@ #define PIDFILE LOCALSTATEDIR"/run/collectd.pid" #endif +#ifndef SYSCONFDIR +#define SYSCONFDIR "/opt/collectd/etc" +#endif + +#ifndef CONFIGFILE +#define CONFIGFILE SYSCONFDIR"/collectd.conf" +#endif + #define MODE_SERVER 0x01 #define MODE_CLIENT 0x02 #define MODE_LOCAL 0x03 diff --git a/src/plugin.c b/src/plugin.c index a6792de0..a249cf76 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -74,6 +74,18 @@ plugin_t *plugin_search (char *type) } /* + * Returns true if the plugin is loaded (i.e. `exists') and false otherwise. + * This is used in `configfile.c' to skip sections that are not needed.. + */ +bool plugin_exists (char *type) +{ + if (plugin_search (type) == NULL) + return (false); + else + return (true); +} + +/* * (Try to) load the shared object `name'. Won't complain if it isn't a shared * object, but it will bitch about a shared object not having a * ``module_register'' symbol.. diff --git a/src/plugin.h b/src/plugin.h index 4a8b7ad7..e14376e5 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -27,6 +27,7 @@ int plugin_load_all (char *dir); void plugin_init_all (void); void plugin_read_all (void); +bool plugin_exists (char *type); void plugin_register (char *type, void (*init) (void), void (*read) (void),