Merge remote branch 'trenkel/master'
[collectd.git] / src / plugin.c
index 97885a3..24b2698 100644 (file)
@@ -270,7 +270,7 @@ static int plugin_unregister (llist_t *list, const char *name) /* {{{ */
  * object, but it will bitch about a shared object not having a
  * ``module_register'' symbol..
  */
-static int plugin_load_file (char *file)
+static int plugin_load_file (char *file, uint32_t flags)
 {
        lt_dlhandle dlh;
        void (*reg_handle) (void);
@@ -280,8 +280,8 @@ static int plugin_load_file (char *file)
        lt_dlinit ();
        lt_dlerror (); /* clear errors */
 
-       /* XXX BUG FIXME */
-       if (strstr(file, "python") != NULL) {
+#if LIBTOOL_VERSION == 2
+       if (flags & PLUGIN_FLAGS_GLOBAL) {
                lt_dladvise advise;
                lt_dladvise_init(&advise);
                lt_dladvise_global(&advise);
@@ -290,6 +290,13 @@ static int plugin_load_file (char *file)
        } else {
                dlh = lt_dlopen (file);
        }
+#else /* if LIBTOOL_VERSION == 1 */
+       if (flags & PLUGIN_FLAGS_GLOBAL)
+               ERROR ("plugin_load_file: The global flag is not supported, "
+                               "libtool 2 is required for this.");
+       dlh = lt_dlopen (file);
+#endif
+
        if (dlh == NULL)
        {
                const char *error = lt_dlerror ();
@@ -545,7 +552,7 @@ void plugin_set_dir (const char *dir)
 }
 
 #define BUFSIZE 512
-int plugin_load (const char *type)
+int plugin_load (const char *type, uint32_t flags)
 {
        DIR  *dh;
        const char *dir;
@@ -607,7 +614,7 @@ int plugin_load (const char *type)
                        continue;
                }
 
-               if (plugin_load_file (filename) == 0)
+               if (plugin_load_file (filename, flags) == 0)
                {
                        /* success */
                        ret = 0;
@@ -1454,7 +1461,12 @@ void plugin_log (int level, const char *format, ...)
        llentry_t *le;
 
        if (list_log == NULL)
+       {
+               va_start (ap, format);
+               vfprintf (stderr, format, ap);
+               va_end (ap);
                return;
+       }
 
 #if !COLLECT_DEBUG
        if (level >= LOG_DEBUG)