/*
 * Initialize the repository
 */
int mca_base_component_repository_init(void)
{
  /* Setup internal structures */

  if (!initialized) {
#if OPAL_WANT_LIBLTDL
    /* Initialize libltdl */

    if (lt_dlinit() != 0) {
      return OPAL_ERR_OUT_OF_RESOURCE;
    }

#if OPAL_HAVE_LTDL_ADVISE
    if (lt_dladvise_init(&opal_mca_dladvise)) {
        return OPAL_ERR_OUT_OF_RESOURCE;
    }

    if (lt_dladvise_ext(&opal_mca_dladvise)) {
        return OPAL_ERROR;
    }

    if (lt_dladvise_global(&opal_mca_dladvise)) {
        return OPAL_ERROR;
    }
#endif

    OBJ_CONSTRUCT(&repository, opal_list_t);
#endif
    initialized = true;
  }

  /* All done */

  return OPAL_SUCCESS;
}
Ejemplo n.º 2
0
void
DynamicLoaderModule::init( SLIInterpreter* i )
{

  // bind functions to terminal names
  i->createcommand( "Install", &loadmodule_function );

  // initialize ltdl library for loading dynamic modules

  int dl_error = lt_dlinit();

  if ( !dl_error )
  {
    const char* path = getenv( "SLI_MODULE_PATH" );
    if ( path != NULL )
    {
      i->message( SLIInterpreter::M_INFO, "DynamicLoaderModule::init", "Setting module path to" );
      i->message( SLIInterpreter::M_INFO, "DynamicLoaderModule::init", path );

      dl_error = lt_dlsetsearchpath( path );
      if ( dl_error )
        i->message( SLIInterpreter::M_ERROR,
          "DynamicLoaderModule::init",
          "Could not set dynamic module path." );
    }
  }
  else
  {
    i->message( SLIInterpreter::M_ERROR,
      "DynamicLoaderModule::init",
      "Could not initialize libltdl. No dynamic modules will be avaiable." );
  }
}
Ejemplo n.º 3
0
/**
 * oh_init_ltdl
 *
 * Does all the initialization needed for the ltdl process to
 * work. It takes no arguments, and returns 0 on success, < 0 on error
 *
 * Returns: 0 on Success.
 **/
static int oh_init_ltdl(void)
{
    struct oh_global_param path_param = { .type = OPENHPI_PATH };
    int err;
    static int init_done = 0;

    data_access_lock();
    if (init_done) {
        data_access_unlock();
        return 0;
    }

    err = lt_dlinit();
    if (err != 0) {
        dbg("Can not init ltdl");
        data_access_unlock();
        return -1;
    }

    oh_get_global_param(&path_param);

    err = lt_dlsetsearchpath(path_param.u.path);
    if (err != 0) {
        dbg("Can not set lt_dl search path");
        oh_exit_ltdl();
        data_access_unlock();
        return -1;
    }

    init_done = 1;
    data_access_unlock();

    return 0;
}
Ejemplo n.º 4
0
static void
sysdep_dynl_init ()
{
  char *env;

  lt_dlinit ();

  /* Initialize 'system_extensions_path' from
     $GUILE_SYSTEM_EXTENSIONS_PATH, or if that's not set:
     <SCM_LIB_DIR> <LT_PATHSEP_CHAR> <SCM_EXTENSIONS_DIR>.

     'lt_dladdsearchdir' can't be used because it is searched before
     the system-dependent search path, which is the one 'libtool
     --mode=execute -dlopen' fiddles with (info "(libtool) Libltdl
     Interface").  See
     <http://lists.gnu.org/archive/html/guile-devel/2010-11/msg00095.html>.

     The environment variables $LTDL_LIBRARY_PATH and $LD_LIBRARY_PATH
     can't be used because they would be propagated to subprocesses
     which may cause problems for other programs.  See
     <http://lists.gnu.org/archive/html/guile-devel/2012-09/msg00037.html> */

  env = getenv ("GUILE_SYSTEM_EXTENSIONS_PATH");
  if (env)
    system_extensions_path = env;
  else
    {
      system_extensions_path
        = scm_gc_malloc_pointerless (strlen (SCM_LIB_DIR)
                                     + strlen (SCM_EXTENSIONS_DIR) + 2,
                                     "system_extensions_path");
      sprintf (system_extensions_path, "%s%c%s",
               SCM_LIB_DIR, LT_PATHSEP_CHAR, SCM_EXTENSIONS_DIR);
    }
}
Ejemplo n.º 5
0
/*
 * (Try to) load the shared object `file'. Won't complain if it isn't a shared
 * object, but it will bitch about a shared object not having a
 * ``module_register'' symbol..
 */
