当前位置: 首页>>代码示例>>C++>>正文


C++ Sys_LoadLibrary函数代码示例

本文整理汇总了C++中Sys_LoadLibrary函数的典型用法代码示例。如果您正苦于以下问题:C++ Sys_LoadLibrary函数的具体用法?C++ Sys_LoadLibrary怎么用?C++ Sys_LoadLibrary使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Sys_LoadLibrary函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Com_Printf

void *Sys_LoadDll(const char *name, qboolean useSystemLib)
{
	void *dllhandle = NULL;

	if(useSystemLib)
		Com_Printf("Trying to load \"%s\"...\n", name);
	
	if(!useSystemLib || !(dllhandle = Sys_LoadLibrary(name)))
	{
		const char *topDir;
		char libPath[MAX_OSPATH];
        
		topDir = Sys_BinaryPath();
        
		if(!*topDir)
			topDir = ".";
        
		Com_Printf("Trying to load \"%s\" from \"%s\"...\n", name, topDir);
		Com_sprintf(libPath, sizeof(libPath), "%s%c%s", topDir, PATH_SEP, name);
        
		if(!(dllhandle = Sys_LoadLibrary(libPath)))
		{
			const char *basePath = Cvar_VariableString("fs_basepath");
			
			if(!basePath || !*basePath)
				basePath = ".";
			
			if(FS_FilenameCompare(topDir, basePath))
			{
				Com_Printf("Trying to load \"%s\" from \"%s\"...\n", name, basePath);
				Com_sprintf(libPath, sizeof(libPath), "%s%c%s", basePath, PATH_SEP, name);
				dllhandle = Sys_LoadLibrary(libPath);
			}
			
			if(!dllhandle)
			{
				const char *cdPath = Cvar_VariableString("fs_cdpath");

				if(!basePath || !*basePath)
					basePath = ".";

				if(FS_FilenameCompare(topDir, cdPath))
				{
					Com_Printf("Trying to load \"%s\" from \"%s\"...\n", name, cdPath);
					Com_sprintf(libPath, sizeof(libPath), "%s%c%s", cdPath, PATH_SEP, name);
					dllhandle = Sys_LoadLibrary(libPath);
				}

				if(!dllhandle)
				{
					Com_Printf("Loading \"%s\" failed\n", name);
				}
			}
		}
	}
	
	return dllhandle;
}
开发者ID:shadow95,项目名称:OpenJK,代码行数:58,代码来源:win_main.cpp

示例2: Com_Printf

/*
=================
Sys_LoadDll

First try to load library name from system library path,
from executable path, then fs_basepath.
=================
*/
void *Sys_LoadDll( const char *name, qboolean useSystemLib )
{
	void *dllhandle = NULL;

	// Don't load any DLLs that end with the pk3 extension
	if ( COM_CompareExtension( name, ".pk3" ) )
	{
		Com_Printf( S_COLOR_YELLOW "WARNING: Rejecting DLL named \"%s\"", name );
		return NULL;
	}

	if ( useSystemLib )
	{
		Com_Printf( "Trying to load \"%s\"...\n", name );

		dllhandle = Sys_LoadLibrary( name );
		if ( dllhandle )
			return dllhandle;

		Com_Printf( "%s(%s) failed: \"%s\"\n", __FUNCTION__, name, Sys_LibraryError() );
	}

	const char *binarypath = Sys_BinaryPath();
	const char *basepath = Cvar_VariableString( "fs_basepath" );

	if ( !*binarypath )
		binarypath = ".";

	const char *searchPaths[] = {
		binarypath,
		basepath,
	};
	const size_t numPaths = ARRAY_LEN( searchPaths );

	for ( size_t i = 0; i < numPaths; i++ )
	{
		const char *libDir = searchPaths[i];
		if ( !libDir[0] )
			continue;

		Com_Printf( "Trying to load \"%s\" from \"%s\"...\n", name, libDir );
		char *fn = va( "%s%c%s", libDir, PATH_SEP, name );
		dllhandle = Sys_LoadLibrary( fn );
		if ( dllhandle )
			return dllhandle;

		Com_Printf( "%s(%s) failed: \"%s\"\n", __FUNCTION__, fn, Sys_LibraryError() );
	}
	return NULL;
}
开发者ID:ForcePush,项目名称:OpenJK,代码行数:58,代码来源:sys_main.cpp

示例3: intptr_t

