示例#1
0
IMapMatch *IMapMatch::GetMapMatch()
{
  if(!m_match)
  {
    CDynamicLibrary oneLib;

#ifdef _DEBUG
    tstring fileName = _T("uegpsd.dll");
    bool rt = oneLib.Load(fileName, CDynamicLibrary::LM_Lazy); 
    assert(rt);
#else
    tstring fileName = _T("uegps.dll");
    bool rt = oneLib.Load(fileName, CDynamicLibrary::LM_Lazy); 
    assert(rt);
#endif

    if(rt)
    {
      tstring funcName = _T("GetMapMatch");
      tstring type = _T("");
      m_match = reinterpret_cast<IMapMatch *>(oneLib.ExecuteInterface(funcName, type));
    }
  }

  assert(m_match);
  return m_match;
}
示例#2
0
文件: query.cpp 项目: sweetdark/navi
IQuery *IQuery::GetQuery()
{
	if(!m_query)
	{
		CDynamicLibrary oneLib;

	#ifdef _DEBUG
		tstring fileName = _T("uequeryd.dll");
		bool rt = oneLib.Load(fileName, CDynamicLibrary::LM_Lazy); 
		assert(rt);
	#else
		tstring fileName = _T("uequery.dll");
		bool rt = oneLib.Load(fileName, CDynamicLibrary::LM_Lazy); 
		assert(rt);
	#endif

		if(rt)
		{
			tstring funcName = _T("GetQuery");
			tstring type = _T("Default");
			m_query = reinterpret_cast<IQuery *>(oneLib.ExecuteInterface(funcName, type));
		}
	}

	assert(m_query);
	return m_query;
}
示例#3
0
文件: Main.cpp 项目: LBRGeorge/jmnvc
static int StartRcon(int argc,char* argv [])
{
    CDynamicLibrary RCon;
    if (RCon.Load(LIB_RCON))
    {
        typedef int(Main_t)(int,char* []);
        Main_t* pfnEntryPoint = reinterpret_cast <Main_t*> ((long long)(RCon.GetProcedureAddress("RunRcon")));
        if (pfnEntryPoint)
        {
            return pfnEntryPoint(argc,argv);
        }
        else
        {
            printf("ERROR: Bad file: %s\n",LIB_RCON);
        }
    }
    else
    {
        printf("ERROR: Could not load %s\n",LIB_RCON);
        printf("* Check installed data files.\n");
#ifdef WIN32
        printf("* Check installed Microsoft Visual C++ 2008 SP1 Redistributable Package (x86).\n");
#endif
    }
	return -1;
}
示例#4
0
	CRemoteMdbItf()
		:m_oLib("MdbCon")
	{
		m_fCreateMdbClient = (FCreateMdbClient)m_oLib.FindSymbol("CreateMdbClient");
		m_fDestroyMdbClient = (FDestroyMdbClient)m_oLib.FindSymbol("DestroyMdbClient");
		m_fStartMdbClient = (FStartMdbClient)m_oLib.FindSymbol("StartMdbClient");
		m_fStopMdbClient = (FStopMdbClient)m_oLib.FindSymbol("StopMdbClient");
	}
示例#5
0
	CMdbRepItf()
		:m_oLib("MdbRep")
	{
		m_fMdbTransfer = (FMdbTransfer)m_oLib.FindSymbol("MdbTransfer");
		m_fConfigMdbDomain = (FConfigMdbDomain)m_oLib.FindSymbol("ConfigMdbDomain");
		m_fCreateMdbReplicator = (FCreateMdbReplicator)m_oLib.FindSymbol("CreateMdbReplicator");
		m_fRegisterMdbTransfer = (FRegisterMdbTransfer)m_oLib.FindSymbol("RegisterMdbTransfer");
		m_fCleanupMdbReplication = (FCleanupMdbReplication)m_oLib.FindSymbol("CleanupMdbReplication");
	}
示例#6
0
	bool Valid()
	{
		if(!m_oLib.Valid())
			return false;
		if(!m_fCreateMemoryDataBase)
			return false;
		return true;
	}
示例#7
0
	bool Valid()
	{
		if(!m_oLib.Valid())
			return false;
		if(!m_fMdbTransfer || !m_fConfigMdbDomain || !m_fCreateMdbReplicator || !m_fRegisterMdbTransfer || !m_fCleanupMdbReplication)
			return false;
		return true;
	}
示例#8
0
	bool Valid()
	{
		if(!m_oLib.Valid())
			return false;
		if(!m_fCreateMdbServer || !m_fDestroyMdbServer)
			return false;
		return true;
	}
示例#9
0
	bool Valid()
	{
		if(!m_oLib.Valid())
			return false;
		if(!m_fCreateMdbClient || !m_fDestroyMdbClient || !m_fStartMdbClient || !m_fStopMdbClient)
			return false;
		return true;
	}
示例#10
0
	bool Valid()
	{
		if(!m_oLib.Valid())
			return false;
		if(!m_fInitializeMdbStorageAttr || !m_fInitializeMdbDataSource || !m_fCleanupMdbStorage ||
				!m_fStartMdbStorage || !m_fStopMdbStorage)
			return false;
		return true;
	}
示例#11
0
	CMdbStoItf()
		:m_oLib("MdbSto")
	{
		m_fInitializeMdbStorageAttr = (FInitializeMdbStorageAttr)m_oLib.FindSymbol("InitializeMdbStorageAttr");
		m_fInitializeMdbDataSource = (FInitializeMdbDataSource)m_oLib.FindSymbol("InitializeMdbDataSource");
		m_fCleanupMdbStorage = (FCleanupMdbStorage)m_oLib.FindSymbol("CleanupMdbStorage");
		m_fStartMdbStorage = (FStartMdbStorage)m_oLib.FindSymbol("StartMdbStorage");
		m_fStopMdbStorage = (FStopMdbStorage)m_oLib.FindSymbol("StopMdbStorage");
		m_fSetStorageTrigger = (FSetStorageTrigger)m_oLib.FindSymbol("SetStorageTrigger");
		m_fSetCacheTrigger = (FSetCacheTrigger)m_oLib.FindSymbol("SetCacheTrigger");
	}
示例#12
0
CAutoLibrary::CAutoLibrary(const char* sLibDir)
{
	char sLibFile[FOCP_MAX_PATH];
#if defined(WINDOWS)// || defined(CYGWIN_NT)
	const char * sPostfix = ".dll";
	const char * sPrefix = "";
#elif defined(CYGWIN_NT)
	const char * sPostfix = ".dll";
	const char * sPrefix = "cyg";
#else
	const char * sPostfix = ".so";
	const char * sPrefix = "lib";
#endif
	CDynamicLibrary* pLibrary = NULL;
	CDiskFileSystem* pFileSystem = CDiskFileSystem::GetInstance();
	void* pDirectory = pFileSystem->OpenDirectory(sLibDir);
	if(pDirectory == NULL)
	{
		FocpLog(FOCP_LOG_ERROR, ("OpenDirectory(%s) failure", sLibDir));
		return;
	}
	//这里不能使用CFile,因为文件驱动的加载需要使用该函数,会形成死递归调用
	FILE* fp;
	CString oLibraryList, oUnLoadList;
	CString::StringCopy(sLibFile, sLibDir);
	CString::StringCatenate(sLibFile, "/load.cfg");
	pFileSystem->GetOsPathName(sLibFile);
	fp = fopen(sLibFile, "rb");
	if(fp)
	{
		fseek(fp, 0, SEEK_END);
		int32 nSize = ftell(fp);
		fseek(fp, 0, SEEK_SET);
		oLibraryList.Append('A', nSize);
		fread((void*)oLibraryList.GetStr(), 1, nSize, fp);
		fclose(fp);
	}
	CString::StringCopy(sLibFile, sLibDir);
	CString::StringCatenate(sLibFile, "/unload.cfg");
	pFileSystem->GetOsPathName(sLibFile);
	fp = fopen(sLibFile, "rb");
	if(fp)
	{
		fseek(fp, 0, SEEK_END);
		int32 nSize = ftell(fp);
		fseek(fp, 0, SEEK_SET);
		oUnLoadList.Append('A', nSize);
		fread((void*)oUnLoadList.GetStr(), 1, nSize, fp);
		fclose(fp);
	}

	bool bIsDirectory;
	const char* sFileName;
	uint32 nLen2 = CString::StringLength(sPostfix);
	uint32 nLen3 = CString::StringLength(sPrefix);
	if(!oLibraryList.Empty())
	{
		CString oFileName;
		CStringFormatter oFormatter(&oLibraryList);
		while(oFormatter.Scan("%r", &oFileName)==1)
		{
			oFileName.Trim();
			if(!oFileName.Empty())
			{
				if(!oUnLoadList.Empty())
				{
					uint32 nLen = oFileName.GetSize();
					const char* sHead = oUnLoadList.GetStr();
					char* sLib = CString::StringOfString(sHead, oFileName.GetStr(), false);
					if(sLib &&
							(sLib[nLen] == '\0' || CString::IsSpace(sLib[nLen])) &&
							(sHead == sLib || CString::IsSpace(*(sLib-1))))
						continue;
				}
				CString::StringCopy(sLibFile, sLibDir);
				CString::StringCatenate(sLibFile, "/");
				CString::StringCatenate(sLibFile, sPrefix);
				CString::StringCatenate(sLibFile, oFileName.GetStr());
				CString::StringCatenate(sLibFile, sPostfix);
				if(pLibrary == NULL)
					pLibrary = new CDynamicLibrary;
				if(pLibrary->Load(sLibFile))
				{
					m_oLibrary.Insert(m_oLibrary.GetSize(), pLibrary);
					pLibrary = NULL;
				}
			}
		}
	}
	else while( (sFileName = pFileSystem->ReadDirectory(pDirectory, bIsDirectory)) )
		{
			if(bIsDirectory)
				continue;
			uint32 nLen = CString::StringLength(sFileName);
			if(nLen <= nLen2+nLen3)
				continue;
			if(CString::StringCompare(sFileName+nLen-nLen2, sPostfix))
				continue;
			if(nLen3 && CString::StringCompare(sFileName, sPrefix, true, nLen3))
				continue;
			if(!oUnLoadList.Empty())
			{
				uint32 nLen4 = nLen-nLen2-nLen3;
				CString oSimpleFileName(sFileName+nLen3, nLen4);
				const char* sHead = oUnLoadList.GetStr();
				char* sLib = CString::StringOfString(sHead, oSimpleFileName.GetStr(), false);
				if(sLib && (sLib[nLen4] == '\0' ||
							CString::IsSpace(sLib[nLen4])) &&
						(sHead == sLib || CString::IsSpace(*(sLib-1))))
					continue;
			}
			CString::StringCopy(sLibFile, sLibDir);
			CString::StringCatenate(sLibFile, "/");
			CString::StringCatenate(sLibFile, sFileName);
			if(pLibrary == NULL)
				pLibrary = new CDynamicLibrary;
			if(pLibrary->Load(sLibFile))
			{
				m_oLibrary.Insert(m_oLibrary.GetSize(), pLibrary);
				pLibrary = NULL;
			}
		}
	pFileSystem->CloseDirectory(pDirectory);
	if(pLibrary)
		delete pLibrary;
}
示例#13
0
	CLocalMdbItf()
		:m_oLib("MdbLoc")
	{
		m_fCreateMemoryDataBase = (FCreateMemoryDataBase)m_oLib.FindSymbol("CreateMemoryDataBase");
	}
示例#14
0
	CMdbServerItf()
		:m_oLib("MdbLsn")
	{
		m_fCreateMdbServer = (FCreateMdbServer)m_oLib.FindSymbol("CreateMdbServer");
		m_fDestroyMdbServer = (FDestroyMdbServer)m_oLib.FindSymbol("DestroyMdbServer");
	}
示例#15
0
int main ( int argc, char* argv [] )
{
    // Work out the launched directory and filename
    int iLength = strlen ( argv[0] );
    char *szLaunchDirectory = static_cast < char* > ( alloca ( iLength + 1 ) );
    char *szLaunchFile = NULL;

    strncpy ( szLaunchDirectory, argv[0], iLength + 1 );

    for ( int i = 0 ; i < iLength ; i++ )
        if ( szLaunchDirectory[i] == '\\' )
            szLaunchDirectory[i] = '/';

    if ( char* cpPos = strrchr ( szLaunchDirectory, '/' ) )
    {
        *cpPos = 0;
        szLaunchFile = cpPos + 1;
    }

    if ( argc > 1 )
    {
        if ( strcmp ( argv[1], "/?" ) == 0 || strcmp ( argv[1], "--help" ) == 0 || strcmp ( argv[1], "-h" ) == 0 )
        {
            printf ( "Usage: %s [OPTION]\n\n", szLaunchFile ? szLaunchFile : "mtaserver" );
            printf ( "  -v                   Shows the program version\n" );
            printf ( "  -s                   Run server in silent mode\n" );
#ifndef WIN32
            printf ( "  -d                   Run server daemonized\n" );
#endif
            printf ( "  -t                   Run server with a simple console\n" );
            printf ( "  -f                   Run server with a standard console (Default)\n" );
            printf ( "  -n                   Disable the usage of ncurses (For screenlog)\n" );
            printf ( "  -D [PATH]            Use as base directory\n" );
            printf ( "  --config [FILE]      Alternate mtaserver.conf file\n" );
            printf ( "  --ip [ADDR]          Set IP address\n" );
            printf ( "  --port [PORT]        Set port\n" );
            printf ( "  --httpport [PORT]    Set http port\n" );
            printf ( "  --maxplayers [max]   Set maxplayers\n" );
            printf ( "  --novoice            Disable voice communication\n" );
            return 1;
        }
        else if ( strcmp ( argv[1], "--version" ) == 0 || strcmp ( argv[1], "-v" ) == 0 )
        {
            printf ( MTA_DM_FULL_STRING " v" MTA_DM_BUILDTAG_LONG "\n" );
            return 1;
        }
    }

    // If we are unable to access the core module, try changing to the directory of the launched file
    FILE* fh = fopen ( LIB_CORE, "r" );
    if ( !fh )
        chdir ( szLaunchDirectory );
    else
        fclose ( fh );

    // Load the core library
    CDynamicLibrary Core;
    if ( Core.Load ( LIB_CORE ) )
    {
        // Grab the entrypoint
        typedef int ( Main_t )( int, char* [] );
        Main_t* pfnEntryPoint = reinterpret_cast < Main_t* > ( (long long)(Core.GetProcedureAddress ( "Run" )) );
        if ( pfnEntryPoint )
        {
            // Call it and return what it returns
            return pfnEntryPoint ( argc, argv );
        }
        else
        {
            printf ( "ERROR: Bad file: %s\n", LIB_CORE );
        }
    }
    else
    {
        printf ( "ERROR: Could not load %s\n", LIB_CORE );
        printf ( "* Check installed data files.\n" );
#ifdef WIN32
        printf ( "* Check installed Microsoft Visual C++ 2008 SP1 Redistributable Package (x86).\n" );
#endif
    }

    // Wait for a key then exit
    printf ( "Press enter to continue...\n" );
    cin.get ();
    return 1;
}
示例#16
0
int main ( int argc, char* argv [] )
{
    // Work out the launched directory and filename
    int iLength = strlen ( argv[0] );
    char *szLaunchDirectory = static_cast < char* > ( alloca ( iLength + 1 ) );

    strncpy ( szLaunchDirectory, argv[0], iLength + 1 );

    for ( int i = 0 ; i < iLength ; i++ )
        if ( szLaunchDirectory[i] == '\\' )
            szLaunchDirectory[i] = '/';

    SString strLaunchFile, strLaunchDirectory;
    if ( char* cpPos = strrchr ( szLaunchDirectory, '/' ) )
    {
        *cpPos = 0;
        strLaunchFile = cpPos + 1;
        strLaunchDirectory = szLaunchDirectory;
    }
    else
    {
        strLaunchFile = szLaunchDirectory;
        strLaunchDirectory = "";
    }

    if ( argc > 1 )
    {
        if ( strcmp ( argv[1], "/?" ) == 0 || strcmp ( argv[1], "--help" ) == 0 || strcmp ( argv[1], "-h" ) == 0 )
        {
            printf ( "Usage: %s [OPTION]\n\n", *strLaunchFile );
            printf ( "  -v                   Shows the program version\n" );
            printf ( "  -s                   Run server in silent mode\n" );
#ifndef WIN32
            printf ( "  -d                   Run server daemonized\n" );
#endif
            printf ( "  -t                   Run server with a simple console\n" );
            printf ( "  -f                   Run server with a standard console (Default)\n" );
            printf ( "  -n                   Disable the usage of ncurses (For screenlog)\n" );
#ifndef WIN32
            printf ( "  -x                   Disable simplified crash reports (To allow core dumps)\n" );
            printf ( "  -q                   Do not add " LINUX_LIBS_PATH " directory to library search path\n" );
#endif
            printf ( "  -D [PATH]            Use as base directory\n" );
            printf ( "  --config [FILE]      Alternate mtaserver.conf file\n" );
            printf ( "  --ip [ADDR]          Set IP address\n" );
            printf ( "  --port [PORT]        Set port\n" );
            printf ( "  --httpport [PORT]    Set http port\n" );
            printf ( "  --maxplayers [max]   Set maxplayers\n" );
            printf ( "  --novoice            Disable voice communication\n" );
            return 1;
        }
    }

#ifdef WIN32
    if ( !IsWindowsXPSP3OrGreater() )
    {
        printf ( "This version of MTA requires Windows XP SP3 or later\n" );

        // Wait for a key then exit
        printf ( "Press enter to continue...\n" );
        cin.get ();
        return 1;
    }
#else
    HandleLinuxLibs( strLaunchDirectory, argc, argv );
#endif

    // If we are unable to access the core module, try changing to the directory of the launched file
    FILE* fh = fopen ( LIB_CORE, "r" );
    if ( !fh )
    {
        #ifdef WIN32
            wchar_t szBuffer[64000];
            GetModuleFileNameW( NULL, szBuffer, 64000 );
            PathRemoveFileSpecW ( szBuffer );
            SetCurrentDirectoryW( szBuffer );
        #else
            chdir ( strLaunchDirectory );
        #endif
    }
    else
        fclose ( fh );

    // Load the core library
    CDynamicLibrary Core;
    if ( Core.Load ( LIB_CORE ) )
    {
        // Grab the entrypoint
        typedef int ( Main_t )( int, char* [] );
        Main_t* pfnEntryPoint = reinterpret_cast < Main_t* > ( (long long)(Core.GetProcedureAddress ( "Run" )) );
        if ( pfnEntryPoint )
        {
            // Call it and return what it returns
            return pfnEntryPoint ( argc, argv );
        }
        else
        {
            printf ( "ERROR: Bad file: %s\n", LIB_CORE );
        }
    }
    else
    {
        printf ( "ERROR: Could not load %s\n", LIB_CORE );
        printf ( "* Check installed data files.\n" );
#ifdef WIN32
        printf ( "* Check installed Microsoft Visual C++ Redistributable Package (x86).\n" );
#endif
    }

    // Wait for a key then exit
    printf ( "Press enter to continue...\n" );
    cin.get ();
    return 1;
}