static int plugin_load_file (char *file)
{
	lt_dlhandle dlh;
	void (*reg_handle) (void);

	DEBUG ("file = %s", file);

	lt_dlinit ();
	lt_dlerror (); /* clear errors */

	if ((dlh = lt_dlopen (file)) == NULL)
	{
		const char *error = lt_dlerror ();

		ERROR ("lt_dlopen (%s) failed: %s", file, error);
		fprintf (stderr, "lt_dlopen (%s) failed: %s\n", file, error);
		return (1);
	}

	if ((reg_handle = (void (*) (void)) lt_dlsym (dlh, "module_register")) == NULL)
	{
		WARNING ("Couldn't find symbol `module_register' in `%s': %s\n",
				file, lt_dlerror ());
		lt_dlclose (dlh);
		return (-1);
	}

	(*reg_handle) ();

	return (0);
}
Ejemplo n.º 6
0
void PluginManager::start(){
  Logger* log = Logger::getLogger();

  std::string list = Settings::getSettings()->get("autoload_plugins");
  size_t pos_c = 0;
  size_t pos_e;
  if(list.length() > 0){
    while(pos_c != list.npos){
      pos_e = list.find(",", pos_c);
      load(list.substr(pos_c, pos_e));
      pos_c = pos_e;
    }
  }else{
    log->info("No automatically loaded plugins were defined in the "
        "configuation, add \"autoload_plugins = <comma list of plugins>\" to conf "
        "to have them loaded.");
  }

  /* Initalise the ltdl module. */
  LTDL_SET_PRELOADED_SYMBOLS();
  if(lt_dlinit() != 0){
    // FIXME: Should raise an error here.!
    log->error("Failed to load initalise the loader %s", lt_dlerror());
	stop();
  }

  /* Need to load ourselves before we can load other modules. */
  lt_dlhandle nlib = lt_dlopen(NULL);
  if(nlib == NULL){
    log->error("Failed to load ourselves because %s.", lt_dlerror());
	stop();
  }

}
Ejemplo n.º 7
0
int
radiusd_add_load_path(const char *path)
{
	if (lt_dlinit())
		return 1;
	return lt_dladdsearchdir(path);
}
Ejemplo n.º 8
0
int init_module_loading()
{
	int ret;
	static int initialised=0;
	
	if (initialised){
		LOG(L_CRIT, "BUG: init_module_loading: already intialised\n");
		return -1;
	}
	/* make sure preloaded modules are initialised */
	/*LTDL_SET_PRELOADED_SYMBOLS();*/
	ret=lt_dlinit();
	
	if (ret){
		LOG(L_CRIT, "ERROR: init_module_loading: lt_dlinit failed: %s\n",
				lt_dlerror());
		goto error;
	}
	
	ret=lt_dlsetsearchpath(MODULE_SEARCH_PATH);
	if (ret){
		LOG(L_CRIT, "ERROR: init_module_loading: lt_dlsetsearchpath "
					"failed: %s\n",
				lt_dlerror());
		goto error;
	}
	initialised++;
	return ret;
error:
	lt_dlexit();
	return -1;
}
Ejemplo n.º 9
0
int
radiusd_set_load_path(const char *path)
{
	if (lt_dlinit())
		return 1;
	return lt_dlsetsearchpath(path);
}
Ejemplo n.º 10
0
/**
 * librdf_new_world:
 *
 * Create a new Redland execution environment.
 *
 * Once this constructor is called to build a #librdf_world object
 * several functions may be called to set some parameters such as
 * librdf_world_set_error(), librdf_world_set_warning(),
 * librdf_world_set_logger(), librdf_world_set_digest(),
 * librdf_world_set_feature().
 *
 * The world object needs initializing using librdf_world_open()
 * whether or not the above functions are called.  It will be
 * automatically called by all object constructors in Redland 1.0.6
 * or later, but for earlier versions it MUST be called before using
 * any other part of Redland.
 *
 * Returns: a new #librdf_world or NULL on failure
 */