/*
=================
Sys_LoadGameDll

Used to load a development dll instead of a virtual machine
=================
*/
void *Sys_LoadGameDll(const char *name,
	intptr_t (QDECL **entryPoint)(intptr_t, ...),
	intptr_t (*systemcalls)(intptr_t, ...))
{
	void *libHandle;
	void (*dllEntry)(intptr_t (*syscallptr)(intptr_t, ...));

	assert(name);

	Com_DPrintf( "Loading DLL file: %s\n", name);
	libHandle = Sys_LoadLibrary(name);

	if(!libHandle)
	{
		Com_Printf("Sys_LoadGameDll(%s) failed:\n\"%s\"\n", name, Sys_LibraryError());
		return NULL;
	}

	dllEntry = Sys_LoadFunction( libHandle, "dllEntry" );
	*entryPoint = Sys_LoadFunction( libHandle, "vmMain" );

	if ( !*entryPoint || !dllEntry )
	{
		Com_Printf ( "Sys_LoadGameDll(%s) failed to find vmMain function:\n\"%s\" !\n", name, Sys_LibraryError( ) );
		Sys_UnloadLibrary(libHandle);

		return NULL;
	}

	Com_DPrintf ( "Sys_LoadGameDll(%s) found vmMain function at %p\n", name, *entryPoint );
	dllEntry( systemcalls );

	return libHandle;
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:41,代码来源:sys_main.c

示例4: CURL_OpenLibrary

/*
====================
CURL_CloseLibrary

Load the cURL DLL
====================
*/
static qboolean CURL_OpenLibrary (void)
{
	const char* dllnames [] =
	{
#if defined(WIN32)
		"libcurl-4.dll",
		"libcurl-3.dll",
#elif defined(MACOSX)
		"libcurl.4.dylib", // Mac OS X Notyetreleased
		"libcurl.3.dylib", // Mac OS X Tiger
		"libcurl.2.dylib", // Mac OS X Panther
#else
		"libcurl.so.4",
		"libcurl.so.3",
		"libcurl.so", // FreeBSD
#endif
		NULL
	};

	// Already loaded?
	if (curl_dll)
		return true;

	// Load the DLL
	return Sys_LoadLibrary (dllnames, &curl_dll, curlfuncs);
}
开发者ID:MarioMario,项目名称:smbnex-engine,代码行数:33,代码来源:libcurl.c

示例5: FS_BuildOSPath

/**
 * @brief Used by Sys_LoadDll to get handle on a mod library
 * @return Handle to a mod library
 */
static void *Sys_TryLibraryLoad(const char *base, const char *gamedir, const char *fname)
{
	void *libHandle;
	char *fn;

	fn = FS_BuildOSPath(base, gamedir, fname);

#ifdef __APPLE__
	if (FS_Unzip(fn, qtrue))
	{
		char buffer[MAX_OSPATH];
		Com_sprintf(buffer, sizeof(buffer), "%s.bundle/Contents/MacOS/%s", fname, fname);
		fn = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), gamedir, buffer);
	}
#endif // __APPLE__

	Com_Printf("Sys_LoadDll(%s)... ", fn);

	libHandle = Sys_LoadLibrary(fn);

	if (!libHandle)
	{
		Com_Printf("failed: \"%s\"\n", Sys_LibraryError());
		return NULL;
	}
	Com_Printf("succeeded\n");

	return libHandle;
}
开发者ID:harleking,项目名称:etlegacy,代码行数:33,代码来源:sys_main.c

示例6: PNG_OpenLibrary

/*
====================
PNG_OpenLibrary

Try to load the PNG DLL
====================
*/
qboolean PNG_OpenLibrary (void)
{
#ifndef LINK_TO_LIBPNG
	const char* dllnames [] =
	{
#if WIN32
        "libpng16.dll",
        "libpng16-16.dll",
		"libpng15-15.dll",
		"libpng15.dll",
		"libpng14-14.dll",
		"libpng14.dll",
		"libpng12.dll",
#elif defined(MACOSX)
        "libpng16.16.dylib",
		"libpng15.15.dylib",
		"libpng14.14.dylib",
		"libpng12.0.dylib",
#else
        "libpng16.so",
        "libpng16.so.16",
		"libpng15.so.15", // WTF libtool guidelines anyone?
		"libpng14.so.14", // WTF libtool guidelines anyone?
		"libpng12.so.0",
		"libpng.so", // FreeBSD
#endif
		NULL
	};

	// Already loaded?
	if (png_dll)
		return true;

	// Load the DLL
	if(!Sys_LoadLibrary (dllnames, &png_dll, pngfuncs))
		return false;
	if(qpng_access_version_number() / 100 >= 104)
		if(!Sys_LoadLibrary (dllnames, &png14_dll, png14funcs))
		{
			Sys_UnloadLibrary (&png_dll);
			return false;
		}
#endif
	return true;
}
开发者ID:kasymovga,项目名称:DarkPlacesRM,代码行数:52,代码来源:image_png.c

