Ejemplo n.º 1
0
/*
	callInitializersIn:
	Call the required initializers in the given module.
	The module has been loaded before so the task is to
	call a) setInterpreter() and check it's return, and
	b) initialiseModule (if defined) and check it's return
	as well.
*/
static sqInt callInitializersIn(ModuleEntry *module)
{
	void *init0;
	void *init1;
	void *init2;
	char *moduleName;
	sqInt okay;

	init0 = findFunctionIn("getModuleName", module);
	init1 = findFunctionIn("setInterpreter", module);
	init2 = findFunctionIn("initialiseModule", module);

	if(init0) {
		/* Check the compiled name of the module */
		moduleName = ((char* (*) (void))init0)();
		if(!moduleName) {
			DPRINTF(("ERROR: getModuleName() returned NULL\n"));
			return 0;
		}
		if(strncmp(moduleName, module->name, strlen(module->name)) != 0) {
			DPRINTF(("ERROR: getModuleName returned %s (expected: %s)\n", moduleName, module->name));
			return 0;
		}
	} else {
		/* Note: older plugins may not export the compiled module name */
		DPRINTF(("WARNING: getModuleName() not found in %s\n", module->name));
	}
	if(!init1) { 
		DPRINTF(("ERROR: setInterpreter() not found\n"));
		return 0;
	}
	/* call setInterpreter */
	okay = ((sqInt (*) (struct VirtualMachine*))init1)(sqGetInterpreterProxy());
	if(!okay) {
		DPRINTF(("ERROR: setInterpreter() returned false\n"));
		return 0;
	}
	if(init2) {
		okay = ((sqInt (*) (void)) init2)();
		if(!okay) {
			DPRINTF(("ERROR: initialiseModule() returned false\n"));
			return 0;
		}
	}
	DPRINTF(("SUCCESS: Module %s is now initialized\n", module->name));
	return 1;
}
Ejemplo n.º 2
0
void initip() {
interpreterProxy = sqGetInterpreterProxy();
}