librdf_world*
librdf_new_world(void)
{
  librdf_world *world;
#ifdef HAVE_GETTIMEOFDAY
  struct timeval tv;
  struct timezone tz;
#endif

  world = (librdf_world*)LIBRDF_CALLOC(librdf_world, sizeof(*world), 1);

  if(!world)
    return NULL;

#ifdef HAVE_GETTIMEOFDAY
  if(!gettimeofday(&tv, &tz)) {
    world->genid_base = tv.tv_sec;
  } else
    world->genid_base = 1;
#else
  world->genid_base = 1;
#endif
  world->genid_counter = 1;
  
#ifdef MODULAR_LIBRDF
  world->ltdl_opened = !(lt_dlinit());
  if (world->ltdl_opened)
    lt_dlsetsearchpath(REDLAND_MODULE_PATH);
  else
    LIBRDF_DEBUG1("lt_dlinit() failed\n");
#endif

  return world;
  
}
Ejemplo n.º 11
0
void loadmod(void) {
	int (*lse_mod_test)(void) ;
	char * modname = cstring(0,0);
        lt_dlhandle modp;

        // Initialize libtool
        lt_dlinit(); 
        // Add local modules to search path
        lt_dladdsearchdir("./modules/");

#ifdef PKGLIBDIR
        // Add global modules to search path
        lt_dladdsearchdir(PKGLIBDIR);
#endif
        // try to load the module
        modp = lt_dlopenext(modname);

        // If we fail, set the flag to 0 and exit
	flag = 0;
	if ( ! modp ) return;

        // Else make sure the module is sane
	if ( !(lse_mod_test = (int (*)(void)) lt_dlsym(modp, "lse_mod_test")) ) return;
        // If all is well, then the test value 
        // should return 1, so se the flag to this and 
	flag = lse_mod_test();
}
Ejemplo n.º 12
0
/*
 * Load a module - this will load the shared object, call
 * C_Initialize, and get the list of function pointers
 */
void *
C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs)
{
	sc_pkcs11_module_t *mod;
	CK_RV rv, (*c_get_function_list)(CK_FUNCTION_LIST_PTR_PTR);
#ifdef HAVE_LTDL_H
	lt_dlinit();
#endif
	mod = calloc(1, sizeof(*mod));
	mod->_magic = MAGIC;

	if (mspec == NULL)
		return NULL;
	mod->handle = sc_dlopen(mspec);
	if (mod->handle == NULL) {
		fprintf(stderr, "sc_dlopen failed: %s\n", sc_dlerror());
		goto failed;
	}

	/* Get the list of function pointers */
	c_get_function_list = (CK_RV (*)(CK_FUNCTION_LIST_PTR_PTR))
				sc_dlsym(mod->handle, "C_GetFunctionList");
	if (!c_get_function_list)
		goto failed;
	rv = c_get_function_list(funcs);
	if (rv == CKR_OK)
		return (void *) mod;
	else
		fprintf(stderr, "C_GetFunctionList failed %lx", rv);
failed:
	C_UnloadModule((void *) mod);
	return NULL;
}
Ejemplo n.º 13
0
/*
 * Load a module - this will load the shared object, call
 * C_Initialize, and get the list of function pointers
 */
void *
C_LoadModule(const char *mspec, CK_FUNCTION_LIST_PTR_PTR funcs)
{
	sc_pkcs11_module_t *mod;
	CK_RV (*c_get_function_list)(CK_FUNCTION_LIST_PTR_PTR);
	int rv;

	lt_dlinit();

	mod = (sc_pkcs11_module_t *) calloc(1, sizeof(*mod));
	mod->_magic = MAGIC;

	if (mspec == NULL)
		mspec = PKCS11_DEFAULT_MODULE_NAME;
	mod->handle = lt_dlopen(mspec);
	if (mod->handle == NULL) {
#if 0
		fprintf(stderr, "lt_dlopen failed: %s\n", lt_dlerror());
#endif
		goto failed;
	}

	/* Get the list of function pointers */
	c_get_function_list = (CK_RV (*)(CK_FUNCTION_LIST_PTR_PTR))
				lt_dlsym(mod->handle, "C_GetFunctionList");
	if (!c_get_function_list)
		goto failed;
	rv = c_get_function_list(funcs);
	if (rv == CKR_OK)
		return (void *) mod;

failed:
	C_UnloadModule((void *) mod);
	return NULL;
}
Ejemplo n.º 14
0
/*
 * Read the directory and load all .so files
 */
