Added defines `SYSCONFDIR' and `CONFIGFILE' to `collectd.h'
authorocto <octo>
Tue, 13 Dec 2005 21:50:01 +0000 (21:50 +0000)
committerocto <octo>
Tue, 13 Dec 2005 21:50:01 +0000 (21:50 +0000)
Added function `plugin_exists (char *type)' to `plugin.[ch]'

src/Makefile.am
src/collectd.h
src/plugin.c
src/plugin.h

index 207288d..f4ac403 100644 (file)
@@ -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
index c7aa925..32b9735 100644 (file)
 #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
index a6792de..a249cf7 100644 (file)
@@ -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..
index 4a8b7ad..e14376e 100644 (file)
@@ -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),