diff --git a/server/gkrellmd.h b/server/gkrellmd.h index 1cb1a58..63368e7 100644 --- a/server/gkrellmd.h +++ b/server/gkrellmd.h @@ -102,26 +102,22 @@ GKRELLMD_VERSION_REV >= (rev))) #define GKRELLMD_CONFIG "gkrellmd.conf" -#define GKRELLMD_PLUGINS_DIR ".gkrellm2/plugins-gkrellmd" - #if defined(WIN32) -#define GKRELLMD_LOCAL_PLUGINS_DIR "./plugins-gkrellmd" -#undef GKRELLMD_SYSTEM_PLUGINS_DIR + // no dot in front of config-filename on win32 + #define GKRELLMD_USER_CONFIG GKRELLMD_CONFIG #else -#define GKRELLMD_LOCAL_PLUGINS_DIR "/usr/local/lib/gkrellm2/plugins-gkrellmd" -#if !defined(GKRELLMD_SYSTEM_PLUGINS_DIR) -#define GKRELLMD_SYSTEM_PLUGINS_DIR "/usr/lib/gkrellm2/plugins-gkrellmd" + #define GKRELLMD_USER_CONFIG ".gkrellmd.conf" #endif -#endif // defined(WIN32) - - -#if defined(WIN32) -#undef GKRELLMD_SYS_ETC -#define GKRELLMD_LOCAL_ETC "./etc" -#else -#define GKRELLMD_SYS_ETC "/etc" -#define GKRELLMD_LOCAL_ETC "/usr/local/etc" -#endif // defined(WIN32) + +#define GKRELLMD_PLUGINS_DIR ".gkrellm2/plugins-gkrellmd" +#if !defined(WIN32) + #define GKRELLMD_LOCAL_PLUGINS_DIR "/usr/local/lib/gkrellm2/plugins-gkrellmd" + #if !defined(GKRELLMD_SYSTEM_PLUGINS_DIR) + #define GKRELLMD_SYSTEM_PLUGINS_DIR "/usr/lib/gkrellm2/plugins-gkrellmd" + #endif + #define GKRELLMD_SYS_ETC "/etc" + #define GKRELLMD_LOCAL_ETC "/usr/local/etc" +#endif // !defined(WIN32) typedef struct _GkrellmdClient diff --git a/server/plugins.c b/server/plugins.c index 97b67a7..9c38066 100644 --- a/server/plugins.c +++ b/server/plugins.c @@ -143,6 +143,8 @@ gkrellmd_string_suffix(gchar *string, gchar *suffix) { gchar *dot; + if (string == NULL || suffix == NULL) + return NULL; dot = strrchr(string, '.'); if (dot && !strcmp(dot + 1, suffix)) return dot + 1; @@ -180,14 +182,14 @@ gkrellmd_plugin_scan(gchar *path) gchar *s; gboolean exists; + /*if (path != NULL) + g_print("Searching for plugins in '%s'\n", path);*/ + if (!path || !*path || (dir = g_dir_open(path, 0, NULL)) == NULL) return; while ((name = (gchar *) g_dir_read_name(dir)) != NULL) { - if ( !gkrellmd_string_suffix(name, "so") - && !gkrellmd_string_suffix(name, "la") - && !gkrellmd_string_suffix(name, "dll") - ) + if (!gkrellmd_string_suffix(name, G_MODULE_SUFFIX)) continue; /* If there's a libtool .la archive, won't want to load this .so @@ -264,11 +266,31 @@ gkrellmd_plugins_load(void) gkrellmd_plugin_log("\n", NULL); } - path = g_strconcat(_GK.homedir, G_DIR_SEPARATOR_S, - GKRELLMD_PLUGINS_DIR, NULL); + path = g_build_filename(_GK.homedir, GKRELLMD_PLUGINS_DIR, NULL); gkrellmd_plugin_scan(path); g_free(path); +#if defined(WIN32) + path = NULL; +#if GLIB_CHECK_VERSION(2,16,0) + gchar *install_path; + install_path = g_win32_get_package_installation_directory_of_module(NULL); + if (install_path != NULL) + { + path = g_build_filename(install_path, "plugins-gkrellmd", NULL); + g_free(install_path); + } +#else + // deprecated since glib 2.16.0 + path = g_win32_get_package_installation_subdirectory(NULL, NULL, "plugins-gkrellmd"); +#endif + if (path) + { + gkrellmd_plugin_scan(path); + g_free(path); + } +#endif + #if defined(GKRELLMD_LOCAL_PLUGINS_DIR) gkrellmd_plugin_scan(GKRELLMD_LOCAL_PLUGINS_DIR); #endif