Пример #1
0
static Multisense_Data *
init_multisense_environment(void)
{
   Multisense_Data *msdata;
   char ms_factory[BUF_LEN];
   char *ms_factory_env;
   Eina_Module *m = NULL;
   MULTISENSE_FACTORY_INIT_FUNC multisense_factory_init;

   msdata = calloc(1, sizeof(Multisense_Data));
   if (!msdata) goto err;

   msdata->msenv = calloc(1, sizeof(Edje_Multisense_Env));
   if (!msdata->msenv) goto err;

   ms_factory_env = getenv("MULTISENSE_FACTORY");
   if (ms_factory_env)
     strncpy(ms_factory, ms_factory_env, BUF_LEN);
   else
     strcpy(ms_factory, "multisense_factory");
   
   m = _edje_module_handle_load(ms_factory);
   if (!m) goto err;
   
   msdata->msenv->remixenv = remix_init();

   multisense_factory_init = 
     eina_module_symbol_get(m, "multisense_factory_init");
   if (multisense_factory_init) multisense_factory_init(msdata->msenv);

   msdata->multisense_sound_player_get = 
     eina_module_symbol_get(m, "multisense_sound_player_get");
   if (!msdata->multisense_sound_player_get) goto err;

   msdata->deck = remix_deck_new(msdata->msenv->remixenv);
   msdata->track = remix_track_new(msdata->msenv->remixenv, msdata->deck);
   msdata->snd_layer = remix_layer_new_ontop(msdata->msenv->remixenv,
                                             msdata->track,
                                             REMIX_TIME_SAMPLES);
   msdata->player_layer = remix_layer_new_ontop(msdata->msenv->remixenv,
                                                msdata->track,
                                                REMIX_TIME_SAMPLES);
   msdata->player = msdata->multisense_sound_player_get(msdata->msenv);
   if (!msdata->player) goto err;
   msdata->player_snd = remix_sound_new(msdata->msenv->remixenv,
                                        msdata->player, msdata->player_layer,
                                        REMIX_SAMPLES(0),
                                        REMIX_SAMPLES(REMIX_COUNT_INFINITE));
   return msdata;

err:
   if (msdata)
     {
        if (msdata->deck) remix_destroy(msdata->msenv->remixenv, msdata->deck);
        if (msdata->msenv->remixenv) remix_purge(msdata->msenv->remixenv);
        if (msdata->msenv) free(msdata->msenv);
        free(msdata);
     }
   return NULL;
}
Пример #2
0
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;
}
Пример #3
0
void* Module::platformFunctionPointer(const char* functionName) const
{
    if (m_module)
        return eina_module_symbol_get(m_module.get(), functionName);

    return 0;
}
Пример #4
0
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;
}
Пример #5
0
void eweather_plugin_byname_set(EWeather *eweather, const char *name)
{
   Eina_Array *array;
   Eina_Module *m;
   int i;
   Eina_Array_Iterator it;
   
   array = eweather_plugins_list_get(eweather);
   EINA_ARRAY_ITER_NEXT(array, i, m, it)
     {
	EWeather_Plugin *plugin = eina_module_symbol_get(m, "_plugin_class");
	if(plugin && !strcmp(name, plugin->name))
	  {
	     eweather_plugin_set(eweather, m);
	     break ;
	  }
     }
Пример #6
0
/**
 * @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;
}
Пример #7
0
const void *
_elm_module_symbol_get(Elm_Module *m, const char *name)
{
   return eina_module_symbol_get(m->module, name);
}
Пример #8
0
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;
}
Пример #9
0
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;
}
Пример #10
0
#endif

#include <stdio.h>

#include "eina_suite.h"
#include "Eina.h"

static Eina_Bool list_cb(Eina_Module *m, void *data EINA_UNUSED)
{
   int *sym;
   const char *file;

   /* the reference count */
   eina_module_load(m);
   /* get */
   sym = eina_module_symbol_get(m, "dummy_symbol");
   fail_if(!sym);
   fail_if(*sym != 0xbad);
   file = eina_module_file_get(m);
   fail_if(!file);
   eina_module_unload(m);

   return EINA_TRUE;
}


START_TEST(eina_module_load_unload)
{
   Eina_Array *_modules;

   eina_init();