vector<AbstractPlugin*> DlOpenPluginLoader::LoadPlugins() {
  AbstractPlugin *plugin = NULL;
  set<string>::iterator iter;
  set<string> plugin_names = FindPlugins(m_dirname);
  vector<AbstractPlugin*> plugins;

  if (!m_dl_active) {
    if (lt_dlinit()) {
      OLA_WARN << "lt_dlinit failed";
      return plugins;
    }
  }

  if (lt_dlsetsearchpath(m_dirname.c_str())) {
    OLA_WARN << "lt_setpath failed";
    lt_dlexit();
    return plugins;
  }
  m_dl_active = true;

  for (iter = plugin_names.begin(); iter != plugin_names.end(); ++iter) {
    string path = m_dirname;
    path.append("/");
    path.append(*iter);

    if ((plugin = this->LoadPlugin(path)))
      plugins.push_back(plugin);
    else
      OLA_WARN << "Failed to load plugin: " << path;
  }
  return plugins;
}
Ejemplo n.º 15
0
int
main (int argc, char* argv[])
{
  lt_dlhandle dlhand;
  char sym[300];
  char* drvnam = argv[1];
  char** info;

  /* Establish a handler for SIGSEGV signals. */
  signal (SIGSEGV, catch_segv);

  lt_dlinit ();
  dlhand = lt_dlopenext (drvnam);
  if (dlhand == NULL) {
    fprintf (stderr, "Could not open driver module %s\n"
                     "libltdl error: %s\n", drvnam, lt_dlerror ());
    return 1;
  }
  sprintf (sym, "plD_DEVICE_INFO_%s", drvnam);
  info = (char **) lt_dlsym (dlhand, sym);
  if (info != NULL) {
    printf ("%s", *info);
    return 0;
  }
  else {
    fprintf (stderr, "Could not read symbol %s in driver module %s\n"
                     "libltdl error: %s\n", sym, drvnam, lt_dlerror ());
    return 1;
  }
}
int oph_ioserver_setup(const char *server_type, oph_ioserver_handler **handle)
{
  if (!handle){
    pmesg(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_LOG_NULL_HANDLE);
  	logging_server(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_COMMON_LOG, OPH_IOSERVER_LOG_NULL_HANDLE);    
    return OPH_IOSERVER_NULL_HANDLE;
  }

  oph_ioserver_handler *internal_handle = (oph_ioserver_handler *)malloc(sizeof(oph_ioserver_handler));

  internal_handle->server_type = NULL;
  internal_handle->server_subtype = NULL;
  internal_handle->lib = NULL;
  internal_handle->dlh = NULL;

  //Set storage server type 
  if(oph_parse_server_name (server_type, &internal_handle->server_type, &internal_handle->server_subtype)){
  	pmesg(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_LOG_SERVER_PARSE_ERROR);
  	logging_server(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_COMMON_LOG, OPH_IOSERVER_LOG_SERVER_PARSE_ERROR);    
    return OPH_IOSERVER_INVALID_PARAM;
  }

  //If already executed don't procede further
  if (internal_handle->dlh)  
    return OPH_IOSERVER_SUCCESS;

  //LTDL_SET_PRELOADED_SYMBOLS();
  if(lt_dlinit () != 0)
  {
	  pmesg(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_LOG_DLINIT_ERROR, lt_dlerror());
  	logging_server(LOG_ERROR, __FILE__, __LINE__, internal_handle->server_type,  OPH_IOSERVER_LOG_DLINIT_ERROR, lt_dlerror());    
    return OPH_IOSERVER_DLOPEN_ERR;
  }

  if (oph_find_server_plugin (internal_handle->server_type, &internal_handle->lib)){
	  pmesg(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_LOG_LIB_NOT_FOUND);
  	logging_server(LOG_ERROR, __FILE__, __LINE__, internal_handle->server_type, OPH_IOSERVER_LOG_LIB_NOT_FOUND);    
    return OPH_IOSERVER_LIB_NOT_FOUND;
  }

  if (!(internal_handle->dlh = (lt_dlhandle) lt_dlopen (internal_handle->lib)))
  {
	  pmesg(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_LOG_DLOPEN_ERROR, lt_dlerror());
  	logging_server(LOG_ERROR, __FILE__, __LINE__, internal_handle->server_type,  OPH_IOSERVER_LOG_DLOPEN_ERROR, lt_dlerror());    
    return OPH_IOSERVER_DLOPEN_ERR;
  }

  char func_name[OPH_IOSERVER_BUFLEN] = {'\0'};
  snprintf(func_name, OPH_IOSERVER_BUFLEN, OPH_IOSERVER_SETUP_FUNC, internal_handle->server_type);

  if (!(_SERVER_setup = (int (*)(oph_ioserver_handler *)) lt_dlsym (internal_handle->dlh, func_name))){
	  pmesg(LOG_ERROR, __FILE__, __LINE__, OPH_IOSERVER_LOG_LOAD_FUNC_ERROR, lt_dlerror());
  	logging_server(LOG_ERROR, __FILE__, __LINE__, internal_handle->server_type,  OPH_IOSERVER_LOG_LOAD_FUNC_ERROR, lt_dlerror());   
    return OPH_IOSERVER_DLSYM_ERR;
  }

  *handle = internal_handle; 
  return _SERVER_setup (*handle);
}
Ejemplo n.º 17
0
void BOSS_Synthesis::initModules(const string & inv) {
  InvMap::iterator it;
  it = invmap.find(inv);
  if(it!=invmap.end()) {
    cerr << "Module order for inventory is already defined - skipping!"
	 << endl;
    return;
  }
  ifstream in;
  if (cl("-modules").optionarg != "") {
    in.open(cl("-modules").optionarg.c_str());
    if (!in) {
      cerr << "No (valid) module order file specified for inventory - exiting!"
	   << endl;
      exit(EXIT_FAILURE);
    }
  } else {
      cerr << "Empty \"modules\" parameter provided, exiting" << endl;
      exit(EXIT_FAILURE);
  }
  
  // Initialise the database connection
  try {
    cerr << "Initialising the database connection - " ;
    data_base = new MySQL_Handler(cl("-h").optionarg,cl("-u").optionarg,cl("-p").optionarg,cl("-db").optionarg);
    cerr << "OK" << endl;
  }
  catch (const MySQL_ConnectFailed & e) {
    e.printError(true);
    cerr << "Cannot establish database connection - exiting!"
	 << endl;
    in.close();
    exit(EXIT_FAILURE);
  }
  /* Initialise libltdl. */
  if (lt_dlinit()) {
    cerr << "BOSS_Synthesis: couldn't initialise libtool." << endl;
    in.close();
    delete data_base;
    exit(EXIT_FAILURE);
  }
  Scheduler s;
  string name;
  while(getline(in, name)) {
	cerr << "name = " << name << endl;
    if (name != "") {
      BOSS::Module * module = load(name);
      if (module != NULL) {
	cerr << module->getDescription() << endl; //NOTE: this line can be deleted, mho
	ModulePointer mp(name,module);
	s.push_back(mp);
      } else {
	      cerr << "got an error while loading the module " << name << endl;
      }
    }
  }
  invmap[inv]=pair<Scheduler, MySQL_Handler *>(s,data_base);
  in.close();
}
Ejemplo n.º 18
0
/* initialize module routines */
int neb_init_modules(void) {

	/* initialize library */
	if (lt_dlinit())
		return ERROR;

	return OK;
}
Ejemplo n.º 19
0
/*
 * (Try to) load the shared object `file'. Won't complain if it isn't a shared
 * object, but it will bitch about a shared object not having a
 * ``module_register'' symbol..
 */
