1 | --- plugins.c.orig 2005-05-08 11:57:31.000000000 -0400 |
---|
2 | +++ plugins.c 2006-11-20 09:30:28.000000000 -0500 |
---|
3 | @@ -22,6 +22,7 @@ |
---|
4 | |
---|
5 | #include "config.h" |
---|
6 | #ifdef ENABLE_PLUGINS |
---|
7 | +#include <sys/types.h> |
---|
8 | #include <dirent.h> |
---|
9 | #include <stdio.h> |
---|
10 | #include <stdlib.h> |
---|
11 | @@ -81,6 +82,8 @@ |
---|
12 | struct dirent *dirent; |
---|
13 | char full_name[FILENAME_MAX]; |
---|
14 | struct plugin_s temp_plugin, *new_plugin; |
---|
15 | + GList *plugin_names = NULL; /* keep a list of plugins found so far */ |
---|
16 | + GList *temp_list = NULL; |
---|
17 | |
---|
18 | count = 0; |
---|
19 | for (i=0; (dirent = readdir(dir)); i++) { |
---|
20 | @@ -90,7 +93,8 @@ |
---|
21 | } |
---|
22 | /* If the filename has either of these extensions then plug it in */ |
---|
23 | if ((strcmp(&(dirent->d_name[strlen(dirent->d_name)-3]), ".so")) && |
---|
24 | - (strcmp(&(dirent->d_name[strlen(dirent->d_name)-3]), ".sl"))) { |
---|
25 | + (strcmp(&(dirent->d_name[strlen(dirent->d_name)-3]), ".sl")) && |
---|
26 | + (strcmp(&(dirent->d_name[strlen(dirent->d_name)-6]), ".dylib"))) { |
---|
27 | continue; |
---|
28 | } else { |
---|
29 | jp_logf(JP_LOG_DEBUG, "found plugin %s\n", dirent->d_name); |
---|
30 | @@ -103,6 +107,7 @@ |
---|
31 | if (temp_plugin.name) { |
---|
32 | jp_logf(JP_LOG_DEBUG, "plugin name is [%s]\n", temp_plugin.name); |
---|
33 | } |
---|
34 | + if (g_list_find_custom(plugin_names, temp_plugin.name, (GCompareFunc)strcmp) == NULL) { |
---|
35 | new_plugin = malloc(sizeof(struct plugin_s)); |
---|
36 | if (!new_plugin) { |
---|
37 | jp_logf(JP_LOG_WARN, "load plugins(): %s\n", _("Out of memory")); |
---|
38 | @@ -113,13 +118,21 @@ |
---|
39 | * we want to avoid that slowness, prepend works for that |
---|
40 | * in this case since we have the head */ |
---|
41 | plugins = g_list_prepend(plugins, new_plugin); |
---|
42 | + plugin_names = g_list_prepend(plugin_names, g_strdup(temp_plugin.name)); |
---|
43 | count++; |
---|
44 | (*number)++; |
---|
45 | } |
---|
46 | } |
---|
47 | + } |
---|
48 | } |
---|
49 | |
---|
50 | plugins = g_list_sort(plugins, plugin_sort); |
---|
51 | + for (temp_list = plugin_names; temp_list; temp_list = temp_list->next) { |
---|
52 | + if (temp_list->data) { |
---|
53 | + g_free(temp_list->data); |
---|
54 | + } |
---|
55 | + } |
---|
56 | + g_list_free(plugin_names); |
---|
57 | |
---|
58 | return count; |
---|
59 | } |
---|