Index: libroar/plugincontainer.c
===================================================================
--- libroar/plugincontainer.c	(revision 5389)
+++ libroar/plugincontainer.c	(revision 5423)
@@ -35,4 +35,8 @@
 
 #include "libroar.h"
+
+#ifdef ROAR_HAVE_H_DIRENT
+#include <dirent.h>
+#endif
 
 #define MAX_PLUGINS 64
@@ -140,4 +144,113 @@
 
 // plugin loading and unloading:
+#ifdef ROAR_HAVE_H_DIRENT
+// pvn = prefix, host vendor, host name
+static struct roar_dl_lhandle * _load_from_path_pvn(const char * name,
+                                                       struct roar_dl_librarypara * para,
+                                                       const char * prefix,
+                                                       const char * hostvendor,
+                                                       const char * hostname) {
+ struct roar_dl_lhandle * ret = NULL;
+ int i, j;
+ char path[1024];
+ const char * path_format[] = {"%s/%s/%s", "%s/%s/universal", "%s/universal/universal"};
+ DIR * dir;
+ struct dirent * dirent;
+ char file[1024];
+ const char * file_format[] = {"%s/%s/%s", "%s/%s/%s.so", "%s/%s/lib%s.so"};
+//  cont->handle[idx] = roar_dl_open(name, ROAR_DL_FLAG_DEFAULTS, 1, para);
+//#vars: $PREFIX_PLUGINS, $hostvendor, $hostname, $name
+//#search order: $PREFIX_PLUGINS/{$hostvendor/{$hostname,universal},universal/universal}/*/{,lib}$name.so
+
+ for (i = 0; i < 3; i++) {
+  snprintf(path, sizeof(path), path_format[i], prefix, hostvendor, hostname);
+  dir = opendir(path);
+  if ( dir == NULL )
+   continue;
+
+  while ((dirent = readdir(dir)) != NULL) {
+   if ( !strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..") )
+    continue;
+
+   for (j = 0; j < 3; j++) {
+    snprintf(file, sizeof(file), file_format[j], path, dirent->d_name, name);
+    ret = roar_dl_open(file, ROAR_DL_FLAG_DEFAULTS, 1, para);
+    if ( ret != NULL ) {
+     closedir(dir);
+     return ret;
+    }
+   }
+  }
+
+  closedir(dir);
+ }
+
+ return NULL;
+}
+
+static struct roar_dl_lhandle * _load_from_path(const char * name, struct roar_dl_librarypara * para) {
+ struct roar_dl_lhandle * ret = NULL;
+ char * host = NULL;
+ char * hostvendor_buffer = NULL;
+ char * hostvendor = NULL;
+ char * hostname = NULL;
+ char * c, * d;
+
+ if ( para->appname != NULL && para->appname[0] != 0 ) {
+  host = roar_mm_strdup(para->appname);
+
+  // if we are out of memory we will likely not pass the rest, so just return in error.
+  if ( host == NULL )
+   return NULL;
+
+  hostname = host;
+  c = strstr(host, "<");
+  if ( c != NULL ) {
+   while (c[-1] == ' ') c--;
+   *c = 0;
+   c++;
+   while (*c == ' ' || *c == '<') c++;
+   if ( *c ) {
+    d = strstr(c, ">");
+    if ( d != NULL )
+     *d = 0;
+
+    d = strstr(c, "/");
+    if ( d != NULL ) {
+     *d = '-';
+     hostvendor = c;
+    } else {
+     hostvendor_buffer = roar_mm_malloc(roar_mm_strlen(c) + 1 /* tailing \0 */ + 6 /* "unreg-" */);
+
+     // see above
+     if ( hostvendor_buffer == NULL ) {
+      roar_mm_free(host);
+      return NULL;
+     }
+
+     strcpy(hostvendor_buffer, "unreg-");
+     strcat(hostvendor_buffer, c);
+     hostvendor = hostvendor_buffer;
+    }
+   }
+  }
+ }
+
+ if ( hostvendor == NULL )
+  hostvendor = "universal";
+
+ if ( hostname == NULL )
+  hostname = "universal";
+
+ ret = _load_from_path_pvn(name, para, ROAR_PREFIX_PLUGINS, hostvendor, hostname);
+
+ if ( host != NULL )
+  roar_mm_free(host);
+ if ( hostvendor_buffer != NULL )
+  roar_mm_free(hostvendor_buffer);
+ return ret;
+}
+#endif
+
 int roar_plugincontainer_load(struct roar_plugincontainer * cont, const char * name, struct roar_dl_librarypara * para) {
  ssize_t idx = -1;
@@ -174,18 +287,20 @@
  if ( strstr(name, "/") != NULL ) {
   cont->handle[idx] = roar_dl_open(name, ROAR_DL_FLAG_DEFAULTS, 1, para);
-  if ( cont->handle[idx] == NULL )
-   return -1;
-
-  cont->deprefc[idx] = 0;
-  cont->numhandles++;
-
-  return 0;
  } else {
+#ifdef ROAR_HAVE_H_DIRENT
+  cont->handle[idx] = _load_from_path(name, para);
+#else
   roar_err_set(ROAR_ERROR_NOSYS);
   return -1;
- }
-
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
+#endif
+ }
+
+ if ( cont->handle[idx] == NULL )
+  return -1;
+
+ cont->deprefc[idx] = 0;
+ cont->numhandles++;
+
+ return 0;
 }
 
