コード例 #1
0
ファイル: vgui_draw.c プロジェクト: adamixik/xash3d
/*
================
VGui_Startup

Load vgui_support library and call VGui_Startup
================
*/
void VGui_Startup( int width, int height )
{
	if(!vgui.initialized)
	{
		void (*F) (vguiapi_t *);
		lib = Com_LoadLibrary(host.vguiloader, false);
		if(!lib)
			MsgDev(D_ERROR, "Failed to load vgui_support library!\n");
		else
		{
			F = Com_GetProcAddress(lib, "InitAPI");
			if(F)
			{
				F(&vgui);
				vgui.initialized = true;
			}
			else
				MsgDev(D_ERROR, "Failed to find vgui_support library entry point!\n");
		}
		VGUI_InitCursors();
	}
	if (vgui.initialized)
	{
		//host.mouse_visible = true;
		vgui.Startup(width, height);
	}
}
コード例 #2
0
ファイル: ascript.c プロジェクト: Racenet/racesow
/*
* Com_LoadScriptLibrary
*/
static void *Com_LoadScriptLibrary( const char *basename, void *parms )
{
	size_t file_size;
	char *file;
	void *( *GetAngelwrapAPI )(void *);
	dllfunc_t funcs[2];

	if( script_library )
		Com_Error( ERR_FATAL, "Com_LoadScriptLibrary without Com_UnloadScriptLibrary" );

	file_size = strlen( LIB_DIRECTORY "/" ) + strlen( basename ) + 1 + strlen( ARCH ) + strlen( LIB_SUFFIX ) + 1;
	file = Mem_TempMalloc( file_size );
	Q_snprintfz( file, file_size, LIB_DIRECTORY "/%s_" ARCH LIB_SUFFIX, basename );

	funcs[0].name = "GetAngelwrapAPI";
	funcs[0].funcPointer = ( void ** )&GetAngelwrapAPI;
	funcs[1].name = NULL;
	script_library = Com_LoadLibrary( file, funcs );

	Mem_TempFree( file );

	if( script_library )
		return GetAngelwrapAPI( parms );
	return NULL;
}
コード例 #3
0
ファイル: cl_sound.c プロジェクト: ultimatecode7/qfusion
/*
* CL_SoundModule_Load
* 
* Helper function to try loading sound module with certain name
*/
static bool CL_SoundModule_Load( const char *name, sound_import_t *import, bool verbose )
{
	int apiversion;
	size_t file_size;
	char *file;
	void *( *GetSoundAPI )(void *);
	dllfunc_t funcs[2];

	if( verbose )
		Com_Printf( "Loading sound module: %s\n", name );

	file_size = strlen( LIB_DIRECTORY "/" LIB_PREFIX "snd_" ) + strlen( name ) + 1 + strlen( ARCH ) + strlen( LIB_SUFFIX ) + 1;
	file = Mem_TempMalloc( file_size );
	Q_snprintfz( file, file_size, LIB_DIRECTORY "/" LIB_PREFIX "snd_%s_" ARCH LIB_SUFFIX, name );

	funcs[0].name = "GetSoundAPI";
	funcs[0].funcPointer = ( void ** )&GetSoundAPI;
	funcs[1].name = NULL;
	sound_library = Com_LoadLibrary( file, funcs );

	Mem_TempFree( file );

	if( !sound_library )
	{
		Com_Printf( "Loading %s failed\n", name );
		return false;
	}

	s_loaded = true;

	se = ( sound_export_t * )GetSoundAPI( import );
	apiversion = se->API();
	if( apiversion != SOUND_API_VERSION )
	{
		CL_SoundModule_Shutdown( verbose );
		Com_Printf( "Wrong module version for %s: %i, not %i\n", name, apiversion, SOUND_API_VERSION );
		return false;
	}

	if( !se->Init( VID_GetWindowHandle(), MAX_EDICTS, verbose ) )
	{
		CL_SoundModule_Shutdown( verbose );
		Com_Printf( "Initialization of %s failed\n", name );
		return false;
	}

	if( verbose )
		Com_Printf( "Initialization of %s succesful\n", name );

	return true;
}
コード例 #4
0
ファイル: anticheat.c プロジェクト: Kaperstone/warsow
/*
* AC_LoadLibrary
*/
qboolean AC_LoadLibrary( void *imports, void *exports, unsigned int flags )
{
	static ac_import_t import;
	dllfunc_t funcs[3];
	qboolean found = qfalse;
	qboolean verbose = qfalse;

	AC_InitImportStruct( import );

	// load dynamic library if it's not already loaded...
	if( !ac_libhandle )
	{
		if( verbose )
			Com_Printf( "Loading AC module... " );

		funcs[0].name = "InitServer";
		funcs[0].funcPointer = (void **) &InitServer_f;
		funcs[1].name = "InitClient";
		funcs[1].funcPointer = (void **) &InitClient_f;
		funcs[2].name = NULL;
		ac_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/ac_" ARCH LIB_SUFFIX, funcs );
	}

	// load succeeded or already loaded and exported functions retrieved
	if( ac_libhandle && InitServer_f && InitClient_f )
	{
		switch ( flags )
		{
		case ANTICHEAT_SERVER:
			InitServer_f( &import );
			found = qtrue;
			break;

		case ANTICHEAT_CLIENT:
			InitClient_f( &import );
			found = qtrue;
			break;

		default:
			break;
		}
	}

	if( verbose )
		Com_Printf( "%s.\n", found ? "Done" : "Not found" );

	return found;
}
コード例 #5
0
ファイル: steam.c プロジェクト: Picmip/qfusion
/*
* Steam_LoadLibrary
*/
void Steam_LoadLibrary( void ) {
	static steamlib_import_t import;
	dllfunc_t funcs[2];
	void *( *GetSteamLibAPI )( void * );

	assert( !steamlib_libhandle );

	import.Com_Error = (com_error_t)Com_Error;
	import.Com_Printf = Com_Printf;
	import.Com_DPrintf = Com_DPrintf;
	import.Cbuf_ExecuteText = Cbuf_ExecuteText;

	// load dynamic library
	Com_Printf( "Loading Steam module... " );
	funcs[0].name = "GetSteamLibAPI";
	funcs[0].funcPointer = (void **) &GetSteamLibAPI;
	funcs[1].name = NULL;
	steamlib_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/" LIB_PREFIX "steamlib" LIB_SUFFIX, funcs );

	if( steamlib_libhandle ) {
		// load succeeded
		int api_version;

		steamlib_export = GetSteamLibAPI( &import );
		api_version = steamlib_export->API();

		if( api_version != STEAMLIB_API_VERSION ) {
			// wrong version
			Com_Printf( "Wrong version: %i, not %i.\n", api_version, STEAMLIB_API_VERSION );
			Steam_UnloadLibrary();
		} else {
			Com_Printf( "Success.\n" );
		}
	} else {
		Com_Printf( "Not found.\n" );
	}
}
コード例 #6
0
ファイル: irc.c プロジェクト: Clever-Boy/qfusion
static void Irc_LoadLibrary( void )
{
	static irc_import_t import;
	dllfunc_t funcs[2];
	GetIrcAPI_t GetIrcAPI_f;

	assert( !irc_libhandle );

	import.Printf = Irc_Print;
	import.CL_GetKeyDest = CL_GetKeyDest;
	import.CL_GetClientState = CL_GetClientState;
	import.Key_DelegatePush = Key_DelegatePush;
	import.Key_DelegatePop = Key_DelegatePop;
	import.SCR_RegisterFont = SCR_RegisterFont;
	import.SCR_DrawString = SCR_DrawString;
	import.SCR_DrawStringWidth = SCR_DrawStringWidth;
	import.SCR_DrawRawChar = SCR_DrawRawChar;
	import.SCR_strHeight = SCR_FontHeight;
	import.SCR_strWidth = SCR_strWidth;
	import.SCR_StrlenForWidth = SCR_StrlenForWidth;
	import.SCR_GetScreenWidth = SCR_GetScreenWidth;
	import.SCR_GetScreenHeight = SCR_GetScreenHeight;
	import.R_RegisterPic = SCR_RegisterPic;
	import.R_DrawStretchPic = SCR_DrawStretchPic;
	import.Sys_Milliseconds = Sys_Milliseconds;
	import.Sys_Microseconds = Sys_Microseconds;
	import.Mem_AllocPool = Irc_MemAllocPool;
	import.Mem_Alloc = Irc_MemAlloc;
	import.Mem_Free = Irc_MemFree;
	import.Mem_FreePool = Irc_MemFreePool;
	import.Mem_EmptyPool = Irc_MemEmptyPool;
	import.Dynvar_Create = Dynvar_Create;
	import.Dynvar_Destroy = Dynvar_Destroy;
	import.Dynvar_Lookup = Dynvar_Lookup;
	import.Dynvar_GetName = Dynvar_GetName;
	import.Dynvar_GetValue = Dynvar_GetValue;
	import.Dynvar_SetValue = Dynvar_SetValue;
	import.Dynvar_CallListeners = Dynvar_CallListeners;
	import.Dynvar_AddListener = Dynvar_AddListener;
	import.Dynvar_RemoveListener = Dynvar_RemoveListener;
	import.DYNVAR_WRITEONLY = DYNVAR_WRITEONLY;
	import.DYNVAR_READONLY = DYNVAR_READONLY;
	import.Cvar_Get = Cvar_Get;
	import.Cvar_Set = Cvar_Set;
	import.Cvar_SetValue = Cvar_SetValue;
	import.Cvar_ForceSet = Cvar_ForceSet;
	import.Cvar_Integer = Cvar_Integer;
	import.Cvar_Value = Cvar_Value;
	import.Cvar_String = Cvar_String;
	import.Cmd_Argc = Cmd_Argc;
	import.Cmd_Argv = Cmd_Argv;
	import.Cmd_Args = Cmd_Args;
	import.Cmd_AddCommand = Cmd_AddCommand;
	import.Cmd_RemoveCommand = Cmd_RemoveCommand;
	import.Cmd_ExecuteString = Cmd_ExecuteString;
	import.Com_BeginRedirect = Com_BeginRedirect;
	import.Com_EndRedirect = Com_EndRedirect;
	import.Cmd_SetCompletionFunc = Cmd_SetCompletionFunc;
	import.Cbuf_AddText = Cbuf_AddText;
	import.Trie_Create = Trie_Create;
	import.Trie_Destroy = Trie_Destroy;
	import.Trie_Clear = Trie_Clear;
	import.Trie_GetSize = Trie_GetSize;
	import.Trie_Insert = Trie_Insert;
	import.Trie_Remove = Trie_Remove;
	import.Trie_Replace = Trie_Replace;
	import.Trie_Find = Trie_Find;
	import.Trie_FindIf = Trie_FindIf;
	import.Trie_NoOfMatches = Trie_NoOfMatches;
	import.Trie_NoOfMatchesIf = Trie_NoOfMatchesIf;
	import.Trie_Dump = Trie_Dump;
	import.Trie_DumpIf = Trie_DumpIf;
	import.Trie_FreeDump = Trie_FreeDump;

	// load dynamic library
	Com_Printf( "Loading IRC module... " );
	funcs[0].name = "GetIrcAPI";
	funcs[0].funcPointer = (void **) &GetIrcAPI_f;
	funcs[1].name = NULL;
	irc_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/" LIB_PREFIX "irc_" ARCH LIB_SUFFIX, funcs );

	if( irc_libhandle )
	{
		// load succeeded
		int api_version;
		irc_export = GetIrcAPI_f( &import );
		irc_pool = Mem_AllocPool( NULL, "IRC Module" );
		api_version = irc_export->API();
		if( api_version == IRC_API_VERSION )
		{
			if( irc_export->Init() )
			{
				dynvar_t *const quit = Dynvar_Lookup( "quit" );
				if( quit )
					Dynvar_AddListener( quit, Irc_Quit_f );
				irc_initialized = true;
				Cmd_AddCommand( "irc_unload", Irc_UnloadLibrary );
				Com_Printf( "Success.\n" );
			}
			else
			{
				// initialization failed
				Mem_FreePool( &irc_pool );
				Com_Printf( "Initialization failed.\n" );
				Irc_UnloadLibrary();
			}
		}
		else
		{
			// wrong version
			Mem_FreePool( &irc_pool );
			Com_Printf( "Wrong version: %i, not %i.\n", api_version, IRC_API_VERSION );
			Irc_UnloadLibrary();
		}
	}
	else
	{
		Com_Printf( "Not found.\n" );
	}

	Mem_DebugCheckSentinelsGlobal();
}
コード例 #7
0
ファイル: cin.c プロジェクト: tenght/qfusion
/*
* CIN_LoadLibrary
*/
void CIN_LoadLibrary( bool verbose )
{
	static cin_import_t import;
	dllfunc_t funcs[2];
	void *( *GetCinematicsAPI )(void *);

	assert( !cin_libhandle );

	import.Print = &CL_CinModule_Print;
	import.Error = &CL_CinModule_Error;

	import.Cvar_Get = &Cvar_Get;
	import.Cvar_Set = &Cvar_Set;
	import.Cvar_SetValue = &Cvar_SetValue;
	import.Cvar_ForceSet = &Cvar_ForceSet;
	import.Cvar_String = &Cvar_String;
	import.Cvar_Value = &Cvar_Value;

	import.Cmd_Argc = &Cmd_Argc;
	import.Cmd_Argv = &Cmd_Argv;
	import.Cmd_Args = &Cmd_Args;

	import.Cmd_AddCommand = &Cmd_AddCommand;
	import.Cmd_RemoveCommand = &Cmd_RemoveCommand;
	import.Cmd_ExecuteText = &Cbuf_ExecuteText;
	import.Cmd_Execute = &Cbuf_Execute;
	import.Cmd_SetCompletionFunc = &Cmd_SetCompletionFunc;

	import.FS_FOpenFile = &FS_FOpenFile;
	import.FS_Read = &FS_Read;
	import.FS_Write = &FS_Write;
	import.FS_Print = &FS_Print;
	import.FS_Tell = &FS_Tell;
	import.FS_Seek = &FS_Seek;
	import.FS_Eof = &FS_Eof;
	import.FS_Flush = &FS_Flush;
	import.FS_FCloseFile = &FS_FCloseFile;
	import.FS_RemoveFile = &FS_RemoveFile;
	import.FS_GetFileList = &FS_GetFileList;
	import.FS_IsUrl = &FS_IsUrl;

	import.Milliseconds = &Sys_Milliseconds;
	import.Microseconds = &Sys_Microseconds;

	import.Mem_AllocPool = &CL_CinModule_MemAllocPool;
	import.Mem_Alloc = &CL_CinModule_MemAlloc;
	import.Mem_Free = &CL_CinModule_MemFree;
	import.Mem_FreePool = &CL_CinModule_MemFreePool;
	import.Mem_EmptyPool = &CL_CinModule_MemEmptyPool;

	// load dynamic library
	cin_export = NULL;
	if( verbose ) {
		Com_Printf( "Loading CIN module... " );
	}

	funcs[0].name = "GetCinematicsAPI";
	funcs[0].funcPointer = ( void ** ) &GetCinematicsAPI;
	funcs[1].name = NULL;
	cin_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/" LIB_PREFIX "cin_" ARCH LIB_SUFFIX, funcs );

	if( cin_libhandle )
	{
		// load succeeded
		int api_version;

		cin_export = GetCinematicsAPI( &import );
		cin_mempool = Mem_AllocPool( NULL, "CIN Module" );

		api_version = cin_export->API();

		if( api_version == CIN_API_VERSION )
		{
			if( cin_export->Init( verbose ) )
			{
				if( verbose ) {
					Com_Printf( "Success.\n" );
				}
			}
			else
			{
				// initialization failed
				Mem_FreePool( &cin_mempool );
				if( verbose ) {
					Com_Printf( "Initialization failed.\n" );
				}
				CIN_UnloadLibrary( verbose );
			}
		}
		else
		{
			// wrong version
			Mem_FreePool( &cin_mempool );
			Com_Printf( "CIN_LoadLibrary: wrong version: %i, not %i.\n", api_version, CIN_API_VERSION );
			CIN_UnloadLibrary( verbose );
		}
	}
	else
	{
		if( verbose ) {
			Com_Printf( "Not found.\n" );
		}
	}

	Mem_DebugCheckSentinelsGlobal();
}
コード例 #8
0
/*
* FTLIB_LoadLibrary
*/
void FTLIB_LoadLibrary( qboolean verbose )
{
	static ftlib_import_t import;
	dllfunc_t funcs[2];
	void *( *GetFTLibAPI )(void *);

	assert( !ftlib_libhandle );

	import.Print = &CL_FTLibModule_Print;
	import.Error = &CL_FTLibModule_Error;

	import.Cvar_Get = &Cvar_Get;
	import.Cvar_Set = &Cvar_Set;
	import.Cvar_SetValue = &Cvar_SetValue;
	import.Cvar_ForceSet = &Cvar_ForceSet;
	import.Cvar_String = &Cvar_String;
	import.Cvar_Value = &Cvar_Value;

	import.Cmd_Argc = &Cmd_Argc;
	import.Cmd_Argv = &Cmd_Argv;
	import.Cmd_Args = &Cmd_Args;

	import.Cmd_AddCommand = &Cmd_AddCommand;
	import.Cmd_RemoveCommand = &Cmd_RemoveCommand;
	import.Cmd_ExecuteText = &Cbuf_ExecuteText;
	import.Cmd_Execute = &Cbuf_Execute;
	import.Cmd_SetCompletionFunc = &Cmd_SetCompletionFunc;

	import.FS_FOpenFile = &FS_FOpenFile;
	import.FS_Read = &FS_Read;
	import.FS_Write = &FS_Write;
	import.FS_Print = &FS_Print;
	import.FS_Tell = &FS_Tell;
	import.FS_Seek = &FS_Seek;
	import.FS_Eof = &FS_Eof;
	import.FS_Flush = &FS_Flush;
	import.FS_FCloseFile = &FS_FCloseFile;
	import.FS_RemoveFile = &FS_RemoveFile;
	import.FS_GetFileList = &FS_GetFileList;
	import.FS_IsUrl = &FS_IsUrl;

	import.R_RegisterPic = &CL_FTLibModule_RegisterPic;
	import.R_RegisterRawPic = &CL_FTLibModule_RegisterRawPic;
	import.R_DrawStretchPic = &CL_FTLibModule_DrawStretchPic;
	import.R_SetScissorRegion = &CL_FTLibModule_SetScissorRegion;
	import.R_GetScissorRegion = &CL_FTLibModule_GetScissorRegion;

	import.Milliseconds = &Sys_Milliseconds;
	import.Microseconds = &Sys_Microseconds;

	import.Mem_AllocPool = &CL_FTLibModule_MemAllocPool;
	import.Mem_Alloc = &CL_FTLibModule_MemAlloc;
	import.Mem_Free = &CL_FTLibModule_MemFree;
	import.Mem_FreePool = &CL_FTLibModule_MemFreePool;
	import.Mem_EmptyPool = &CL_FTLibModule_MemEmptyPool;

	// load dynamic library
	ftlib_export = NULL;
	if( verbose ) {
		Com_Printf( "Loading Fonts module... " );
	}

	funcs[0].name = "GetFTLibAPI";
	funcs[0].funcPointer = ( void ** ) &GetFTLibAPI;
	funcs[1].name = NULL;
	ftlib_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/ftlib_" ARCH LIB_SUFFIX, funcs );

	if( ftlib_libhandle )
	{
		// load succeeded
		int api_version;

		ftlib_export = GetFTLibAPI( &import );
		ftlib_mempool = Mem_AllocPool( NULL, "Fonts Library Module" );

		api_version = ftlib_export->API();

		if( api_version == FTLIB_API_VERSION )
		{
			if( ftlib_export->Init( verbose ) )
			{
				if( verbose ) {
					Com_Printf( "Success.\n" );
				}
			}
			else
			{
				// initialization failed
				Mem_FreePool( &ftlib_mempool );
				if( verbose ) {
					Com_Printf( "Initialization failed.\n" );
				}
				FTLIB_UnloadLibrary( verbose );
			}
		}
		else
		{
			// wrong version
			Mem_FreePool( &ftlib_mempool );
			Com_Printf( "ftlib_LoadLibrary: wrong version: %i, not %i.\n", api_version, FTLIB_API_VERSION );
			FTLIB_UnloadLibrary( verbose );
		}
	}
	else
	{
		if( verbose ) {
			Com_Printf( "Not found.\n" );
		}
	}

	Mem_CheckSentinelsGlobal();
}
コード例 #9
0
ファイル: vgui_draw.c プロジェクト: Reedych/xash3d
/*
================
VGui_Startup

Load vgui_support library and call VGui_Startup
================
*/
void VGui_Startup( int width, int height )
{
	static qboolean failed = false;
	if( failed )
		return;
	if(!vgui.initialized)
	{
		void (*F) ( vguiapi_t * );
		char vguiloader[256];
		char vguilib[256];

		Com_ResetLibraryError();

		// hack: load vgui with correct path first if specified.
		// it will be reused while resolving vgui support and client deps
		if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ) )
		{
			if( Q_strstr( vguilib, ".dll") )
				Q_strncpy( vguiloader, "vgui_support.dll", 256 );
			else
				Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );
			if( !Com_LoadLibrary( vguilib, false ) )
				MsgDev( D_WARN, "VGUI preloading failed. Default library will be used!\n");
		}

		if( !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ) )
			Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );

		lib = Com_LoadLibrary( vguiloader, false );
		if(!lib)
			MsgDev( D_ERROR, "Failed to load vgui_support library: %s", Com_GetLibraryError() );
		else
		{
			F = Com_GetProcAddress( lib, "InitAPI" );
			if( F )
			{
				F( &vgui );
				vgui.initialized = true;
				VGUI_InitCursors();
			}
			else
				MsgDev( D_ERROR, "Failed to find vgui_support library entry point!\n" );
		}

	}

	// vgui may crash if it cannot find font
	if( width <= 320 )
		width = 320;
	else if( width <= 400 )
		width = 400;
	else if( width <= 512 )
		width = 512;
	else if( width <= 640 )
		width = 640;
	else if( width <= 800 )
		width = 800;
	else if( width <= 1024 )
		width = 1024;
	else if( width <= 1152 )
		width = 1152;
	else if( width <= 1280 )
		width = 1280;
	else //if( width <= 1600 )
		width = 1600;


	if( vgui.initialized )
	{
		//host.mouse_visible = true;
		vgui.Startup( width, height );
	}
	else failed = true;
}