plugin_status_t start_plugin_list(GSList *plugin_list) { struct plugin *plugin = NULL; GSList* iterator = NULL; int rc; pthread_t check_thr; if (plugin_list == NULL) return PLUGIN_ERROR_NULL; for (iterator = plugin_list; iterator; iterator = iterator->next) { plugin = iterator->data; if (load_shared_library(plugin) != PLUGIN_OK) { printf("Failed to load %s\n", plugin->library_name); } else { if ((rc = pthread_create(&(plugin->plugin_thread), NULL, start_plugin, plugin))) { printf("Failed to create thread\n"); } } } return PLUGIN_OK; }
static inline void* calc_reloc(uint32_t offset, struct flat_hdr * header, void *base) { /* the library id is located in high byte of offset entry */ int id = (offset >> 24) & 0xff; offset &= 0x00ffffff; /* fix up offset */ if (id != 0) { /* need to load shared library */ #ifndef SHARED_LIB_SUPPORT error_user_return("No support for bFLT shared libraries built in."); #else if (load_shared_library(id, &base, header->build_date) != 0) return (void*)-1; #endif } return (void*)((uint32_t)base + offset); }
int init_external_locking(struct locking_type *locking, struct cmd_context *cmd, int suppress_messages) { const char *libname; if (_locking_lib) { log_error_suppress(suppress_messages, "External locking already initialised"); return 1; } locking->lock_resource = _lock_resource; locking->fin_locking = _fin_external_locking; locking->reset_locking = _reset_external_locking; locking->flags = 0; libname = find_config_tree_str(cmd, "global/locking_library", DEFAULT_LOCKING_LIB); if (!(_locking_lib = load_shared_library(cmd, libname, "locking", 1))) return_0; /* Get the functions we need */ if (!(_init_fn = dlsym(_locking_lib, "locking_init")) || !(_lock_fn = dlsym(_locking_lib, "lock_resource")) || !(_reset_fn = dlsym(_locking_lib, "reset_locking")) || !(_end_fn = dlsym(_locking_lib, "locking_end"))) { log_error_suppress(suppress_messages, "Shared library %s does " "not contain locking functions", libname); dlclose(_locking_lib); _locking_lib = NULL; return 0; } if (!(_lock_query_fn = dlsym(_locking_lib, "query_resource"))) log_warn_suppress(suppress_messages, "WARNING: %s: _query_resource() " "missing: Using inferior activation method.", libname); log_verbose("Loaded external locking library %s", libname); return _init_fn(2, cmd->cft, &locking->flags); }
int init_external_locking(struct locking_type *locking, struct cmd_context *cmd) { const char *libname; if (_locking_lib) { log_error("External locking already initialised"); return 1; } locking->lock_resource = _lock_resource; locking->fin_locking = _fin_external_locking; locking->reset_locking = _reset_external_locking; locking->flags = 0; libname = find_config_tree_str(cmd, "global/locking_library", DEFAULT_LOCKING_LIB); if (!(_locking_lib = load_shared_library(cmd, libname, "locking", 1))) { stack; return 0; } /* Get the functions we need */ if (!(_init_fn = dlsym(_locking_lib, "locking_init")) || !(_lock_fn = dlsym(_locking_lib, "lock_resource")) || !(_reset_fn = dlsym(_locking_lib, "reset_locking")) || !(_end_fn = dlsym(_locking_lib, "locking_end"))) { log_error("Shared library %s does not contain locking " "functions", libname); dlclose(_locking_lib); _locking_lib = NULL; return 0; } log_verbose("Loaded external locking library %s", libname); return _init_fn(2, cmd->cft, &locking->flags); }
bool open(){return (handle_ = load_shared_library(location_.c_str())) != 0;}