static int plugin_load_file (char *file, uint32_t flags)
{
	lt_dlhandle dlh;
	void (*reg_handle) (void);

	lt_dlinit ();
	lt_dlerror (); /* clear errors */

#if LIBTOOL_VERSION == 2
	if (flags & PLUGIN_FLAGS_GLOBAL) {
		lt_dladvise advise;
		lt_dladvise_init(&advise);
		lt_dladvise_global(&advise);
		dlh = lt_dlopenadvise(file, advise);
		lt_dladvise_destroy(&advise);
	} else {
        	dlh = lt_dlopen (file);
	}
#else /* if LIBTOOL_VERSION == 1 */
	if (flags & PLUGIN_FLAGS_GLOBAL)
		WARNING ("plugin_load_file: The global flag is not supported, "
				"libtool 2 is required for this.");
	dlh = lt_dlopen (file);
#endif

	if (dlh == NULL)
	{
		char errbuf[1024] = "";

		ssnprintf (errbuf, sizeof (errbuf),
				"lt_dlopen (\"%s\") failed: %s. "
				"The most common cause for this problem are "
				"missing dependencies. Use ldd(1) to check "
				"the dependencies of the plugin "
				"/ shared object.",
				file, lt_dlerror ());

		ERROR ("%s", errbuf);
		/* Make sure this is printed to STDERR in any case, but also
		 * make sure it's printed only once. */
		if (list_log != NULL)
			fprintf (stderr, "ERROR: %s\n", errbuf);

		return (1);
	}

	if ((reg_handle = (void (*) (void)) lt_dlsym (dlh, "module_register")) == NULL)
	{
		WARNING ("Couldn't find symbol \"module_register\" in \"%s\": %s\n",
				file, lt_dlerror ());
		lt_dlclose (dlh);
		return (-1);
	}

	(*reg_handle) ();

	return (0);
}
Ejemplo n.º 20
0
/**
 * Module activation
 * @ingroup globus_callout_activation
 */
