5typedef MERROR_RETVAL (*mplug_proc_t)(
void* data,
size_t data_sz );
10typedef HMODULE mplug_mod_t;
11# define MPLUG_EXPORT extern __declspec( dllexport )
13typedef void* mplug_mod_t;
18 const char* plugin_path, mplug_mod_t* p_mod_exe );
21 mplug_mod_t mod_exe,
const char* proc_name,
void* data,
size_t data_sz );
23void mplug_free( mplug_mod_t mod_exe );
27#if defined( RETROFLAT_OS_UNIX )
32 const char* plugin_basename, mplug_mod_t* p_mod_exe
36#ifdef RETROFLAT_OS_WIN
45#if defined( RETROFLAT_OS_UNIX )
47 *p_mod_exe = dlopen( plugin_path, RTLD_LAZY );
48#elif defined( RETROFLAT_OS_WIN )
52 if(
'/' == plugin_path[i] ) {
53 plugin_path[i] =
'\\';
57 if( 0 == MultiByteToWideChar(
58 CP_ACP, MB_PRECOMPOSED, plugin_path, -1,
62 "unable to convert wide path for module: %s", plugin_path );
67 *p_mod_exe = (mplug_mod_t)LoadLibraryW( plugin_path_w );
69 *p_mod_exe = (mplug_mod_t)LoadLibrary( plugin_path );
75 if( NULL != plugin_path_w ) {
76 free( plugin_path_w );
80# pragma message( "warning: dlopen undefined!" )
83 if( (mplug_mod_t)NULL == *p_mod_exe ) {
84 error_printf(
"unable to load module: %s", plugin_path );
92 mplug_mod_t mod_exe,
const char* proc_name,
void* data,
size_t data_sz
95 mplug_proc_t plugin_proc = (mplug_proc_t)NULL;
96#ifdef RETROFLAT_OS_WIN
103#ifdef RETROFLAT_OS_UNIX
104 plugin_proc = dlsym( mod_exe, proc_name );
105#elif defined( RETROFLAT_OS_WIN )
111# if defined( MAUG_WCHAR ) && defined( RETROFLAT_API_WINCE )
112 if( 0 == MultiByteToWideChar(
113 CP_ACP, MB_PRECOMPOSED, proc_name_ex, -1, proc_name_ex_w,
116 error_printf(
"could not create wide proc name!" );
117 retval = MERROR_FILE;
121 plugin_proc = (mplug_proc_t)GetProcAddressW( mod_exe, proc_name_ex_w );
123 plugin_proc = (mplug_proc_t)GetProcAddress( mod_exe, proc_name_ex );
126# pragma message( "dlsym undefined!" )
129 if( (mplug_proc_t)NULL == plugin_proc ) {
130 error_printf(
"unable to load proc: %s", proc_name );
131 retval = MERROR_FILE;
135 retval = plugin_proc( data, data_sz );
141void mplug_free( mplug_mod_t mod_exe ) {
142#ifdef RETROFLAT_OS_UNIX
144#elif defined( RETROFLAT_OS_WIN )
145 FreeLibrary( mod_exe );
147# pragma message( "dlclose undefined!" )
uint16_t MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition: merror.h:28
#define MAUG_PATH_SZ_MAX
Maximum size allocated for asset paths.
Definition: mfile.h:35