int Module_LoadMem(void *Buffer, Uint Length, char *ArgString);
int Module_LoadFile(char *Path, char *ArgString);
int Module_int_ResolveDeps(tModule *Info);
- int Module_IsLoaded(char *Name);
+ int Module_IsLoaded(const char *Name);
// === EXPORTS ===
EXPORT(Module_RegisterLoader);
/**
* \brief Initialises a module
* \param Module Pointer to the module header
+ * \param ArgString Comma separated list of module arguments
* \return Zero on success, eModuleErrors or -1 on error
* \retval -1 Returned if a dependency fails, or a circular dependency
* exists.
free(gasBuiltinModuleArgs);
}
+/**
+ * \brief Initialise a builtin module given it's name
+ * \example Used by VTerm to load an alternate video driver at runtime
+ */
+int Modules_InitialiseBuiltin(const char *Name)
+{
+ int i;
+
+ // Check if it's loaded
+ if( Module_IsLoaded(Name) )
+ return 0;
+
+ if( !gapBuiltinModules )
+ Modules_int_GetBuiltinArray();
+
+ for( i = 0; i < giNumBuiltinModules; i++ )
+ {
+ if( strcmp(gapBuiltinModules[i]->Name, Name) == 0 ) {
+ return Module_int_Initialise(gapBuiltinModules[i],
+ (gasBuiltinModuleArgs ? gasBuiltinModuleArgs[i] : NULL)
+ );
+ }
+ }
+ return -1;
+}
+
/**
* \brief Sets the parameters for a builtin module
*/
return 0;
}
- #if 1
+ // Initialise (and register)
if( Module_int_Initialise( info, ArgString ) )
{
Binary_Unload(base);
return 0;
}
- #else
- // Resolve Dependencies
- if( !Module_int_ResolveDeps(info) ) {
- Binary_Unload(base);
- return 0;
- }
-
- Log_Log("Module", "Initialising %p '%s' v%i.%i...",
- info,
- info->Name,
- info->Version>>8, info->Version & 0xFF
- );
-
- // Call Initialiser
- //if( info->Init( ArgString ) != 0 )
- if( info->Init( NULL ) == 0 )
- {
- Binary_Unload(base);
- return 0;
- }
-
- // Add to list
- LOCK( &glModuleSpinlock );
- info->Next = gLoadedModules;
- gLoadedModules = info;
- RELEASE( &glModuleSpinlock );
- #endif
return 1;
}
}
/**
- * \fn int Module_IsLoaded(char *Name)
+ * \fn int Module_IsLoaded(const char *Name)
* \brief Checks if a module is loaded
* \param Name Name of module to find
*/
-int Module_IsLoaded(char *Name)
+int Module_IsLoaded(const char *Name)
{
tModule *mod = gLoadedModules;