Index: src/hid_init.c =================================================================== --- src/hid_init.c (revision 3579) +++ src/hid_init.c (revision 3580) @@ -72,20 +72,24 @@ fprintf(stderr, "dl_error: %s\n", dlerror()); } else { - symname = Concat("hid_", basename, "_init", NULL); - if ((sym = dlsym(so, symname)) != NULL) { - symv = (pcb_uninit_t (*)())pcb_cast_d2f(sym); - uninit = symv(); + plugin_info_t *inf = plugin_find(basename); + if (inf == NULL) { + symname = Concat("hid_", basename, "_init", NULL); + if ((sym = dlsym(so, symname)) != NULL) { + symv = (pcb_uninit_t (*)())pcb_cast_d2f(sym); + uninit = symv(); + } + else if ((sym = dlsym(so, "pcb_plugin_init")) != NULL) { + symv = (pcb_uninit_t (*)()) pcb_cast_d2f(sym); + uninit = symv(); + } + else + uninit = NULL; + plugin_register(basename, path, so, 1, uninit); + free(symname); } - else if ((sym = dlsym(so, "pcb_plugin_init")) != NULL) { - symv = (pcb_uninit_t (*)()) pcb_cast_d2f(sym); - uninit = symv(); - } else - uninit = NULL; - - plugin_register(basename, path, so, 1, uninit); - free(symname); + Message(PCB_MSG_ERROR, "Can't load %s because it'd provide plugin %s that is already loaded from %s\n", path, basename, (*inf->path == '<' ? "" : inf->path)); } } free(basename); Index: src/plugins.c =================================================================== --- src/plugins.c (revision 3579) +++ src/plugins.c (revision 3580) @@ -35,6 +35,15 @@ plugin_info_t *plugins = NULL; +plugin_info_t *plugin_find(const char *name) +{ + plugin_info_t *i; + for(i = plugins; i != NULL; i = i->next) + if (strcmp(i->name, name) == 0) + return i; + return NULL; +} + void plugin_register(const char *name, const char *path, void *handle, int dynamic_loaded, void (*uninit)(void)) { plugin_info_t *i = malloc(sizeof(plugin_info_t)); Index: src/plugins.h =================================================================== --- src/plugins.h (revision 3579) +++ src/plugins.h (revision 3580) @@ -50,6 +50,8 @@ /* Register a new plugin (or buildin) */ void plugin_register(const char *name, const char *path, void *handle, int dynamic, pcb_uninit_t uninit); +/* Find a plugin by name */ +plugin_info_t *plugin_find(const char *name); /* Hook based plugin generics; plugins that implement a common API should use HOOK_REGISTER with an api struct. The core should run the plugins using