Eina_Module * _ecore_evas_engine_load(const char *engine) { const char *path; Eina_List *l; Eina_Module *em = NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(engine, NULL); em = (Eina_Module *)eina_hash_find(_registered_engines, engine); if (em) return em; EINA_LIST_FOREACH(_engines_paths, l, path) { char tmp[PATH_MAX]; snprintf(tmp, sizeof (tmp), "%s/%s/%s/"ECORE_EVAS_ENGINE_NAME, path, engine, MODULE_ARCH); em = eina_module_new(tmp); if (!em) continue; if (!eina_module_load(em)) { eina_module_free(em); continue; } if (eina_hash_add(_registered_engines, engine, em)) return em; }
static Evas_Loader_Module_Api * loader_module_find(const char *type) { Evas_Loader_Module_Api *l; Eina_Module *em; char buf[PATH_MAX]; l = eina_hash_find(loaders, type); if (l) return l; /* FIXME: Look in every possible path, but what will those be? */ snprintf(buf, sizeof(buf), PACKAGE_LIB_DIR "/evas/cserve2/loaders/%s/%s/%s", type, MODULE_ARCH, EVAS_MODULE_NAME_IMAGE_LOADER); em = eina_module_new(buf); if (!em) return NULL; if (!eina_module_load(em)) { eina_module_free(em); return NULL; } l = eina_hash_find(loaders, type); if (l) { modules = eina_list_append(modules, em); return l; } eina_module_free(em); return NULL; }
static void _dir_list_cb(const char *name, const char *path, void *data) { Dir_List_Cb_Data *cb_data = data; size_t length; length = strlen(name); if (length < sizeof(SHARED_LIB_SUFFIX)) /* x.so */ return; if (!strcmp(name + length - sizeof(SHARED_LIB_SUFFIX) + 1, SHARED_LIB_SUFFIX)) { char *file; Eina_Module *m; length = strlen(path) + strlen(name) + 2; file = alloca(sizeof (char) * length); snprintf(file, length, "%s" SEP_S "%s", path, name); m = eina_module_new(file); if (!m) { return; /* call the user provided cb on this module */ } if (!cb_data->cb(m, cb_data->data)) eina_module_free(m); } }
bool Module::load() { m_module = EflUniquePtr<Eina_Module>(eina_module_new(m_path.utf8().data())); if (!m_module || !eina_module_load(m_module.get())) { m_module = nullptr; return false; } return true; }
Eina_Bool _elm_module_load(Elm_Module *m) { char buf[PATH_MAX]; if (m->module) return EINA_TRUE; if (strchr(m->name, '/')) return EINA_FALSE; if (getenv("ELM_RUN_IN_TREE")) { snprintf(buf, sizeof(buf), ELM_TOP_BUILD_DIR "/src/modules/%s/.libs/module"EFL_SHARED_EXTENSION, m->name); } else { snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s/module"EFL_SHARED_EXTENSION, _elm_lib_dir, m->name, MODULE_ARCH); } m->module = eina_module_new(buf); if ((m->module) && (eina_module_load(m->module) == EINA_TRUE)) { m->init_func = eina_module_symbol_get(m->module, "elm_modapi_init"); if (m->init_func) { m->shutdown_func = eina_module_symbol_get(m->module, "elm_modapi_shutdown"); m->so_path = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s", _elm_lib_dir, m->name, MODULE_ARCH); m->bin_dir = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/elementary/modules/%s", _elm_lib_dir, m->name); m->data_dir = eina_stringshare_add(buf); } else { if (m->module) { eina_module_unload(m->module); eina_module_free(m->module); m->module = NULL; } return EINA_FALSE; } } else if (m->module) { eina_module_free(m->module); m->module = NULL; } if (!m->module) return EINA_FALSE; return EINA_TRUE; }
Eina_Bool _elm_web_init(const char *engine) { char buf[PATH_MAX]; if (!bs_mod_get(buf, sizeof(buf), "elementary/web", engine)) snprintf(buf, sizeof(buf), "%s/elementary/modules/web/%s/%s/module"EFL_SHARED_EXTENSION, _elm_lib_dir, engine, MODULE_ARCH); if (ewm.m) { // Check if the module is already open if (!strcmp(buf, eina_module_file_get(ewm.m))) return EINA_TRUE; // We are leaking reference on purpose here, as we can't be sure that // the web engine is not leaking state around preventing a clean exit. // Only future elm_web object created from now will use the new engine. ewm.unneed_web = NULL; ewm.need_web = NULL; ewm.window_features_ref = NULL; ewm.window_features_unref = NULL; ewm.window_features_property_get = NULL; ewm.window_features_region_get = NULL; ewm.class_get = NULL; } ewm.m = eina_module_new(buf); if (!ewm.m) return EINA_FALSE; if (!eina_module_load(ewm.m)) { eina_module_free(ewm.m); ewm.m = NULL; return EINA_FALSE; } ewm.unneed_web = eina_module_symbol_get(ewm.m, "ewm_unneed_web"); ewm.need_web = eina_module_symbol_get(ewm.m, "ewm_need_web"); ewm.window_features_ref = eina_module_symbol_get(ewm.m, "ewm_window_features_ref"); ewm.window_features_unref = eina_module_symbol_get(ewm.m, "ewm_window_features_unref"); ewm.window_features_property_get = eina_module_symbol_get(ewm.m, "ewm_window_features_property_get"); ewm.window_features_region_get = eina_module_symbol_get(ewm.m, "ewm_window_features_region_get"); ewm.class_get = eina_module_symbol_get(ewm.m, "ewm_class_get"); // Only the class_get is mandatory if (!ewm.class_get) return EINA_FALSE; return EINA_TRUE; }
Evas_Module * evas_module_find_type(Evas_Module_Type type, const char *name) { const char *path; const char *format = NULL; char buffer[4096]; Evas_Module *em; Eina_Module *en; Eina_List *l; if ((unsigned int)type > 3) return NULL; em = eina_hash_find(evas_modules[type], name); if (em) return em; EINA_LIST_FOREACH(evas_module_paths, l, path) { switch (type) { case EVAS_MODULE_TYPE_ENGINE: format = "%s/engines/%s/%s/" EVAS_MODULE_NAME_ENGINE; break; case EVAS_MODULE_TYPE_IMAGE_LOADER: format = "%s/loaders/%s/%s/" EVAS_MODULE_NAME_IMAGE_LOADER; break; case EVAS_MODULE_TYPE_IMAGE_SAVER: format = "%s/savers/%s/%s/" EVAS_MODULE_NAME_IMAGE_SAVER; break; case EVAS_MODULE_TYPE_OBJECT: format = "%s/object/%s/%s/" EVAS_MODULE_NAME_OBJECT; break; } snprintf(buffer, sizeof (buffer), format, path, name, MODULE_ARCH, name); if (!evas_file_path_is_file(buffer)) continue; en = eina_module_new(buffer); if (!en) continue; if (!eina_module_load(en)) { eina_module_free(en); continue; } em = eina_hash_find(evas_modules[type], name); if (em) { eina_evas_modules = eina_list_append(eina_evas_modules, en); return em; } eina_module_free(en); } return NULL; }
Eina_Module * _ecore_evas_engine_load(const char *engine) { const char *path; Eina_List *l; Eina_Module *em = NULL; Eina_Bool run_in_tree; EINA_SAFETY_ON_NULL_RETURN_VAL(engine, NULL); em = (Eina_Module *)eina_hash_find(_registered_engines, engine); if (em) return em; run_in_tree = !!getenv("EFL_RUN_IN_TREE"); EINA_LIST_FOREACH(_engines_paths, l, path) { char tmp[PATH_MAX] = ""; #if defined(HAVE_GETUID) && defined(HAVE_GETEUID) if (getuid() == geteuid()) #endif { if (run_in_tree) { struct stat st; snprintf(tmp, sizeof(tmp), "%s/%s/.libs/%s", path, engine, ECORE_EVAS_ENGINE_NAME); if (stat(tmp, &st) != 0) tmp[0] = '\0'; } } if (tmp[0] == '\0') snprintf(tmp, sizeof(tmp), "%s/%s/%s/%s", path, engine, MODULE_ARCH, ECORE_EVAS_ENGINE_NAME); em = eina_module_new(tmp); if (!em) continue; if (!eina_module_load(em)) { eina_module_free(em); continue; } if (eina_hash_add(_registered_engines, engine, em)) return em; }
Eina_Module * _edje_module_handle_load(const char *module) { const char *path; Eina_List *l; Eina_Module *em = NULL; Eina_Bool run_in_tree; EINA_SAFETY_ON_NULL_RETURN_VAL(module, NULL); em = (Eina_Module *)eina_hash_find(_registered_modules, module); if (em) return em; run_in_tree = !!getenv("EFL_RUN_IN_TREE"); EINA_LIST_FOREACH(_modules_paths, l, path) { char tmp[PATH_MAX] = ""; if (run_in_tree) { struct stat st; snprintf(tmp, sizeof(tmp), "%s/%s/.libs/%s", path, module, EDJE_MODULE_NAME); if (stat(tmp, &st) != 0) tmp[0] = '\0'; } if (tmp[0] == '\0') snprintf(tmp, sizeof(tmp), "%s/%s/%s/%s", path, module, MODULE_ARCH, EDJE_MODULE_NAME); em = eina_module_new(tmp); if (!em) continue; if (!eina_module_load(em)) { eina_module_free(em); continue; } if (eina_hash_add(_registered_modules, module, em)) return em; }
/** * @brief Load a library and run a function from it which returns an #Azy_Server_Module_Def * This function loads @p file as an Eina_Module. If @p modname is specified, it attempts to call * modname() from the loaded module to create an #Azy_Server_Module_Def. If @p is NULL, the following * shell script formula will be used to generate a function name: * shell$ echo "$(basename $file | cut -d'.' -f1)_module_def" * @param file The file to load as a module (NOT NULL) * @param modname The name of the function to call of type #Azy_Server_Module_Def_Cb * @return On success, the loaded #Azy_Server_Module_Def, else NULL. */ Azy_Server_Module_Def * azy_server_module_def_load(const char *file, const char *modname) { Eina_Module *m; Azy_Server_Module_Def *ret; const char *name; char buf[4096]; Azy_Server_Module_Def_Cb cb; EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL); if (modname) name = modname; else /* attempt to autodetect module name */ { const char *s, *d; s = strrchr(file, '/'); EINA_SAFETY_ON_NULL_RETURN_VAL(s, NULL); d = strchr(++s, '.'); EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL); EINA_SAFETY_ON_TRUE_RETURN_VAL(d - s + sizeof("_module_def") > sizeof(buf), NULL); snprintf(buf, d - s + sizeof("_module_def"), "%s_module_def", s); name = buf; } m = eina_module_new(file); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); EINA_SAFETY_ON_TRUE_GOTO(!eina_module_load(m), err); cb = (Azy_Server_Module_Def_Cb)eina_module_symbol_get(m, name); EINA_SAFETY_ON_TRUE_GOTO(!cb, err); ret = cb(); EINA_SAFETY_ON_TRUE_GOTO(!ret, err); ret->module = m; return ret; err: eina_module_free(m); return NULL; }
static void _dir_arch_list_cb(const char *name, const char *path, void *data) { Dir_List_Get_Cb_Data *cb_data = data; Eina_Module *m; char *file = NULL; size_t length; length = strlen(path) + 1 + strlen(name) + 1 + strlen((char *)(cb_data->data)) + 1 + sizeof("module") + sizeof(SHARED_LIB_SUFFIX) + 1; file = alloca(length); snprintf(file, length, "%s" SEP_S "%s" SEP_S "%s" SEP_S "module" SHARED_LIB_SUFFIX, path, name, (char *)(cb_data->data)); m = eina_module_new(file); if (!m) return; eina_array_push(cb_data->array, m); }
bool InjectedBundle::initialize(const WebProcessCreationParameters&, API::Object* initializationUserData) { m_platformBundle = eina_module_new(m_path.utf8().data()); if (!m_platformBundle) { EINA_LOG_CRIT("Error loading the injected bundle: eina_module_new() failed"); return false; } if (!eina_module_load(m_platformBundle)) { EINA_LOG_CRIT("Error loading the injected bundle from %s: %s", m_path.utf8().data(), eina_error_msg_get(eina_error_get())); eina_module_free(m_platformBundle); m_platformBundle = 0; return false; } WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(eina_module_symbol_get(m_platformBundle, "WKBundleInitialize")); if (!initializeFunction) { EINA_LOG_CRIT("Error loading WKBundleInitialize symbol from injected bundle."); return false; } initializeFunction(toAPI(this), toAPI(initializationUserData)); return true; }
Eina_Bool _elm_module_load(Elm_Module *m) { const char *home; char buf[PATH_MAX]; if (m->module) return EINA_TRUE; home = getenv("HOME"); if (home) { snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/modules/%s/%s/module" EFL_SHARED_EXTENSION, home, m->name, MODULE_ARCH); m->module = eina_module_new(buf); if (m->module && eina_module_load (m->module) == EINA_TRUE) { m->init_func = eina_module_symbol_get(m->module, "elm_modapi_init"); if (m->init_func) { m->shutdown_func = eina_module_symbol_get(m->module, "elm_modapi_shutdown"); m->so_path = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/modules/%s/%s", home, m->name, MODULE_ARCH); m->bin_dir = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/modules/%s", home, m->name); m->data_dir = eina_stringshare_add(buf); } else { if (m->module) { eina_module_unload(m->module); eina_module_free(m->module); m->module = NULL; } return EINA_FALSE; } } else if (m->module) { eina_module_free(m->module); m->module = NULL; } } if (!m->module) { snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s/module" EFL_SHARED_EXTENSION, _elm_lib_dir, m->name, MODULE_ARCH); m->module = eina_module_new(buf); if (m->module && eina_module_load (m->module) == EINA_TRUE) { m->init_func = eina_module_symbol_get(m->module, "elm_modapi_init"); if (m->init_func) { m->shutdown_func = eina_module_symbol_get(m->module, "elm_modapi_shutdown"); m->so_path = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s", _elm_lib_dir, m->name, MODULE_ARCH); m->bin_dir = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/elementary/modules/%s", _elm_lib_dir, m->name); m->data_dir = eina_stringshare_add(buf); } else { if (m->module) { eina_module_unload(m->module); eina_module_free(m->module); m->module = NULL; } return EINA_FALSE; } } } else if (m->module) { eina_module_free(m->module); m->module = NULL; } if (!m->module) return EINA_FALSE; return EINA_TRUE; }