summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a7e84e9)
raw | patch | inline | side by side (parent: a7e84e9)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 10 Mar 2013 21:38:05 +0000 (22:38 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 10 Mar 2013 21:38:05 +0000 (22:38 +0100) |
That is, behave similar to Perl when encountering a '::' in a plugin's name and
translate that to a slash. "foo::bar" will thus become PKGLIBDIR/foo/bar.so.
This will be used to name plugins accessing the same backend using different
methods and to have an, imho, nicer name for those.
The daemon will now use that to prepend "backend::" to the name of backends.
This is no different to the behavior before but only uses different names that
will be displayed in log messages.
translate that to a slash. "foo::bar" will thus become PKGLIBDIR/foo/bar.so.
This will be used to name plugins accessing the same backend using different
methods and to have an, imho, nicer name for those.
The daemon will now use that to prepend "backend::" to the name of backends.
This is no different to the behavior before but only uses different names that
will be displayed in log messages.
src/core/plugin.c | patch | blob | history | |
src/daemon/config.c | patch | blob | history |
diff --git a/src/core/plugin.c b/src/core/plugin.c
index 306f5e902565d3a0b025ea8d08851672a4b53fbe..c8e8e9e0db06a7799275608b4724eb8929d5b89f 100644 (file)
--- a/src/core/plugin.c
+++ b/src/core/plugin.c
int
sdb_plugin_load(const char *name)
{
+ char real_name[strlen(name) > 0 ? strlen(name) : 1];
+ const char *name_ptr;
+ char *tmp;
+
char filename[1024];
lt_dlhandle lh;
int status;
+ if ((! name) || (! *name))
+ return -1;
+
+ real_name[0] = '\0';
+ name_ptr = name;
+
+ while ((tmp = strstr(name_ptr, "::"))) {
+ strncat(real_name, name_ptr, (size_t)(tmp - name_ptr));
+ strcat(real_name, "/");
+ name_ptr = tmp + strlen("::");
+ }
+ strcat(real_name, name_ptr);
+
snprintf(filename, sizeof(filename), "%s/%s.so",
- PKGLIBDIR, name);
+ PKGLIBDIR, real_name);
filename[sizeof(filename) - 1] = '\0';
if (access(filename, R_OK)) {
char errbuf[1024];
- sdb_log(SDB_LOG_ERR, "plugin: Failed to load plugin '%s': %s\n",
- name, sdb_strerror(errno, errbuf, sizeof(errbuf)));
+ sdb_log(SDB_LOG_ERR, "plugin: Failed to load plugin '%s' (%s): %s\n",
+ name, filename, sdb_strerror(errno, errbuf, sizeof(errbuf)));
return -1;
}
diff --git a/src/daemon/config.c b/src/daemon/config.c
index 2975e06fa7d218393907bbcd770809d6689353ff..95e45e311aa9409da52236ecf7d0808d5290e1bb 100644 (file)
--- a/src/daemon/config.c
+++ b/src/daemon/config.c
return -1;
}
- snprintf(plugin_name, sizeof(plugin_name), "backend/%s", name);
+ snprintf(plugin_name, sizeof(plugin_name), "backend::%s", name);
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *child = ci->children + i;