static
int
globus_l_callout_activate(void)
{
    int                                 result = (int) GLOBUS_SUCCESS;
    char *                              tmp_string;
    static char *                       _function_name_ =
        "globus_l_callout_activate";

    tmp_string = globus_module_getenv("GLOBUS_CALLOUT_DEBUG_LEVEL");
    if(tmp_string != GLOBUS_NULL)
    {
        globus_i_callout_debug_level = atoi(tmp_string);
        
        if(globus_i_callout_debug_level < 0)
        {
            globus_i_callout_debug_level = 0;
        }
    }

    tmp_string = globus_module_getenv("GLOBUS_CALLOUT_DEBUG_FILE");
    if(tmp_string != GLOBUS_NULL)
    {
        globus_i_callout_debug_fstream = fopen(tmp_string, "a");
        if(globus_i_callout_debug_fstream == NULL)
        {
            result = (int) GLOBUS_FAILURE;
            goto exit;
        }
    }
    else
    {
        globus_i_callout_debug_fstream = stderr;
    }

    GLOBUS_I_CALLOUT_DEBUG_ENTER;

    result = globus_module_activate(GLOBUS_COMMON_MODULE);

    if(result != GLOBUS_SUCCESS)
    {
        goto exit;
    }

#ifndef BUILD_STATIC_ONLY
    if((result = lt_dlinit()) != 0)
    {
        goto exit;
    }
#endif

    GLOBUS_I_CALLOUT_DEBUG_EXIT;

 exit:

    return result;
}
Ejemplo n.º 21
0
static int dso_init(void) {
#ifdef PR_USE_CTRLS
  register unsigned int i = 0;
#endif /* PR_USE_CTRLS */

  /* Allocate the pool for this module's use. */
  dso_pool = make_sub_pool(permanent_pool);
  pr_pool_tag(dso_pool, MOD_DSO_VERSION);

  lt_dlpreload_default(lt_preloaded_symbols);

  /* Initialize libltdl. */
  if (lt_dlinit() < 0) {
    pr_log_pri(PR_LOG_ERR, MOD_DSO_VERSION ": error initializing libltdl: %s",
      lt_dlerror());
    return -1;
  }

  /* Explicitly set the search path used for opening modules. */
  if (lt_dlsetsearchpath(dso_module_path) < 0) {
    pr_log_pri(PR_LOG_ERR, MOD_DSO_VERSION ": error setting module path: %s",
      lt_dlerror());
    return -1;
  }

#ifdef PR_USE_CTRLS
  /* Register ctrls handlers. */
  for (i = 0; dso_acttab[i].act_action; i++) {
    pool *sub_pool = make_sub_pool(dso_pool);

    /* Allocate and initialize the ACL for this control. */
    dso_acttab[i].act_acl = pcalloc(sub_pool, sizeof(ctrls_acl_t));
    dso_acttab[i].act_acl->acl_pool = sub_pool;
    pr_ctrls_init_acl(dso_acttab[i].act_acl);

    if (pr_ctrls_register(&dso_module, dso_acttab[i].act_action,
        dso_acttab[i].act_desc, dso_acttab[i].act_cb) < 0)
      pr_log_pri(PR_LOG_INFO, MOD_DSO_VERSION
        ": error registering '%s' control: %s", dso_acttab[i].act_action,
        strerror(errno));
  }
#endif /* PR_USE_CTRLS */

  /* Ideally, we'd call register a listener for the 'core.exit' event
   * and call lt_dlexit() there, politely freeing up any resources allocated
   * by the ltdl library.  However, it's possible that other modules, later in
   * the dispatch cycles, may need to use pointers to memory in shared modules
   * that would become invalid by such finalization.  So we skip it, for now.
   *
   * If there was a way to schedule this handler, to happen after all other
   * exit handlers, that'd be best.
   */
  pr_event_register(&dso_module, "core.restart", dso_restart_ev, NULL);

  return 0;
}
Ejemplo n.º 22
0
/* return 0 on error */
int nutscan_load_upsclient_library()
{

        if( dl_handle != NULL ) {
                /* if previous init failed */
                if( dl_handle == (void *)1 ) {
                        return 0;
                }
                /* init has already been done */
                return 1;
        }

        if( lt_dlinit() != 0 ) {
                fprintf(stderr, "Error initializing lt_init\n");
                return 0;
        }

        dl_handle = lt_dlopenext(libname);
        if (!dl_handle) {
                dl_error = lt_dlerror();
                goto err;
        }

        lt_dlerror();      /* Clear any existing error */

        *(void **) (&nut_upscli_splitaddr) = lt_dlsym(dl_handle,
                                                        "upscli_splitaddr");
        if ((dl_error = lt_dlerror()) != NULL)  {
                goto err;
        }

        *(void **) (&nut_upscli_tryconnect) = lt_dlsym(dl_handle,
							"upscli_tryconnect");
        if ((dl_error = lt_dlerror()) != NULL)  {
                goto err;
        }

        *(void **) (&nut_upscli_list_start) = lt_dlsym(dl_handle,
							"upscli_list_start");
        if ((dl_error = lt_dlerror()) != NULL)  {
                goto err;
        }

        *(void **) (&nut_upscli_list_next) = lt_dlsym(dl_handle,
							"upscli_list_next");
        if ((dl_error = lt_dlerror()) != NULL)  {
                goto err;
        }

        return 1;
err:
        fprintf(stderr, "Cannot load NUT library (%s) : %s. NUT search disabled.\n", libname, dl_error);
        dl_handle = (void *)1;
	lt_dlexit();
        return 0;
}
Ejemplo n.º 23
0
/*
 * The libtool dynamic loading library must be initialized before any calls
 * are made to library routines.  Initialize only once.
 */
