Code

Deleted `multicast.c' and `multicast.h'
[collectd.git] / src / plugin.c
index d2e5f47cfea5365ae3ca418b7f160bb26bc7e3b1..fc79668db24d017b24dca717615568192d73fd24 100644 (file)
@@ -25,7 +25,7 @@
 #include <ltdl.h>
 
 #include "plugin.h"
-#include "multicast.h"
+#include "network.h"
 
 typedef struct plugin
 {
@@ -52,7 +52,7 @@ char *plugin_get_dir (void)
                return (plugindir);
 }
 
-void plugin_set_dir (char *dir)
+void plugin_set_dir (const char *dir)
 {
        if (plugindir != NULL)
                free (plugindir);
@@ -80,7 +80,7 @@ int plugin_count (void)
 /*
  * Returns the plugins with the type `type' or NULL if it's not found.
  */
-plugin_t *plugin_search (char *type)
+plugin_t *plugin_search (const char *type)
 {
        plugin_t *ret;
 
@@ -136,7 +136,7 @@ int plugin_load_file (char *file)
 }
 
 #define BUFSIZE 512
-int plugin_load (char *type)
+int plugin_load (const char *type)
 {
        DIR  *dh;
        char *dir;
@@ -171,7 +171,7 @@ int plugin_load (char *type)
 
        while ((de = readdir (dh)) != NULL)
        {
-               if (strncmp (de->d_name, typename, typename_len))
+               if (strncasecmp (de->d_name, typename, typename_len))
                        continue;
 
                if (snprintf (filename, BUFSIZE, "%s/%s", dir, de->d_name) >= BUFSIZE)
@@ -289,6 +289,12 @@ void plugin_register (char *type,
        if (plugin_search (type) != NULL)
                return;
 
+#ifdef HAVE_LIBRRD
+       if ((operating_mode == MODE_LOCAL) || (operating_mode == MODE_CLIENT))
+#endif
+               if ((init != NULL) && (read == NULL))
+                       syslog (LOG_NOTICE, "Plugin `%s' doesn't provide a read function.", type);
+
        if ((p = (plugin_t *) malloc (sizeof (plugin_t))) == NULL)
                return;
 
@@ -327,7 +333,7 @@ void plugin_write (char *host, char *type, char *inst, char *val)
 
 /*
  * Receive data from the plugin/module and get it somehow to ``plugin_write'':
- * Either using ``multicast_send'' (when in network/client mode) or call it
+ * Either using ``network_send'' (when in network/client mode) or call it
  * directly (in local mode).
  */
 void plugin_submit (char *type, char *inst, char *val)
@@ -336,10 +342,10 @@ void plugin_submit (char *type, char *inst, char *val)
        if (operating_mode == MODE_LOCAL)
                plugin_write (NULL, type, inst, val);
        else if (operating_mode == MODE_CLIENT)
-               multicast_send (type, inst, val);
+               network_send (type, inst, val);
        else /* operating_mode == MODE_SERVER */
                syslog (LOG_ERR, "WTF is the server doing in ``plugin_submit''?!?\n");
 #else
-       multicast_send (type, inst, val);
+       network_send (type, inst, val);
 #endif
 }