Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 42 additions & 21 deletions libdleyna/core/connector-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,54 @@ const dleyna_connector_t *dleyna_connector_mgr_load(const gchar *name)
const dleyna_connector_t *connector;
dleyna_connector_get_interface_t get_interface;
gchar *path;
const gchar *connector_path;
gchar **connector_path_list;
gsize i;

DLEYNA_LOG_DEBUG("Enter");

path = g_strdup_printf("%s/%s%s.so", CONNECTOR_DIR,
DLEYNA_CONNECTOR_LIB_PATTERN, name);
module = g_module_open(path, G_MODULE_BIND_LAZY);
g_free(path);
connector_path = g_getenv ("DLEYNA_CONNECTOR_PATH");
if (!connector_path) {
DLEYNA_LOG_DEBUG ("DLEYNA_CONNECTOR_PATH not set");
connector_path = CONNECTOR_DIR;
} else {
DLEYNA_LOG_DEBUG ("DLEYNA_CONNECTOR_PATH set to %s", connector_path);
}

connector_path_list = g_strsplit (connector_path, G_SEARCHPATH_SEPARATOR_S, 0);

for (i = 0; connector_path_list[i]; i++) {
path = g_strdup_printf("%s/%s%s.so", connector_path_list[i],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For maximum compatibility you could probably use g_module_build_path here but that's minor and would also probably need a change for DLEYNA_CONNECTOR_LIB_PATTERN

DLEYNA_CONNECTOR_LIB_PATTERN, name);
module = g_module_open(path, G_MODULE_BIND_LAZY);
g_free(path);

if (module) {
if (!g_connectors)
g_connectors = g_hash_table_new(g_direct_hash,
g_direct_equal);

if (g_module_symbol(module, "dleyna_connector_get_interface",
(gpointer *)&get_interface)) {
connector = get_interface();
g_hash_table_insert(g_connectors, (gpointer)connector,
module);

break;
} else {
connector = NULL;
g_module_close(module);
DLEYNA_LOG_CRITICAL(
"Connector '%s' entry point not found",
name);
}

if (module) {
if (!g_connectors)
g_connectors = g_hash_table_new(g_direct_hash,
g_direct_equal);

if (g_module_symbol(module, "dleyna_connector_get_interface",
(gpointer *)&get_interface)) {
connector = get_interface();
g_hash_table_insert(g_connectors, (gpointer)connector,
module);
} else {
connector = NULL;
g_module_close(module);
DLEYNA_LOG_CRITICAL(
"Connector '%s' entry point not found",
name);
}
}

} else {
g_strfreev (connector_path_list);

if (!module) {
connector = NULL;
DLEYNA_LOG_CRITICAL("Connector '%s' not found", name);
}
Expand Down