Exemplo n.º 1
0
static cell_t GetExtensionFileStatus(IPluginContext *pContext, const cell_t *params)
{
	char *str;
	pContext->LocalToString(params[1], &str);

	IExtension *pExtension = extsys->FindExtensionByFile(str);
	
	if (!pExtension)
	{
		return -2;
	}
	
	if (!pExtension->IsLoaded())
	{
		return -1;
	}

	char *error;
	pContext->LocalToString(params[2], &error);
	if (!pExtension->IsRunning(error, params[3]))
	{
		return 0;
	}

	return 1;
}
Exemplo n.º 2
0
IDBDriver *DBManager::FindOrLoadDriver(const char *name)
{
	size_t last_size = m_drivers.size();
	for (size_t i=0; i<last_size; i++)
	{
		if (strcmp(m_drivers[i]->GetIdentifier(), name) == 0)
		{
			return m_drivers[i];
		}
	}

	char filename[PLATFORM_MAX_PATH];
	g_pSM->Format(filename, sizeof(filename), "dbi.%s.ext", name);

	IExtension *pExt = g_Extensions.LoadAutoExtension(filename);
	if (!pExt || !pExt->IsLoaded() || m_drivers.size() <= last_size)
	{
		return NULL;
	}

	/* last_size is now gauranteed to be a valid index.
	 * The identifier must match the name.
	 */
	if (strcmp(m_drivers[last_size]->GetIdentifier(), name) == 0)
	{
		return m_drivers[last_size];
	}

	return NULL;
}