Bool lecode_tools_Init( int* argc, char** argv[] ) { /* This init function tells StGermain of all the component types, etc this module contributes. Because it can be linked at compile time or linked in by a toolbox at runtime, we need to make sure it isn't run twice (compiled in and loaded through a toolbox.*/ if( !ToolboxesManager_IsInitialised( stgToolboxesManager, "lecode_tools" ) ) { int tmp; char* directory; lecode_tools_Base_Init(argc, argv); Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */ tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), 0 ); Journal_Printf( /* DO NOT CHANGE OR REMOVE */ Journal_Register( InfoStream_Type, (Name)"Context" ), "lecode_tools. Copyright (C) 2012 Monash University.\n" ); Stream_Flush( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), tmp ); /* Add the lecode_tools path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf(directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "lecode_tools", directory ); Memory_Free(directory); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "lecode_tools", LIB_DIR ); return True; }
Bool StGermainBase_Init( int* argc, char** argv[] ) { char* directory; int tmp; /* Initialise enough bits and pieces to get IO going */ BaseFoundation_Init( argc, argv ); BaseIO_Init( argc, argv ); /* Write out the copyright message */ Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), 0 ); Stream_Flush( Journal_Register( InfoStream_Type, "Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, "Context" ), tmp ); /* Initialise the remaining bits and pieces */ BaseContainer_Init( argc, argv ); BaseAutomation_Init( argc, argv ); BaseExtensibility_Init( argc, argv ); BaseContext_Init( argc, argv ); /* Add the StGermain path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf( directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "StGermain", directory ); Memory_Free( directory ); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "StGermain", LIB_DIR ); return True; }
Bool Geothermal_Init( int* argc, char** argv[] ) { /* * This init function tells StGermain of all the component types, etc this module contributes. * Because it can be linked at compile time or linked in by a toolbox at runtime, we need to make * sure it isn't run twice (compiled in and loaded through a toolbox. */ if( !ToolboxesManager_IsInitialised( stgToolboxesManager, "Geothermal" ) ) { int tmp; char* directory; Geothermal_Base_Init(argc, argv); /* DO NOT CHANGE OR REMOVE */ Journal_Printf( Journal_Register( DebugStream_Type, (Name)"Context" ), "In: %s\n", __func__ ); tmp = Stream_GetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), 0 ); /* DO NOT CHANGE OR REMOVE */ Journal_Printf( Journal_Register( InfoStream_Type, (Name)"Context" ), "Geothermal (Bleeding Edge Geodynamics framework) Revision %s. Copyright (C) 2005 Monash University.\n", VERSION ); /* Add repo indentity info in the repo dictionary. */ Dictionary_Add( versionDict, "Geothermal", Dictionary_Entry_Value_FromString( VERSION ) ); Dictionary_Add( branchDict, "Geothermal", Dictionary_Entry_Value_FromString( BRANCH ) ); Dictionary_Add( pathDict, "Geothermal", Dictionary_Entry_Value_FromString( PATH ) ); Stream_Flush( Journal_Register( InfoStream_Type, (Name)"Context" ) ); Stream_SetPrintingRank( Journal_Register( InfoStream_Type, (Name)"Context" ), tmp ); /* Add the Geothermal path to the global xml path dictionary */ directory = Memory_Alloc_Array( char, 200, "xmlDirectory" ) ; sprintf(directory, "%s%s", LIB_DIR, "/StGermain" ); XML_IO_Handler_AddDirectory( "Geothermal", directory ); Memory_Free(directory); /* Add the plugin path to the global plugin list */ ModulesManager_AddDirectory( "Geothermal", LIB_DIR ); return True; }
void ModulesManager_Load( void* modulesManager, void* _dictionary, Name contextName ) { ModulesManager* self = (ModulesManager*)modulesManager; Dictionary* dictionary = (Dictionary*)_dictionary; unsigned int entryCount; unsigned int entry_I; Dictionary_Entry_Value* modulesVal; /* * First add the directory list onto LD_LIBRARY_PATH so that it can potentially * resolve the unknown symbols */ #ifndef NOSHARED char* curEnvPath; char* newEnvPath; Index newEnvPathLength; Index dir_I; Index i, count; char* dir; newEnvPathLength = 0; if( dictionary ) { Dictionary_Entry_Value* localLibDirList = Dictionary_Get( dictionary, "LD_LIBRARY_PATH" ); if( localLibDirList ) { count = Dictionary_Entry_Value_GetCount( localLibDirList ); for( i = 0; i < count; ++i ) { dir = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( localLibDirList, i ) ); ModulesManager_AddDirectory( "FromDictionary", dir ); } } } for( dir_I = 0; dir_I < moduleDirectories->count; ++dir_I ) { newEnvPathLength += strlen( (char*)Stg_ObjectList_ObjectAt( moduleDirectories, dir_I ) ); /* Add one make space for the ':' inbetween the directories */ newEnvPathLength += 1; } curEnvPath = getenv("LD_LIBRARY_PATH"); if( curEnvPath ) { newEnvPathLength += strlen( curEnvPath ); } if( newEnvPathLength > 0 ) { /* Add one to make space for the Null Terminator '\0' */ newEnvPathLength += 1; newEnvPath = Memory_Alloc_Array( char, newEnvPathLength, "LD_LIBRARY_PATH" ); newEnvPath[0] = '\0'; for( dir_I = 0; dir_I < moduleDirectories->count; ++dir_I ) { strcat( newEnvPath, (char*)Stg_ObjectList_ObjectAt( moduleDirectories, dir_I ) ); strcat( newEnvPath, ":" ); } if( curEnvPath ) { strcat( newEnvPath, curEnvPath ); } setenv( "LD_LIBRARY_PATH", newEnvPath, 1 ); Journal_Printf( Journal_Register( Debug_Type, self->type ), "Using LD_LIBRARY_PATH=%s\n", newEnvPath ); Memory_Free( newEnvPath ); }