Stop hardcoding plugin extensions everywhere

This commit is contained in:
TingPing 2014-06-04 11:15:35 -04:00
parent 5849a0588e
commit 11e3ecc739
4 changed files with 13 additions and 64 deletions

View File

@ -2541,7 +2541,6 @@ cmd_load (struct session *sess, char *tbuf, char *word[], char *word_eol[])
char *file, *buf; char *file, *buf;
#ifdef USE_PLUGIN #ifdef USE_PLUGIN
char *error, *arg; char *error, *arg;
int len;
#endif #endif
if (!word[2][0]) if (!word[2][0])
@ -2562,16 +2561,7 @@ cmd_load (struct session *sess, char *tbuf, char *word[], char *word_eol[])
} }
#ifdef USE_PLUGIN #ifdef USE_PLUGIN
len = strlen (word[2]); if (g_str_has_suffix (word[2], "."G_MODULE_SUFFIX))
#ifdef WIN32
if (len > 4 && g_ascii_strcasecmp (".dll", word[2] + len - 4) == 0)
#else
#if defined(__hpux)
if (len > 3 && g_ascii_strcasecmp (".sl", word[2] + len - 3) == 0)
#else
if (len > 3 && g_ascii_strcasecmp (".so", word[2] + len - 3) == 0)
#endif
#endif
{ {
arg = NULL; arg = NULL;
if (word_eol[3][0]) if (word_eol[3][0])
@ -3567,18 +3557,9 @@ static int
cmd_unload (struct session *sess, char *tbuf, char *word[], char *word_eol[]) cmd_unload (struct session *sess, char *tbuf, char *word[], char *word_eol[])
{ {
#ifdef USE_PLUGIN #ifdef USE_PLUGIN
int len, by_file = FALSE; gboolean by_file = FALSE;
len = strlen (word[2]); if (g_str_has_suffix (word[2], "."G_MODULE_SUFFIX))
#ifdef WIN32
if (len > 4 && g_ascii_strcasecmp (word[2] + len - 4, ".dll") == 0)
#else
#if defined(__hpux)
if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".sl") == 0)
#else
if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".so") == 0)
#endif
#endif
by_file = TRUE; by_file = TRUE;
switch (plugin_kill (word[2], by_file)) switch (plugin_kill (word[2], by_file))
@ -3601,18 +3582,9 @@ static int
cmd_reload (struct session *sess, char *tbuf, char *word[], char *word_eol[]) cmd_reload (struct session *sess, char *tbuf, char *word[], char *word_eol[])
{ {
#ifdef USE_PLUGIN #ifdef USE_PLUGIN
int len, by_file = FALSE; gboolean by_file = FALSE;
len = strlen (word[2]); if (g_str_has_suffix (word[2], "."G_MODULE_SUFFIX))
#ifdef WIN32
if (len > 4 && g_ascii_strcasecmp (word[2] + len - 4, ".dll") == 0)
#else
#if defined(__hpux)
if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".sl") == 0)
#else
if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".so") == 0)
#endif
#endif
by_file = TRUE; by_file = TRUE;
switch (plugin_reload (sess, word[2], by_file)) switch (plugin_reload (sess, word[2], by_file))

View File

@ -460,17 +460,11 @@ plugin_auto_load (session *sess)
for_files (lib_dir, "hcupd.dll", plugin_auto_load_cb); for_files (lib_dir, "hcupd.dll", plugin_auto_load_cb);
for_files (lib_dir, "hcwinamp.dll", plugin_auto_load_cb); for_files (lib_dir, "hcwinamp.dll", plugin_auto_load_cb);
for_files (lib_dir, "hcsysinfo.dll", plugin_auto_load_cb); for_files (lib_dir, "hcsysinfo.dll", plugin_auto_load_cb);
#else
for_files (lib_dir, "*."G_MODULE_SUFFIX, plugin_auto_load_cb);
#endif
for_files (sub_dir, "*.dll", plugin_auto_load_cb); for_files (sub_dir, "*."G_MODULE_SUFFIX, plugin_auto_load_cb);
#else
#if defined(__hpux)
for_files (lib_dir, "*.sl", plugin_auto_load_cb);
for_files (sub_dir, "*.sl", plugin_auto_load_cb);
#else
for_files (lib_dir, "*.so", plugin_auto_load_cb);
for_files (sub_dir, "*.so", plugin_auto_load_cb);
#endif
#endif
g_free (sub_dir); g_free (sub_dir);
} }

View File

@ -161,11 +161,7 @@ plugingui_load (void)
sub_dir = g_build_filename (get_xdir(), "addons", NULL); sub_dir = g_build_filename (get_xdir(), "addons", NULL);
gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess, gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess,
#ifdef WIN32 sub_dir, "*."G_MODULE_SUFFIX";*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);
sub_dir, "*.dll;*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);
#else
sub_dir, "*.so;*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);
#endif
g_free (sub_dir); g_free (sub_dir);
} }
@ -179,7 +175,6 @@ plugingui_loadbutton_cb (GtkWidget * wid, gpointer unused)
static void static void
plugingui_unload (GtkWidget * wid, gpointer unused) plugingui_unload (GtkWidget * wid, gpointer unused)
{ {
int len;
char *modname, *file, *buf; char *modname, *file, *buf;
GtkTreeView *view; GtkTreeView *view;
GtkTreeIter iter; GtkTreeIter iter;
@ -189,16 +184,7 @@ plugingui_unload (GtkWidget * wid, gpointer unused)
FILE_COLUMN, &file, -1)) FILE_COLUMN, &file, -1))
return; return;
len = strlen (file); if (g_str_has_suffix (file, "."G_MODULE_SUFFIX))
#ifdef WIN32
if (len > 4 && g_ascii_strcasecmp (file + len - 4, ".dll") == 0)
#else
#if defined(__hpux)
if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".sl") == 0)
#else
if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".so") == 0)
#endif
#endif
{ {
if (plugin_kill (modname, FALSE) == 2) if (plugin_kill (modname, FALSE) == 2)
fe_message (_("That plugin is refusing to unload.\n"), FE_MSG_ERROR); fe_message (_("That plugin is refusing to unload.\n"), FE_MSG_ERROR);

View File

@ -153,11 +153,8 @@ initialize_enchant ()
GModule *enchant; GModule *enchant;
gpointer funcptr; gpointer funcptr;
#ifdef WIN32
enchant = g_module_open("libenchant.dll", 0); enchant = g_module_open("libenchant."G_MODULE_SUFFIX, 0);
#else
enchant = g_module_open("libenchant", 0);
#endif
if (enchant == NULL) if (enchant == NULL)
{ {
#ifndef WIN32 #ifndef WIN32