示例7: OGG_OpenLibrary

/*
====================
OGG_OpenLibrary

Try to load the VorbisFile DLL
====================
*/
qboolean OGG_OpenLibrary (void)
{
	const char* dllnames_vo [] =
	{
#if defined(WIN32)
		"libvorbis-0.dll",
		"libvorbis.dll",
		"vorbis.dll",
#elif defined(MACOSX)
		"libvorbis.dylib",
#else
		"libvorbis.so.0",
		"libvorbis.so",
#endif
		NULL
	};
	const char* dllnames_vf [] =
	{
#if defined(WIN32)
		"libvorbisfile-3.dll",
		"libvorbisfile.dll",
		"vorbisfile.dll",
#elif defined(MACOSX)
		"libvorbisfile.dylib",
#else
		"libvorbisfile.so.3",
		"libvorbisfile.so",
#endif
		NULL
	};

	// Already loaded?
	if (vf_dll)
		return true;

// COMMANDLINEOPTION: Sound: -novorbis disables ogg vorbis sound support
	if (COM_CheckParm("-novorbis"))
		return false;

	// Load the DLLs
	// We need to load both by hand because some OSes seem to not load
	// the vorbis DLL automatically when loading the VorbisFile DLL
	return Sys_LoadLibrary (dllnames_vo, &vo_dll, vorbisfuncs) && Sys_LoadLibrary (dllnames_vf, &vf_dll, vorbisfilefuncs);
}
开发者ID:Feoggou,项目名称:DpOmnicide,代码行数:51,代码来源:ogg.cpp

示例8: Com_Printf

