plugins.c, gkrellmd.h: search for plugins in INSTDIR/gkrellmd-plugins on win32

This commit is contained in:
Stefan Gehn 2008-05-25 12:05:15 +00:00
parent bbe16bd885
commit bb0a4a901d
2 changed files with 41 additions and 23 deletions

View File

@ -102,26 +102,22 @@
GKRELLMD_VERSION_REV >= (rev))) GKRELLMD_VERSION_REV >= (rev)))
#define GKRELLMD_CONFIG "gkrellmd.conf" #define GKRELLMD_CONFIG "gkrellmd.conf"
#define GKRELLMD_PLUGINS_DIR ".gkrellm2/plugins-gkrellmd"
#if defined(WIN32) #if defined(WIN32)
#define GKRELLMD_LOCAL_PLUGINS_DIR "./plugins-gkrellmd" // no dot in front of config-filename on win32
#undef GKRELLMD_SYSTEM_PLUGINS_DIR #define GKRELLMD_USER_CONFIG GKRELLMD_CONFIG
#else #else
#define GKRELLMD_LOCAL_PLUGINS_DIR "/usr/local/lib/gkrellm2/plugins-gkrellmd" #define GKRELLMD_USER_CONFIG ".gkrellmd.conf"
#if !defined(GKRELLMD_SYSTEM_PLUGINS_DIR)
#define GKRELLMD_SYSTEM_PLUGINS_DIR "/usr/lib/gkrellm2/plugins-gkrellmd"
#endif #endif
#endif // defined(WIN32)
#define GKRELLMD_PLUGINS_DIR ".gkrellm2/plugins-gkrellmd"
#if !defined(WIN32)
#if defined(WIN32) #define GKRELLMD_LOCAL_PLUGINS_DIR "/usr/local/lib/gkrellm2/plugins-gkrellmd"
#undef GKRELLMD_SYS_ETC #if !defined(GKRELLMD_SYSTEM_PLUGINS_DIR)
#define GKRELLMD_LOCAL_ETC "./etc" #define GKRELLMD_SYSTEM_PLUGINS_DIR "/usr/lib/gkrellm2/plugins-gkrellmd"
#else #endif
#define GKRELLMD_SYS_ETC "/etc" #define GKRELLMD_SYS_ETC "/etc"
#define GKRELLMD_LOCAL_ETC "/usr/local/etc" #define GKRELLMD_LOCAL_ETC "/usr/local/etc"
#endif // defined(WIN32) #endif // !defined(WIN32)
typedef struct _GkrellmdClient typedef struct _GkrellmdClient

View File

@ -143,6 +143,8 @@ gkrellmd_string_suffix(gchar *string, gchar *suffix)
{ {
gchar *dot; gchar *dot;
if (string == NULL || suffix == NULL)
return NULL;
dot = strrchr(string, '.'); dot = strrchr(string, '.');
if (dot && !strcmp(dot + 1, suffix)) if (dot && !strcmp(dot + 1, suffix))
return dot + 1; return dot + 1;
@ -180,14 +182,14 @@ gkrellmd_plugin_scan(gchar *path)
gchar *s; gchar *s;
gboolean exists; 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) if (!path || !*path || (dir = g_dir_open(path, 0, NULL)) == NULL)
return; return;
while ((name = (gchar *) g_dir_read_name(dir)) != NULL) while ((name = (gchar *) g_dir_read_name(dir)) != NULL)
{ {
if ( !gkrellmd_string_suffix(name, "so") if (!gkrellmd_string_suffix(name, G_MODULE_SUFFIX))
&& !gkrellmd_string_suffix(name, "la")
&& !gkrellmd_string_suffix(name, "dll")
)
continue; continue;
/* If there's a libtool .la archive, won't want to load this .so /* 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); gkrellmd_plugin_log("\n", NULL);
} }
path = g_strconcat(_GK.homedir, G_DIR_SEPARATOR_S, path = g_build_filename(_GK.homedir, GKRELLMD_PLUGINS_DIR, NULL);
GKRELLMD_PLUGINS_DIR, NULL);
gkrellmd_plugin_scan(path); gkrellmd_plugin_scan(path);
g_free(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) #if defined(GKRELLMD_LOCAL_PLUGINS_DIR)
gkrellmd_plugin_scan(GKRELLMD_LOCAL_PLUGINS_DIR); gkrellmd_plugin_scan(GKRELLMD_LOCAL_PLUGINS_DIR);
#endif #endif