static void check_lt_initialized(void)
{
  static int initialized = FALSE;
  if (!initialized) {
#if defined(PIC) || !defined(SIDL_PURE_STATIC_RUNTIME)
    (void) lt_dlinit();
#endif /* defined(PIC) || !defined(SIDL_PURE_STATIC_RUNTIME) */
    initialized = TRUE;
  }
}
Ejemplo n.º 24
0
exception_t init_module_list(){
	int errors = 0;
	//skyeye_modules = skyeye_mm(sizeof(skyeye_modules_t));
	skyeye_modules = NULL;
	/* Initialise libltdl. */
	errors = lt_dlinit ();

	if(skyeye_modules == NULL)
		return Malloc_exp;
	return No_exp;
}
Ejemplo n.º 25
0
int main( int argc, char *argv[] )
{
  void * dummy;

  lt_dlinit();
  dummy= lt_dlopen("dummy.so");

  if (dummy) lt_dlclose(dummy);

  return(0);
}
Ejemplo n.º 26
0
void moduleloader_init(const char* searchpath){
	lt_dlinit();

	char* path_list = strdup(searchpath);
	char* path = strtok(path_list, ":");
	while ( path ){
		lt_dladdsearchdir(path);
		path = strtok(NULL, ":");
	}
	free(path_list);
}
Ejemplo n.º 27
0
/* pub funs */
fixc_eng_t
fixc_open_eng(const char *file)
{
	static int mod_initted_p = 0;
	fixc_eng_t res;
	fixc_eng_f fun;

	/* speed-dating singleton */
	if (!mod_initted_p) {
		/* initialise the dl system */
		lt_dlinit();
		/* add moddir to search path */
		add_myself();
		/* and just so we are a proper singleton */
		mod_initted_p = 1;
	}
	if (UNLIKELY((res = my_dlopen(file)) == NULL)) {
		return NULL;
	}
	if ((fun = eng_sym(res, "fixc_get_cid")) != NULL) {
		__get_cid = (fixc_comp_t(*)())fun;
	}
	if ((fun = eng_sym(res, "fixc_get_aid")) != NULL) {
		__get_aid = (fixc_attr_t(*)())fun;
	}
	if ((fun = eng_sym(res, "fixc_get_mty")) != NULL) {
		__get_mty = (fixc_msgt_t(*)())fun;
	}

	if ((fun = eng_sym(res, "fixc_msgt_fixmlify")) != NULL) {
		__msgt_fixmlify = (const char*(*)())fun;
	}
	if ((fun = eng_sym(res, "fixc_comp_fixmlify")) != NULL) {
		__comp_fixmlify = (const char*(*)())fun;
	}
	if ((fun = eng_sym(res, "fixc_attr_fixmlify")) != NULL) {
		__attr_fixmlify = (const char*(*)())fun;
	}

	if ((fun = eng_sym(res, "fixc_comp_rptb")) != NULL) {
		__comp_rptb = (fixc_attr_t(*)())fun;
	}
	if ((fun = eng_sym(res, "fixc_get_comp_orb")) != NULL) {
		__get_comp_orb = (fixc_comp_t(*)())fun;
	}
	if ((fun = eng_sym(res, "fixc_get_comp_sub")) != NULL) {
		__get_comp_sub = (fixc_comp_sub_t(*)())fun;
	}
	if ((fun = eng_sym(res, "fixc_get_fld_ctx")) != NULL) {
		__get_fld_ctx = (fixc_fld_ctx_t(*)())fun;
	}
	return res;
}
Ejemplo n.º 28
0
int nv_plugins_init() {
	int ret = 0;

	/* init the plugin system */
	LTDL_SET_PRELOADED_SYMBOLS();
	ret = lt_dlinit();
	if (ret) {
		nv_log(NVLOG_ERROR, "lt_dlinit(): %s", lt_dlerror());
		return -1;
	}
	return ret;
}
Ejemplo n.º 29
0
KLibLoader::KLibLoader( QObject* parent, const char* name )
    : QObject( parent, name )
{
    s_self = this;
    d = new KLibLoaderPrivate;
    lt_dlinit();
    d->unload_mode = KLibLoaderPrivate::UNKNOWN;
    if (getenv("KDE_NOUNLOAD") != 0)
        d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD;
    else if (getenv("KDE_DOUNLOAD") != 0)
        d->unload_mode = KLibLoaderPrivate::UNLOAD;
    d->loaded_stack.setAutoDelete( true );
}
Ejemplo n.º 30
0
    /**
        Initializes the dynamic module facility.
        Applications that use this library must call this function
        prior to any operation involved with the facility.
        @return true on error, false otherwise.
     */
    static bool initialize()
    {
        if ( lt_dlinit() > 0 )
            return true;

        if ( lt_dlsetsearchpath("") > 0 )
        {
            lt_dlexit();
            return true;
        }

        return false;
    }