/*
=================
Sys_LoadDll

First try to load library name from system library path,
from executable path, then fs_basepath.
=================
*/
void *Sys_LoadDll( const char *name, qboolean useSystemLib )
{
	void *dllhandle = NULL;

	if ( useSystemLib )
	{
		Com_Printf( "Trying to load \"%s\"...\n", name );

		dllhandle = Sys_LoadLibrary( name );
		if ( dllhandle )
			return dllhandle;

		Com_Printf( "%s(%s) failed: \"%s\"\n", __FUNCTION__, name, Sys_LibraryError() );
	}

	const char *binarypath = Sys_BinaryPath();
	const char *basepath = Cvar_VariableString( "fs_basepath" );

	if ( !*binarypath )
		binarypath = ".";

	const char *searchPaths[] = {
		binarypath,
		basepath,
	};
	const size_t numPaths = ARRAY_LEN( searchPaths );

	for ( size_t i = 0; i < numPaths; i++ )
	{
		const char *libDir = searchPaths[i];
		if ( !libDir[0] )
			continue;

		Com_Printf( "Trying to load \"%s\" from \"%s\"...\n", name, libDir );
		char *fn = va( "%s%c%s", libDir, PATH_SEP, name );
		dllhandle = Sys_LoadLibrary( fn );
		if ( dllhandle )
			return dllhandle;

		Com_Printf( "%s(%s) failed: \"%s\"\n", __FUNCTION__, fn, Sys_LibraryError() );
	}
	return NULL;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:51,代码来源:sys_main.cpp

示例9: Sys_LoadDll

/*
 * First try to load library name from system library path,
 * from executable path, then fs_basepath.
 */
void *
Sys_LoadDll(const char *name, qbool useSystemLib)
{
	void *dllhandle;

	if(useSystemLib)
		comprintf("Trying to load \"%s\"...\n", name);

	if(!useSystemLib || !(dllhandle = Sys_LoadLibrary(name))){
		const char *topDir;
		char libPath[MAX_OSPATH];

		topDir = Sys_BinaryPath();

		if(!*topDir)
			topDir = ".";

		comprintf("Trying to load \"%s\" from \"%s\"...\n", name,
			topDir);
		Q_sprintf(libPath, sizeof(libPath), "%s%c%s", topDir, PATH_SEP,
			name);

		if(!(dllhandle = Sys_LoadLibrary(libPath))){
			const char *basePath = cvargetstr("fs_basepath");

			if(!basePath || !*basePath)
				basePath = ".";

			if(fscomparefname(topDir, basePath)){
				comprintf("Trying to load \"%s\" from \"%s\"...\n",
					name, basePath);
				Q_sprintf(libPath, sizeof(libPath), "%s%c%s",
					basePath, PATH_SEP, name);
				dllhandle = Sys_LoadLibrary(libPath);
			}

			if(!dllhandle)
				comprintf("Loading \"%s\" failed\n", name);
		}
	}
	return dllhandle;
}
开发者ID:icanhas,项目名称:yantar,代码行数:46,代码来源:main.c

示例10: JVM_JNI_Init

static qboolean JVM_JNI_Init()
{
	if(javaLib)
		return qtrue;

	Com_Printf("Loading \"%s\"...\n", jvm_javaLib->string);
	if((javaLib = Sys_LoadLibrary(jvm_javaLib->string)) == 0)
	{
#ifdef _WIN32
		return qfalse;
#else
		char            fn[1024];

		Com_Printf("JVM_JNI_Init() failed:\n\"%s\"\n", Sys_LibraryError());

		Q_strncpyz(fn, Sys_Cwd(), sizeof(fn));
		strncat(fn, "/", sizeof(fn) - strlen(fn) - 1);
		strncat(fn, jvm_javaLib->string, sizeof(fn) - strlen(fn) - 1);

		if((javaLib = Sys_LoadLibrary(fn)) == 0)
		{
			Com_Printf("JVM_JNI_Init() failed:\n\"%s\"\n", Sys_LibraryError());
			return qfalse;
		}
#endif							/* _WIN32 */
	}

	javaEnabled = qtrue;

	QJNI_CreateJavaVM = GPA("JNI_CreateJavaVM");
	QJNI_GetCreatedJavaVMs = GPA("JNI_GetCreatedJavaVMs");

	if(!javaEnabled)
	{
		//JVM_JNI_Shutdown();
		return qfalse;
	}

	return qtrue;
}
开发者ID:redrumrobot,项目名称:dretchstorm,代码行数:40,代码来源:vm_java.c

示例11: QAL_Init

qboolean QAL_Init(void)
{
    al_driver = Cvar_Get("al_driver", LIBAL, 0);
    al_device = Cvar_Get("al_device", "", 0);

    // don't allow absolute or relative paths
    FS_SanitizeFilenameVariable(al_driver);

    Sys_LoadLibrary(al_driver->string, NULL, &handle);
    if (!handle) {
        return qfalse;
    }

#define QAL(type, func)  q##func = Sys_GetProcAddress(handle, #func)
    QALC_IMP
    QAL_IMP
#undef QAL

    device = qalcOpenDevice(al_device->string[0] ? al_device->string : NULL);
    if (!device) {
        Com_SetLastError(va("alcOpenDevice(%s) failed", al_device->string));
        goto fail;
    }

    context = qalcCreateContext(device, NULL);
    if (!context) {
        Com_SetLastError("alcCreateContext failed");
        goto fail;
    }

    if (!qalcMakeContextCurrent(context)) {
        Com_SetLastError("alcMakeContextCurrent failed");
        goto fail;
    }

    al_driver->flags |= CVAR_SOUND;
    al_device->flags |= CVAR_SOUND;

    return qtrue;

fail:
    QAL_Shutdown();
    return qfalse;
}
开发者ID:jayschwa,项目名称:q2pro,代码行数:44,代码来源:qal.c

示例12: QAL_Init

qboolean QAL_Init( void ) {
    al_driver = Cvar_Get( "al_driver", DEFAULT_OPENAL_DRIVER, CVAR_SOUND );
    al_device = Cvar_Get( "al_device", "", CVAR_SOUND );

    Sys_LoadLibrary( al_driver->string, NULL, &handle );
    if( !handle ) {
        return qfalse;
    }

#define QAL(type,func)  q##func = Sys_GetProcAddress( handle, #func );
QALC_IMP
QAL_IMP
#undef QAL

    Com_DPrintf( "...opening OpenAL device: " );
    device = qalcOpenDevice( al_device->string[0] ? al_device->string : NULL );
    if( !device ) {
        goto fail;
    }
    Com_DPrintf( "ok\n" );

    Com_DPrintf( "...creating OpenAL context: " );
    context = qalcCreateContext( device, NULL );
    if( !context ) {
        goto fail;
    }
    Com_DPrintf( "ok\n" );

    Com_DPrintf( "...making context current: " );
    if( !qalcMakeContextCurrent( context ) ) {
        goto fail;
    }
    Com_DPrintf( "ok\n" );

    al_driver->flags |= CVAR_SOUND;
    al_device->flags |= CVAR_SOUND;

    return qtrue;

fail:
    Com_DPrintf( "failed\n" );
    QAL_Shutdown();
    return qfalse;
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:44,代码来源:qal_api.c

示例13: intptr_t

/*
=================
Sys_LoadDll

Used to load a development dll instead of a virtual machine
#1 look in fs_homepath
#2 look in fs_basepath
=================
*/
void *Sys_LoadDll( const char *name,
	intptr_t (**entryPoint)(int, ...),
	intptr_t (*systemcalls)(intptr_t, ...) )
{
	void  *libHandle;
	void  (*dllEntry)( intptr_t (*syscallptr)(intptr_t, ...) );
	char  fname[MAX_OSPATH];
	char  *netpath;

	assert( name );

	Com_sprintf(fname, sizeof(fname), "%s" ARCH_STRING DLL_EXT, name);

	netpath = FS_FindDll(fname);

	if(!netpath) {
		Com_Printf( "Sys_LoadDll(%s) could not find it\n", fname );
		return NULL;
	}

	Com_Printf( "Loading DLL file: %s\n", netpath);
	libHandle = Sys_LoadLibrary(netpath);

	if(!libHandle) {
		Com_Printf( "Sys_LoadDll(%s) failed:\n\"%s\"\n", netpath, Sys_LibraryError() );
		return NULL;
	}

	dllEntry = Sys_LoadFunction( libHandle, "dllEntry" );
	*entryPoint = Sys_LoadFunction( libHandle, "vmMain" );

	if ( !*entryPoint || !dllEntry )
	{
		Com_Printf ( "Sys_LoadDll(%s) failed to find vmMain function:\n\"%s\" !\n", name, Sys_LibraryError( ) );
		Sys_UnloadLibrary(libHandle);

		return NULL;
	}

	Com_Printf ( "Sys_LoadDll(%s) found vmMain function at %p\n", name, *entryPoint );
	dllEntry( systemcalls );

	return libHandle;
}
开发者ID:OpenArena,项目名称:legacy,代码行数:53,代码来源:sys_main.c

示例14: VGui_Setup

qboolean VGui_Setup(void)
{
	void *vguidll;

	dllfunction_t funcs[] =
	{
		{(void*)&vgui_init, "init"},
		{(void*)&vgui_frame, "frame"},
		{(void*)&vgui_key, "key"},
		{(void*)&vgui_mouse, "mouse"},
		{NULL}
	};

	vguidll = Sys_LoadLibrary("vguiwrap", funcs);

	if (vguidll)
		vgui_panel = vgui_init();
	return !!vgui_panel;
}
开发者ID:ProfessorKaos64,项目名称:ftequake,代码行数:19,代码来源:clhl_game.c

示例15: ModPlug_OpenLibrary

/*
====================
ModPlug_OpenLibrary

Try to load the modplugFile DLL
====================
*/
qboolean ModPlug_OpenLibrary (void)
{
	const char* dllnames_modplug [] =
	{
#if defined(WIN32)
		"libmodplug-1.dll",
		"modplug.dll",
#elif defined(MACOSX)
		"libmodplug.dylib",
#else
		"libmodplug.so.1",
		"libmodplug.so",
#endif
		NULL
	};

	// Already loaded?
	if (modplug_dll)
		return true;

// COMMANDLINEOPTION: Sound: -nomodplug disables modplug sound support
	if (COM_CheckParm("-nomodplug"))
		return false;

#ifdef __ANDROID__
	Con_Print("Warning: no modplug support in Android yet.\n");
	return false;
#endif

	// Load the DLLs
	// We need to load both by hand because some OSes seem to not load
	// the modplug DLL automatically when loading the modplugFile DLL
	if(Sys_LoadLibrary (dllnames_modplug, &modplug_dll, modplugfuncs))
	{
		qModPlug_SetMasterVolume = (ModPlug_SetMasterVolume_t *) Sys_GetProcAddress(modplug_dll, "ModPlug_SetMasterVolume");
		if(!qModPlug_SetMasterVolume)
			Con_Print("Warning: modplug volume control not supported. Try getting a newer version of libmodplug.\n");
		return true;
	}
	else
		return false;
}
开发者ID:kaadmy,项目名称:diamondbomb,代码行数:49,代码来源:snd_modplug.c


注:本文中的Sys_LoadLibrary函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。