Commit bdc46e27 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Inline module_Call()

parent ae5e3537
......@@ -1059,21 +1059,35 @@ static module_t * AllocatePlugin( vlc_object_t * p_this, const char *psz_file )
p_module->b_loaded = true;
/* Initialize the module: fill p_module, default config */
if( module_Call( p_this, p_module ) != 0 )
static const char entry[] = "vlc_entry" MODULE_SUFFIX;
/* Try to resolve the symbol */
int (*pf_symbol)(module_t * p_module)
= (int (*)(module_t *)) module_Lookup( p_module->handle,entry );
if( pf_symbol == NULL )
{
/* We couldn't call module_init() */
free( p_module->psz_filename );
module_release( p_module );
module_Unload( handle );
return NULL;
msg_Warn( p_this, "cannot find symbol \"%s\" in plugin `%s'",
entry, psz_file );
goto error;
}
else
/* We can now try to call the symbol */
if( pf_symbol( p_module ) != 0 )
{
/* With a well-written module we shouldn't have to print an
* additional error message here, but just make sure. */
msg_Err( p_this, "cannot initialize plugin `%s'", psz_file );
goto error;
}
DupModule( p_module );
/* Everything worked fine ! The module is ready to be added to the list. */
p_module->b_builtin = false;
assert( !p_module->b_builtin );
return p_module;
error:
free( p_module->psz_filename );
module_release( p_module );
module_Unload( handle );
return NULL;
}
/*****************************************************************************
......
......@@ -143,8 +143,8 @@ void module_EndBank( vlc_object_t *, bool );
int vlc_bindtextdomain (const char *);
/* Low-level OS-dependent handler */
int module_Load (vlc_object_t *, const char *, module_handle_t *);
int module_Call (vlc_object_t *obj, module_t *);
int module_Load (vlc_object_t *, const char *, module_handle_t *);
void *module_Lookup (module_handle_t, const char *);
void module_Unload (module_handle_t);
/* Plugins cache */
......
......@@ -66,62 +66,10 @@
* Local prototypes
*****************************************************************************/
#ifdef HAVE_DYNAMIC_PLUGINS
static void *module_Lookup( module_handle_t, const char * );
#if defined(HAVE_DL_WINDOWS)
static char * GetWindowsError ( void );
#endif
/**
* module Call
*
* Call a symbol given its name and a module structure. The symbol MUST
* refer to a function returning int and taking a module_t* as an argument.
* \param p_module the modules
* \return 0 if it pass and -1 in case of a failure
*/
int module_Call( vlc_object_t *obj, module_t *p_module )
{
static const char psz_name[] = "vlc_entry" MODULE_SUFFIX;
int (* pf_symbol) ( module_t * p_module );
/* Try to resolve the symbol */
pf_symbol = (int (*)(module_t *)) module_Lookup( p_module->handle,
psz_name );
if( pf_symbol == NULL )
{
#if defined(HAVE_DL_WINDOWS)
char *psz_error = GetWindowsError();
msg_Warn( obj, "cannot find symbol \"%s\" in file `%s' (%s)",
psz_name, p_module->psz_filename, psz_error );
free( psz_error );
#elif defined(HAVE_DL_DLOPEN)
msg_Warn( obj, "cannot find symbol \"%s\" in file `%s' (%s)",
psz_name, p_module->psz_filename, dlerror() );
#elif defined(HAVE_DL_SHL_LOAD)
msg_Warn( obj, "cannot find symbol \"%s\" in file `%s' (%m)",
psz_name, p_module->psz_filename );
#else
# error "Something is wrong in modules.c"
#endif
return -1;
}
/* We can now try to call the symbol */
if( pf_symbol( p_module ) != 0 )
{
/* With a well-written module we shouldn't have to print an
* additional error message here, but just make sure. */
msg_Err( obj, "Failed to call symbol \"%s\" in file `%s'",
psz_name, p_module->psz_filename );
return -1;
}
/* Everything worked fine, we can return */
return 0;
}
/**
* Load a dynamically linked library using a system dependent method.
*
......@@ -235,7 +183,7 @@ void module_Unload( module_handle_t handle )
* @param psz_function function name
* @return NULL on error, or the address of the symbol
*/
static void *module_Lookup( module_handle_t handle, const char *psz_function )
void *module_Lookup( module_handle_t handle, const char *psz_function )
{
#if defined(HAVE_DL_WINDOWS) && defined(UNDER_CE)
wchar_t wide[strlen( psz_function ) + 1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment