Ejemplo n.º 1
0
bool CLocalExtension::Load(char *error, size_t maxlength)
{
    m_pLib = g_LibSys.OpenLibrary(m_Path.c_str(), error, maxlength);

    if (m_pLib == NULL)
    {
        return false;
    }

    typedef IExtensionInterface *(*GETAPI)();
    GETAPI pfnGetAPI = NULL;

    if ((pfnGetAPI=(GETAPI)m_pLib->GetSymbolAddress("GetSMExtAPI")) == NULL)
    {
        m_pLib->CloseLibrary();
        m_pLib = NULL;
        snprintf(error, maxlength, "Unable to find extension entry point");
        return false;
    }

    m_pAPI = pfnGetAPI();

    /* Check pointer and version */
    if (!PerformAPICheck(error, maxlength))
    {
        m_pLib->CloseLibrary();
        m_pLib = NULL;
        m_pAPI = NULL;
        return false;
    }

    /* Load as MM:S */
    if (m_pAPI->IsMetamodExtension())
    {
        bool already;
        m_PlId = g_pMMPlugins->Load(m_Path.c_str(), g_PLID, already, error, maxlength);
    }

    if (!CExtension::Load(error, maxlength))
    {
        if (m_pAPI->IsMetamodExtension())
        {
            if (m_PlId)
            {
                char dummy[255];
                g_pMMPlugins->Unload(m_PlId, true, dummy, sizeof(dummy));
                m_PlId = 0;
            }
        }
        m_pLib->CloseLibrary();
        m_pLib = NULL;
        m_pAPI = NULL;
        return false;
    }

    return true;
}
Ejemplo n.º 2
0
bool CRemoteExtension::Load(char *error, size_t maxlength)
{
	if (!PerformAPICheck(error, maxlength))
	{
		m_pAPI = NULL;
		return false;
	}

	if (!CExtension::Load(error, maxlength))
	{
		m_pAPI = NULL;
		return false;
	}

	return true;
}
Ejemplo n.º 3
0
bool CLocalExtension::Load(char *error, size_t maxlength)
{
	m_pLib = libsys->OpenLibrary(m_Path.c_str(), error, maxlength);

	if (m_pLib == NULL)
	{
		return false;
	}

	typedef IExtensionInterface *(*GETAPI)();
	GETAPI pfnGetAPI = NULL;

	if ((pfnGetAPI=(GETAPI)m_pLib->GetSymbolAddress("GetSMExtAPI")) == NULL)
	{
		m_pLib->CloseLibrary();
		m_pLib = NULL;
		snprintf(error, maxlength, "Unable to find extension entry point");
		return false;
	}

	m_pAPI = pfnGetAPI();

	/* Check pointer and version */
	if (!PerformAPICheck(error, maxlength))
	{
		m_pLib->CloseLibrary();
		m_pLib = NULL;
		m_pAPI = NULL;
		return false;
	}

	/* Load as MM:S */
	if (m_pAPI->IsMetamodExtension())
	{
		bool ok;
		m_PlId = smcore.LoadMMSPlugin(m_Path.c_str(), &ok, error, maxlength);

		if (!m_PlId || !ok)
		{
			m_pLib->CloseLibrary();
			m_pLib = NULL;
			m_pAPI = NULL;
			return false;
		}
	}

	if (!CExtension::Load(error, maxlength))
	{
		if (m_pAPI->IsMetamodExtension())
		{
			if (m_PlId)
			{
				smcore.UnloadMMSPlugin(m_PlId);
				m_PlId = 0;
			}
		}
		m_pLib->CloseLibrary();
		m_pLib = NULL;
		m_pAPI = NULL;
		return false;
	}

	return true;
}