core/ExtensionSys.cpp
author Nicholas Hastings <skamonkey@gmail.com>
Sat Sep 10 12:08:38 2011 -0400 (2011-09-10)
changeset 3389 68d3e56f4bb7
parent 3373 c6463cdc2180
child 3402 a459183ce707
permissions -rw-r--r--
Added CheckAccess native to check cmd/override access of AdminId (bug 5083, r=fyren).
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2010 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #include <stdlib.h>
    33 #include "ExtensionSys.h"
    34 #include "LibrarySys.h"
    35 #include "ShareSys.h"
    36 #include "Logger.h"
    37 #include "sourcemm_api.h"
    38 #include "sm_srvcmds.h"
    39 #include "sm_stringutil.h"
    40 
    41 CExtensionManager g_Extensions;
    42 IdentityType_t g_ExtType;
    43 
    44 void CExtension::Initialize(const char *filename, const char *path)
    45 {
    46 	m_pAPI = NULL;
    47 	m_pIdentToken = NULL;
    48 	unload_code = 0;
    49 	m_bFullyLoaded = false;
    50 	m_File.assign(filename);
    51 	m_Path.assign(path);
    52 	char real_name[PLATFORM_MAX_PATH];
    53 	g_LibSys.GetFileFromPath(real_name, sizeof(real_name), m_Path.c_str());
    54 	m_RealFile.assign(real_name);
    55 }
    56 
    57 CRemoteExtension::CRemoteExtension(IExtensionInterface *pAPI, const char *filename, const char *path)
    58 {
    59 	Initialize(filename, path);
    60 	m_pAPI = pAPI;
    61 }
    62 
    63 #if defined METAMOD_PLAPI_VERSION
    64 #if SOURCE_ENGINE == SE_LEFT4DEAD
    65 #define GAMEFIX "2.l4d"
    66 #elif SOURCE_ENGINE == SE_LEFT4DEAD2
    67 #define GAMEFIX "2.l4d2"
    68 #elif SOURCE_ENGINE == SE_ALIENSWARM
    69 #define GAMEFIX "2.swarm"
    70 #elif SOURCE_ENGINE == SE_ORANGEBOX
    71 #define GAMEFIX "2.ep2"
    72 #elif SOURCE_ENGINE == SE_BLOODYGOODTIME
    73 #define GAMEFIX "2.bgt"
    74 #elif SOURCE_ENGINE == SE_EYE
    75 #define GAMEFIX "2.eye"
    76 #elif SOURCE_ENGINE == SE_ORANGEBOXVALVE
    77 #define GAMEFIX "2.ep2v"
    78 #elif SOURCE_ENGINE == SE_DARKMESSIAH
    79 #define GAMEFIX "2.darkm"
    80 #else
    81 #define GAMEFIX "2.ep1"
    82 #endif //(SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
    83 #else  //METAMOD_PLAPI_VERSION
    84 #define GAMEFIX "1.ep1"
    85 #endif //METAMOD_PLAPI_VERSION
    86 
    87 CLocalExtension::CLocalExtension(const char *filename)
    88 {
    89 	m_PlId = 0;
    90 	m_pLib = NULL;
    91 
    92 	char path[PLATFORM_MAX_PATH];
    93 
    94 	/* Special case for new bintools binary */
    95 	if (strcmp(filename, "bintools.ext") == 0)
    96 	{
    97 		goto normal;
    98 	}
    99 
   100 	/* Zeroth, see if there is an engine specific build in the new place. */
   101 	g_SourceMod.BuildPath(Path_SM,
   102 		path,
   103 		PLATFORM_MAX_PATH,
   104 		"extensions/%s." GAMEFIX "." PLATFORM_LIB_EXT,
   105 		filename);
   106 
   107 	if (g_LibSys.IsPathFile(path))
   108 	{
   109 		goto found;
   110 	}
   111 
   112 	/* First see if there is an engine specific build! */
   113 	g_SourceMod.BuildPath(Path_SM, 
   114 		path, 
   115 		PLATFORM_MAX_PATH,
   116 		"extensions/auto." GAMEFIX "/%s." PLATFORM_LIB_EXT,
   117 		filename);
   118 
   119 normal:
   120 	/* Try the "normal" version */
   121 	if (!g_LibSys.IsPathFile(path))
   122 	{
   123 		g_SourceMod.BuildPath(Path_SM,
   124 			path,
   125 			PLATFORM_MAX_PATH,
   126 			"extensions/%s." PLATFORM_LIB_EXT,
   127 			filename);
   128 	}
   129 
   130 found:
   131 	Initialize(filename, path);
   132 }
   133 
   134 bool CRemoteExtension::Load(char *error, size_t maxlength)
   135 {
   136 	if (!PerformAPICheck(error, maxlength))
   137 	{
   138 		m_pAPI = NULL;
   139 		return false;
   140 	}
   141 
   142 	if (!CExtension::Load(error, maxlength))
   143 	{
   144 		m_pAPI = NULL;
   145 		return false;
   146 	}
   147 
   148 	return true;
   149 }
   150 
   151 bool CLocalExtension::Load(char *error, size_t maxlength)
   152 {
   153 	m_pLib = g_LibSys.OpenLibrary(m_Path.c_str(), error, maxlength);
   154 
   155 	if (m_pLib == NULL)
   156 	{
   157 		return false;
   158 	}
   159 
   160 	typedef IExtensionInterface *(*GETAPI)();
   161 	GETAPI pfnGetAPI = NULL;
   162 
   163 	if ((pfnGetAPI=(GETAPI)m_pLib->GetSymbolAddress("GetSMExtAPI")) == NULL)
   164 	{
   165 		m_pLib->CloseLibrary();
   166 		m_pLib = NULL;
   167 		snprintf(error, maxlength, "Unable to find extension entry point");
   168 		return false;
   169 	}
   170 
   171 	m_pAPI = pfnGetAPI();
   172 
   173 	/* Check pointer and version */
   174 	if (!PerformAPICheck(error, maxlength))
   175 	{
   176 		m_pLib->CloseLibrary();
   177 		m_pLib = NULL;
   178 		m_pAPI = NULL;
   179 		return false;
   180 	}
   181 
   182 	/* Load as MM:S */
   183 	if (m_pAPI->IsMetamodExtension())
   184 	{
   185 		bool already;
   186 		m_PlId = g_pMMPlugins->Load(m_Path.c_str(), g_PLID, already, error, maxlength);
   187 
   188 		// Check the plugin didn't refuse load
   189 		Pl_Status status;
   190 		
   191 #ifndef METAMOD_PLAPI_VERSION
   192 		const char *file;
   193 		PluginId source;
   194 #endif
   195 		
   196 		if (!m_PlId || (
   197 #ifndef METAMOD_PLAPI_VERSION
   198 			g_pMMPlugins->Query(m_PlId, file, status, source)
   199 #else
   200 			g_pMMPlugins->Query(m_PlId, NULL, &status, NULL)
   201 #endif			
   202 			&& status < Pl_Paused))
   203 		{
   204 			m_pLib->CloseLibrary();
   205 			m_pLib = NULL;
   206 			m_pAPI = NULL;
   207 			return false;
   208 		}
   209 	}
   210 
   211 	if (!CExtension::Load(error, maxlength))
   212 	{
   213 		if (m_pAPI->IsMetamodExtension())
   214 		{
   215 			if (m_PlId)
   216 			{
   217 				char dummy[255];
   218 				g_pMMPlugins->Unload(m_PlId, true, dummy, sizeof(dummy));
   219 				m_PlId = 0;
   220 			}
   221 		}
   222 		m_pLib->CloseLibrary();
   223 		m_pLib = NULL;
   224 		m_pAPI = NULL;
   225 		return false;
   226 	}
   227 
   228 	return true;
   229 }
   230 
   231 void CRemoteExtension::Unload()
   232 {
   233 }
   234 
   235 void CLocalExtension::Unload()
   236 {
   237 	if (m_pAPI != NULL && m_PlId)
   238 	{
   239 		char temp_buffer[255];
   240 		g_pMMPlugins->Unload(m_PlId, true, temp_buffer, sizeof(temp_buffer));
   241 		m_PlId = 0;
   242 	}
   243 
   244 	if (m_pLib != NULL)
   245 	{
   246 		m_pLib->CloseLibrary();
   247 		m_pLib = NULL;
   248 	}
   249 }
   250 
   251 bool CRemoteExtension::Reload(char *error, size_t maxlength)
   252 {
   253 	snprintf(error, maxlength, "Remote extensions do not support reloading");
   254 	return false;
   255 }
   256 
   257 bool CLocalExtension::Reload(char *error, size_t maxlength)
   258 {
   259 	if (m_pLib == NULL) // FIXME: just load it instead?
   260 		return false;
   261 	
   262 	m_pAPI->OnExtensionUnload();
   263 	Unload();
   264 	
   265 	return Load(error, maxlength);
   266 }
   267 
   268 bool CRemoteExtension::IsExternal()
   269 {
   270 	return true;
   271 }
   272 
   273 bool CLocalExtension::IsExternal()
   274 {
   275 	return false;
   276 }
   277 
   278 CExtension::~CExtension()
   279 {
   280 	DestroyIdentity();
   281 }
   282 
   283 bool CExtension::PerformAPICheck(char *error, size_t maxlength)
   284 {
   285 	if (!m_pAPI)
   286 	{
   287 		snprintf(error, maxlength, "No IExtensionInterface instance provided");
   288 		return false;
   289 	}
   290 	
   291 	if (m_pAPI->GetExtensionVersion() > SMINTERFACE_EXTENSIONAPI_VERSION)
   292 	{
   293 		snprintf(error, maxlength, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
   294 		return false;
   295 	}
   296 
   297 	return true;
   298 }
   299 
   300 bool CExtension::Load(char *error, size_t maxlength)
   301 {
   302 	CreateIdentity();
   303 	if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !g_SourceMod.IsMapLoading()))
   304 	{
   305 		DestroyIdentity();
   306 		return false;
   307 	}
   308 	else
   309 	{
   310 		/* Check if we're past load time */
   311 		if (!g_SourceMod.IsMapLoading())
   312 		{
   313 			m_pAPI->OnExtensionsAllLoaded();
   314 		}
   315 	}
   316 
   317 	return true;
   318 }
   319 
   320 void CExtension::CreateIdentity()
   321 {
   322 	if (m_pIdentToken != NULL)
   323 	{
   324 		return;
   325 	}
   326 
   327 	m_pIdentToken = g_ShareSys.CreateIdentity(g_ExtType, this);
   328 }
   329 
   330 void CExtension::DestroyIdentity()
   331 {
   332 	if (m_pIdentToken == NULL)
   333 	{
   334 		return;
   335 	}
   336 
   337 	g_ShareSys.DestroyIdentity(m_pIdentToken);
   338 	m_pIdentToken = NULL;
   339 }
   340 
   341 void CExtension::MarkAllLoaded()
   342 {
   343 	assert(m_bFullyLoaded == false);
   344 	if (!m_bFullyLoaded)
   345 	{
   346 		m_bFullyLoaded = true;
   347 		m_pAPI->OnExtensionsAllLoaded();
   348 	}
   349 }
   350 
   351 void CExtension::AddPlugin(CPlugin *pPlugin)
   352 {
   353 	/* Unfortunately we have to do this :( */
   354 	if (m_Dependents.find(pPlugin) != m_Dependents.end())
   355 	{
   356 		m_Dependents.push_back(pPlugin);
   357 	}
   358 }
   359 
   360 void CExtension::SetError(const char *error)
   361 {
   362 	m_Error.assign(error);
   363 }
   364 
   365 IExtensionInterface *CExtension::GetAPI()
   366 {
   367 	return m_pAPI;
   368 }
   369 
   370 const char *CExtension::GetFilename()
   371 {
   372 	return m_RealFile.c_str();
   373 }
   374 
   375 IdentityToken_t *CExtension::GetIdentity()
   376 {
   377 	return m_pIdentToken;
   378 }
   379 
   380 bool CRemoteExtension::IsLoaded()
   381 {
   382 	return (m_pAPI != NULL);
   383 }
   384 
   385 bool CLocalExtension::IsLoaded()
   386 {
   387 	return (m_pLib != NULL);
   388 }
   389 
   390 void CExtension::AddDependency(const IfaceInfo *pInfo)
   391 {
   392 	if (m_Deps.find(*pInfo) == m_Deps.end())
   393 	{
   394 		m_Deps.push_back(*pInfo);
   395 	}
   396 }
   397 
   398 bool operator ==(const IfaceInfo &i1, const IfaceInfo &i2)
   399 {
   400 	return (i1.iface == i2.iface) && (i1.owner == i2.owner);
   401 }
   402 
   403 void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
   404 {
   405 	IfaceInfo info;
   406 	info.iface = iface;
   407 	info.owner = pOther;
   408 
   409 	List<IfaceInfo>::iterator iter;
   410 	for (iter = m_ChildDeps.begin();
   411 		 iter != m_ChildDeps.end();
   412 		 iter++)
   413 	{
   414 		IfaceInfo &other = (*iter);
   415 		if (other == info)
   416 		{
   417 			return;
   418 		}
   419 	}
   420 
   421 	m_ChildDeps.push_back(info);
   422 }
   423 
   424 ITERATOR *CExtension::FindFirstDependency(IExtension **pOwner, SMInterface **pInterface)
   425 {
   426 	List<IfaceInfo>::iterator iter = m_Deps.begin();
   427 
   428 	if (iter == m_Deps.end())
   429 	{
   430 		return NULL;
   431 	}
   432 
   433 	if (pOwner)
   434 	{
   435 		*pOwner = (*iter).owner;
   436 	}
   437 	if (pInterface)
   438 	{
   439 		*pInterface = (*iter).iface;
   440 	}
   441 
   442 	List<IfaceInfo>::iterator *pIter = new List<IfaceInfo>::iterator(iter);
   443 
   444 	return (ITERATOR *)pIter;
   445 }
   446 
   447 bool CExtension::FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface)
   448 {
   449 	List<IfaceInfo>::iterator *pIter = (List<IfaceInfo>::iterator *)iter;
   450 	List<IfaceInfo>::iterator _iter;
   451 
   452 	if (_iter == m_Deps.end())
   453 	{
   454 		return false;
   455 	}
   456 
   457 	_iter++;
   458 
   459 	if (pOwner)
   460 	{
   461 		*pOwner = (*_iter).owner;
   462 	}
   463 	if (pInterface)
   464 	{
   465 		*pInterface = (*_iter).iface;
   466 	}
   467 
   468 	*pIter = _iter;
   469 
   470 	if (_iter == m_Deps.end())
   471 	{
   472 		return false;
   473 	}
   474 
   475 	return true;
   476 }
   477 
   478 void CExtension::FreeDependencyIterator(ITERATOR *iter)
   479 {
   480 	List<IfaceInfo>::iterator *pIter = (List<IfaceInfo>::iterator *)iter;
   481 
   482 	delete pIter;
   483 }
   484 
   485 void CExtension::AddInterface(SMInterface *pInterface)
   486 {
   487 	m_Interfaces.push_back(pInterface);
   488 }
   489 
   490 bool CExtension::IsRunning(char *error, size_t maxlength)
   491 {
   492 	if (!IsLoaded())
   493 	{
   494 		if (error)
   495 		{
   496 			snprintf(error, maxlength, "%s", m_Error.c_str());
   497 		}
   498 		return false;
   499 	}
   500 
   501 	return m_pAPI->QueryRunning(error, maxlength);
   502 }
   503 
   504 void CExtension::AddLibrary(const char *library)
   505 {
   506 	m_Libraries.push_back(library);
   507 }
   508 
   509 /*********************
   510  * EXTENSION MANAGER *
   511  *********************/
   512 
   513 void CExtensionManager::OnSourceModAllInitialized()
   514 {
   515 	g_ExtType = g_ShareSys.CreateIdentType("EXTENSION");
   516 	g_PluginSys.AddPluginsListener(this);
   517 	g_RootMenu.AddRootConsoleCommand("exts", "Manage extensions", this);
   518 	g_ShareSys.AddInterface(NULL, this);
   519 }
   520 
   521 void CExtensionManager::OnSourceModShutdown()
   522 {
   523 	g_RootMenu.RemoveRootConsoleCommand("exts", this);
   524 	g_ShareSys.DestroyIdentType(g_ExtType);
   525 }
   526 
   527 void CExtensionManager::Shutdown()
   528 {
   529 	List<CExtension *>::iterator iter;
   530 
   531 	while ((iter = m_Libs.begin()) != m_Libs.end())
   532 	{
   533 		UnloadExtension((*iter));
   534 	}
   535 }
   536 
   537 void CExtensionManager::TryAutoload()
   538 {
   539 	char path[PLATFORM_MAX_PATH];
   540 
   541 	g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "extensions");
   542 
   543 	IDirectory *pDir = g_LibSys.OpenDirectory(path);
   544 	if (!pDir)
   545 	{
   546 		return;
   547 	}
   548 
   549 	const char *lfile;
   550 	size_t len;
   551 	while (pDir->MoreFiles())
   552 	{
   553 		if (pDir->IsEntryDirectory())
   554 		{
   555 			pDir->NextEntry();
   556 			continue;
   557 		}
   558 
   559 		lfile = pDir->GetEntryName();
   560 		len = strlen(lfile);
   561 		if (len <= 9) /* size of ".autoload" */
   562 		{
   563 			pDir->NextEntry();
   564 			continue;
   565 		}
   566 
   567 		if (strcmp(&lfile[len - 9], ".autoload") != 0)
   568 		{
   569 			pDir->NextEntry();
   570 			continue;
   571 		}
   572 
   573 		char file[PLATFORM_MAX_PATH];
   574 		len = UTIL_Format(file, sizeof(file), "%s", lfile);
   575 		strcpy(&file[len - 9], ".ext");
   576 
   577 		LoadAutoExtension(file);
   578 		
   579 		pDir->NextEntry();
   580 	}
   581 }
   582 
   583 IExtension *CExtensionManager::LoadAutoExtension(const char *path)
   584 {
   585 	/* Remove platform extension if it's there. Compat hack. */
   586 	const char *ext = g_LibSys.GetFileExtension(path);
   587 	if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
   588 	{
   589 		char path2[PLATFORM_MAX_PATH];
   590 		UTIL_Format(path2, sizeof(path2), "%s", path);
   591 		path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
   592 		return LoadAutoExtension(path2);
   593 	}
   594 
   595 	IExtension *pAlready;
   596 	if ((pAlready=FindExtensionByFile(path)) != NULL)
   597 	{
   598 		return pAlready;
   599 	}
   600 
   601 	char error[256];
   602 	CExtension *p = new CLocalExtension(path);
   603 
   604 	/* We put us in the list beforehand so extensions that check for each other
   605 	 * won't recursively load each other.
   606 	 */
   607 	m_Libs.push_back(p);
   608 
   609 	if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
   610 	{
   611 		g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
   612 		p->SetError(error);
   613 	}
   614 
   615 	return p;
   616 }
   617 
   618 IExtension *CExtensionManager::FindExtensionByFile(const char *file)
   619 {
   620 	List<CExtension *>::iterator iter;
   621 	CExtension *pExt;
   622 
   623 	/* Chomp off the path */
   624 	char lookup[PLATFORM_MAX_PATH];
   625 	g_LibSys.GetFileFromPath(lookup, sizeof(lookup), file);
   626 
   627 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   628 	{
   629 		pExt = (*iter);
   630 		if (pExt->IsSameFile(lookup))
   631 		{
   632 			return pExt;
   633 		}
   634 	}
   635 
   636 	return NULL;
   637 }
   638 
   639 IExtension *CExtensionManager::FindExtensionByName(const char *ext)
   640 {
   641 	List<CExtension *>::iterator iter;
   642 	CExtension *pExt;
   643 	IExtensionInterface *pAPI;
   644 	const char *name;
   645 
   646 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   647 	{
   648 		pExt = (*iter);
   649 		if (!pExt->IsLoaded())
   650 		{
   651 			continue;
   652 		}
   653 		if ((pAPI = pExt->GetAPI()) == NULL)
   654 		{
   655 			continue;
   656 		}
   657 		name = pAPI->GetExtensionName();
   658 		if (!name)
   659 		{
   660 			continue;
   661 		}
   662 		if (strcmp(name, ext) == 0)
   663 		{
   664 			return pExt;
   665 		}
   666 	}
   667 
   668 	return NULL;
   669 }
   670 
   671 IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
   672 {
   673 	/* Remove platform extension if it's there. Compat hack. */
   674 	const char *ext = g_LibSys.GetFileExtension(file);
   675 	if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
   676 	{
   677 		char path2[PLATFORM_MAX_PATH];
   678 		UTIL_Format(path2, sizeof(path2), "%s", file);
   679 		path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
   680 		return LoadExtension(path2, error, maxlength);
   681 	}
   682 
   683 	IExtension *pAlready;
   684 	if ((pAlready=FindExtensionByFile(file)) != NULL)
   685 	{
   686 		return pAlready;
   687 	}
   688 
   689 	CExtension *pExt = new CLocalExtension(file);
   690 
   691 	if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
   692 	{
   693 		pExt->Unload();
   694 		delete pExt;
   695 		return NULL;
   696 	}
   697 
   698 	/* :TODO: do QueryRunning check if the map is loaded */
   699 
   700 	m_Libs.push_back(pExt);
   701 
   702 	return pExt;
   703 }
   704 
   705 void CExtensionManager::BindDependency(IExtension *pRequester, IfaceInfo *pInfo)
   706 {
   707 	CExtension *pExt = (CExtension *)pRequester;
   708 	CExtension *pOwner = (CExtension *)pInfo->owner;
   709 
   710 	pExt->AddDependency(pInfo);
   711 
   712 	IExtensionInterface *pAPI = pExt->GetAPI();
   713 	if (pAPI && !pAPI->QueryInterfaceDrop(pInfo->iface))
   714 	{
   715 		pOwner->AddChildDependent(pExt, pInfo->iface);
   716 	}
   717 }
   718 
   719 void CExtensionManager::AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface)
   720 {
   721 	CExtension *pExt = (CExtension *)ext;
   722 	CExtension *pOwner = GetExtensionFromIdent(other);
   723 
   724 	IfaceInfo info;
   725 
   726 	info.iface = (SMInterface *)iface;
   727 	info.owner = pOwner;
   728 
   729 	pExt->AddDependency(&info);
   730 	pOwner->AddChildDependent(pExt, (SMInterface *)iface);
   731 }
   732 
   733 void CExtensionManager::AddInterface(IExtension *pOwner, SMInterface *pInterface)
   734 {
   735 	CExtension *pExt = (CExtension *)pOwner;
   736 
   737 	pExt->AddInterface(pInterface);
   738 }
   739 
   740 void CExtensionManager::BindChildPlugin( IExtension *pParent, CPlugin *pPlugin )
   741 {
   742 	CExtension *pExt = (CExtension *)pParent;
   743 
   744 	pExt->AddPlugin(pPlugin);
   745 }
   746 
   747 void CExtensionManager::OnPluginDestroyed(IPlugin *plugin)
   748 {
   749 	List<CExtension *>::iterator iter;
   750 
   751 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   752 	{
   753 		(*iter)->DropRefsTo((CPlugin *)plugin);
   754 	}
   755 }
   756 
   757 CExtension *CExtensionManager::FindByOrder(unsigned int num)
   758 {
   759 	if (num < 1 || num > m_Libs.size())
   760 	{
   761 		return NULL;
   762 	}
   763 
   764 	List<CExtension *>::iterator iter = m_Libs.begin();
   765 
   766 	while (iter != m_Libs.end())
   767 	{
   768 		if (--num == 0)
   769 		{
   770 			return (*iter);
   771 		}
   772 		iter++;
   773 	}
   774 
   775 	return NULL;
   776 }
   777 
   778 bool CExtensionManager::UnloadExtension(IExtension *_pExt)
   779 {
   780 	if (!_pExt)
   781 	{
   782 		return false;
   783 	}
   784 
   785 	CExtension *pExt = (CExtension *)_pExt;
   786 
   787 	if (m_Libs.find(pExt) == m_Libs.end())
   788 	{
   789 		return false;
   790 	}
   791 
   792 	/* First remove us from internal lists */
   793 	g_ShareSys.RemoveInterfaces(_pExt);
   794 	m_Libs.remove(pExt);
   795 
   796 	List<CExtension *> UnloadQueue;
   797 
   798 	/* Handle dependencies */
   799 	if (pExt->IsLoaded())
   800 	{
   801 		/* Unload any dependent plugins */
   802 		List<CPlugin *>::iterator p_iter = pExt->m_Dependents.begin();
   803 		while (p_iter != pExt->m_Dependents.end())
   804 		{
   805 			/* We have to manually unlink ourselves here, since we're no longer being managed */
   806 			g_PluginSys.UnloadPlugin((*p_iter));
   807 			p_iter = pExt->m_Dependents.erase(p_iter);
   808 		}
   809 
   810 		List<String>::iterator s_iter;
   811 		for (s_iter = pExt->m_Libraries.begin();
   812 			 s_iter != pExt->m_Libraries.end();
   813 			 s_iter++)
   814 		{
   815 			g_PluginSys.OnLibraryAction((*s_iter).c_str(), false, true);
   816 		}
   817 
   818 		/* Notify and/or unload all dependencies */
   819 		List<CExtension *>::iterator c_iter;
   820 		CExtension *pDep;
   821 		IExtensionInterface *pAPI;
   822 		for (c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++)
   823 		{
   824 			pDep = (*c_iter);
   825 			if ((pAPI=pDep->GetAPI()) == NULL)
   826 			{
   827 				continue;
   828 			}
   829 			if (pDep == pExt)
   830 			{
   831 				continue;
   832 			}
   833 			/* Now, get its dependency list */
   834 			bool dropped = false;
   835 			List<IfaceInfo>::iterator i_iter = pDep->m_Deps.begin();
   836 			while (i_iter != pDep->m_Deps.end())
   837 			{
   838 				if ((*i_iter).owner == _pExt)
   839 				{
   840 					if (!pAPI->QueryInterfaceDrop((*i_iter).iface))
   841 					{
   842 						if (!dropped)
   843 						{
   844 							dropped = true;
   845 							UnloadQueue.push_back(pDep);
   846 						}
   847 					}
   848 					pAPI->NotifyInterfaceDrop((*i_iter).iface);
   849 					i_iter = pDep->m_Deps.erase(i_iter);
   850 				}
   851 				else
   852 				{
   853 					i_iter++;
   854 				}
   855 			}
   856 			/* Flush out any back references to this plugin */
   857 			i_iter = pDep->m_ChildDeps.begin();
   858 			while (i_iter != pDep->m_ChildDeps.end())
   859 			{
   860 				if ((*i_iter).owner == pExt)
   861 				{
   862 					i_iter = pDep->m_ChildDeps.erase(i_iter);
   863 				}
   864 				else
   865 				{
   866 					i_iter++;
   867 				}
   868 			}
   869 		}
   870 
   871 		/* Unbind our natives from Core */
   872 		pExt->DropEverything();
   873 	}
   874 
   875 	IdentityToken_t *pIdentity;
   876 	if ((pIdentity = pExt->GetIdentity()) != NULL)
   877 	{
   878 		SMGlobalClass *glob = SMGlobalClass::head;
   879 		while (glob)
   880 		{
   881 			glob->OnSourceModIdentityDropped(pIdentity);
   882 			glob = glob->m_pGlobalClassNext;
   883 		}
   884 	}
   885 
   886 	/* Tell it to unload */
   887 	if (pExt->IsLoaded())
   888 	{
   889 		IExtensionInterface *pAPI = pExt->GetAPI();
   890 		pAPI->OnExtensionUnload();
   891 	}
   892 
   893 	pExt->Unload();
   894 	delete pExt;
   895 
   896 	List<CExtension *>::iterator iter;
   897 	for (iter=UnloadQueue.begin(); iter!=UnloadQueue.end(); iter++)
   898 	{
   899 		/* NOTE: This is safe because the unload function backs out of anything not present */
   900 		UnloadExtension((*iter));
   901 	}
   902 
   903 	return true;
   904 }
   905 
   906 void CExtensionManager::MarkAllLoaded()
   907 {
   908 	List<CExtension *>::iterator iter;
   909 	CExtension *pExt;
   910 
   911 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   912 	{
   913 		pExt = (*iter);
   914 		if (!pExt->IsLoaded())
   915 		{
   916 			continue;
   917 		}
   918 		if (pExt->m_bFullyLoaded)
   919 		{
   920 			continue;
   921 		}
   922 		pExt->MarkAllLoaded();
   923 	}
   924 }
   925 
   926 void CExtensionManager::AddDependency(IExtension *pSource, const char *file, bool required, bool autoload)
   927 {
   928 	/* This function doesn't really need to do anything now.  We make sure the 
   929 	 * other extension is loaded, but handling of dependencies is really done 
   930 	 * by the interface fetcher.
   931 	 */
   932 	if (required || autoload)
   933 	{
   934 		LoadAutoExtension(file);
   935 	}
   936 }
   937 
   938 void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
   939 {
   940 	int argcount = command.ArgC();
   941 	if (argcount >= 3)
   942 	{
   943 		const char *cmd = command.Arg(2);
   944 		if (strcmp(cmd, "list") == 0)
   945 		{
   946 			List<CExtension *>::iterator iter;
   947 			CExtension *pExt;
   948 			unsigned int num = 1;
   949 			switch (m_Libs.size())
   950 			{
   951 			case 1:
   952 				{
   953 					g_RootMenu.ConsolePrint("[SM] Displaying 1 extension:");
   954 					break;
   955 				}
   956 			case 0:
   957 				{
   958 					g_RootMenu.ConsolePrint("[SM] No extensions are loaded.");
   959 					break;
   960 				}
   961 			default:
   962 				{
   963 					g_RootMenu.ConsolePrint("[SM] Displaying %d extensions:", m_Libs.size());
   964 					break;
   965 				}
   966 			}
   967 			for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++,num++)
   968 			{
   969 				pExt = (*iter);
   970 				if (pExt->IsLoaded())
   971 				{
   972 					char error[255];
   973 					if (!pExt->IsRunning(error, sizeof(error)))
   974 					{
   975 						g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), error);
   976 					}
   977 					else
   978 					{
   979 						IExtensionInterface *pAPI = pExt->GetAPI();
   980 						const char *name = pAPI->GetExtensionName();
   981 						const char *version = pAPI->GetExtensionVerString();
   982 						const char *descr = pAPI->GetExtensionDescription();
   983 						g_RootMenu.ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
   984 					}
   985 				} else {
   986 					g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
   987 				}
   988 			}
   989 			return;
   990 		}
   991 		else if (strcmp(cmd, "load") == 0)
   992 		{
   993 			if (argcount < 4)
   994 			{
   995 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts load <file>");
   996 				return;
   997 			}
   998 
   999 			const char *filename = command.Arg(3);
  1000 			char path[PLATFORM_MAX_PATH];
  1001 			char error[256];
  1002 
  1003 			UTIL_Format(path, sizeof(path), "%s%s%s", filename, !strstr(filename, ".ext") ? ".ext" : "",
  1004 				!strstr(filename, "." PLATFORM_LIB_EXT) ? "." PLATFORM_LIB_EXT : "");
  1005 			
  1006 			if (FindExtensionByFile(path) != NULL)
  1007 			{
  1008 				g_RootMenu.ConsolePrint("[SM] Extension %s is already loaded.", path);
  1009 				return;
  1010 			}
  1011 			
  1012 			if (LoadExtension(path, error, sizeof(error)))
  1013 			{
  1014 				g_RootMenu.ConsolePrint("[SM] Loaded extension %s successfully.", path);
  1015 			} else
  1016 			{
  1017 				g_RootMenu.ConsolePrint("[SM] Extension %s failed to load: %s", path, error);
  1018 			}
  1019 			
  1020 			return;
  1021 		}
  1022 		else if (strcmp(cmd, "info") == 0)
  1023 		{
  1024 			if (argcount < 4)
  1025 			{
  1026 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
  1027 				return;
  1028 			}
  1029 
  1030 			const char *sId = command.Arg(3);
  1031 			unsigned int id = atoi(sId);
  1032 			if (id <= 0)
  1033 			{
  1034 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>");
  1035 				return;
  1036 			}
  1037 
  1038 			if (m_Libs.size() == 0)
  1039 			{
  1040 				g_RootMenu.ConsolePrint("[SM] No extensions are loaded.");
  1041 				return;
  1042 			}
  1043 
  1044 			if (id > m_Libs.size())
  1045 			{
  1046 				g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id);
  1047 				return;
  1048 			}
  1049 
  1050 			List<CExtension *>::iterator iter = m_Libs.begin();
  1051 			CExtension *pExt = NULL;
  1052 			while (iter != m_Libs.end())
  1053 			{
  1054 				if (--id == 0)
  1055 				{
  1056 					pExt = (*iter);
  1057 					break;
  1058 				}
  1059 				iter++;
  1060 			}
  1061 			/* This should never happen */
  1062 			if (!pExt)
  1063 			{
  1064 				g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id);
  1065 				return;
  1066 			}
  1067 
  1068 			if (!pExt->IsLoaded())
  1069 			{
  1070 				g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
  1071 				g_RootMenu.ConsolePrint(" Loaded: No (%s)", pExt->m_Error.c_str());
  1072 			}
  1073 			else
  1074 			{
  1075 				char error[255];
  1076 				if (!pExt->IsRunning(error, sizeof(error)))
  1077 				{
  1078 					g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
  1079 					g_RootMenu.ConsolePrint(" Loaded: Yes");
  1080 					g_RootMenu.ConsolePrint(" Running: No (%s)", error);
  1081 				}
  1082 				else
  1083 				{
  1084 					IExtensionInterface *pAPI = pExt->GetAPI();
  1085 					g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename());
  1086 					g_RootMenu.ConsolePrint(" Loaded: Yes (version %s)", pAPI->GetExtensionVerString());
  1087 					g_RootMenu.ConsolePrint(" Name: %s (%s)", pAPI->GetExtensionName(), pAPI->GetExtensionDescription());
  1088 					g_RootMenu.ConsolePrint(" Author: %s (%s)", pAPI->GetExtensionAuthor(), pAPI->GetExtensionURL());
  1089 					g_RootMenu.ConsolePrint(" Binary info: API version %d (compiled %s)", pAPI->GetExtensionVersion(), pAPI->GetExtensionDateString());
  1090 
  1091 					if (pExt->IsExternal())
  1092 					{
  1093 						g_RootMenu.ConsolePrint(" Method: Loaded by Metamod:Source, attached to SourceMod");
  1094 					}
  1095 					else if (pAPI->IsMetamodExtension())
  1096 					{
  1097 						g_RootMenu.ConsolePrint(" Method: Loaded by SourceMod, attached to Metamod:Source");
  1098 					}
  1099 					else
  1100 					{
  1101 						g_RootMenu.ConsolePrint(" Method: Loaded by SourceMod");
  1102 					}
  1103 				}
  1104 			}
  1105 			return;
  1106 		}
  1107 		else if (strcmp(cmd, "unload") == 0)
  1108 		{
  1109 			if (argcount < 4)
  1110 			{
  1111 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts unload <#> [code]");
  1112 				return;
  1113 			}
  1114 
  1115 			const char *arg = command.Arg(3);
  1116 			unsigned int num = atoi(arg);
  1117 			CExtension *pExt = FindByOrder(num);
  1118 
  1119 			if (!pExt)
  1120 			{
  1121 				g_RootMenu.ConsolePrint("[SM] Extension number %d was not found.", num);
  1122 				return;
  1123 			}
  1124 
  1125 			if (argcount > 4 && pExt->unload_code)
  1126 			{
  1127 				const char *unload = command.Arg(4);
  1128 				if (pExt->unload_code == (unsigned)atoi(unload))
  1129 				{
  1130 					char filename[PLATFORM_MAX_PATH];
  1131 					snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
  1132 					UnloadExtension(pExt);
  1133 					g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename);
  1134 				}
  1135 				else
  1136 				{
  1137 					g_RootMenu.ConsolePrint("[SM] Please try again, the correct unload code is \"%d\"", pExt->unload_code);
  1138 				}
  1139 				return;
  1140 			}
  1141 
  1142 			if (!pExt->IsLoaded() 
  1143 				|| (!pExt->m_ChildDeps.size() && !pExt->m_Dependents.size()))
  1144 			{
  1145 				char filename[PLATFORM_MAX_PATH];
  1146 				snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
  1147 				UnloadExtension(pExt);
  1148 				g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename);
  1149 				return;
  1150 			}
  1151 			else
  1152 			{
  1153 				List<CPlugin *> plugins;
  1154 				if (pExt->m_ChildDeps.size())
  1155 				{
  1156 					g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following extensions: ", pExt->GetFilename());
  1157 					List<CExtension *>::iterator iter;
  1158 					CExtension *pOther;
  1159 					/* Get list of all extensions */
  1160 					for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
  1161 					{
  1162 						List<IfaceInfo>::iterator i_iter;
  1163 						pOther = (*iter);
  1164 						if (!pOther->IsLoaded() || pOther == pExt)
  1165 						{
  1166 							continue;
  1167 						}
  1168 						/* Get their dependencies */
  1169 						for (i_iter=pOther->m_Deps.begin();
  1170 							 i_iter!=pOther->m_Deps.end();
  1171 							 i_iter++)
  1172 						{
  1173 							/* Is this dependency to us? */
  1174 							if ((*i_iter).owner != pExt)
  1175 							{
  1176 								continue;
  1177 							}
  1178 							/* Will our dependent care? */
  1179 							if (!pExt->GetAPI()->QueryInterfaceDrop((*i_iter).iface))
  1180 							{
  1181 								g_RootMenu.ConsolePrint(" -> %s", pExt->GetFilename());
  1182 								/* Add to plugin unload list */
  1183 								List<CPlugin *>::iterator p_iter;
  1184 								for (p_iter=pOther->m_Dependents.begin();
  1185 									 p_iter!=pOther->m_Dependents.end();
  1186 									 p_iter++)
  1187 								{
  1188 									if (plugins.find((*p_iter)) == plugins.end())
  1189 									{
  1190 										plugins.push_back((*p_iter));
  1191 									}
  1192 								}
  1193 							}
  1194 						}
  1195 					}
  1196 				}
  1197 				if (pExt->m_Dependents.size())
  1198 				{
  1199 					g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following plugins: ", pExt->GetFilename());
  1200 					List<CPlugin *>::iterator iter;
  1201 					CPlugin *pPlugin;
  1202 					for (iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++)
  1203 					{
  1204 						pPlugin = (*iter);
  1205 						if (plugins.find(pPlugin) == plugins.end())
  1206 						{
  1207 							plugins.push_back(pPlugin);
  1208 						}
  1209 					}
  1210 					for (iter = plugins.begin(); iter != plugins.end(); iter++)
  1211 					{
  1212 						pPlugin = (*iter);
  1213 						g_RootMenu.ConsolePrint(" -> %s", pPlugin->GetFilename());
  1214 					}
  1215 				}
  1216 				srand(static_cast<int>(time(NULL)));
  1217 				pExt->unload_code = (rand() % 877) + 123;	//123 to 999
  1218 				g_RootMenu.ConsolePrint("[SM] To verify unloading %s, please use the following: ", pExt->GetFilename());
  1219 				g_RootMenu.ConsolePrint("[SM] sm exts unload %d %d", num, pExt->unload_code);
  1220 
  1221 				return;
  1222 			}
  1223 		}
  1224 		else if (strcmp(cmd, "reload") == 0)
  1225 		{
  1226 			if (argcount < 4)
  1227 			{
  1228 				g_RootMenu.ConsolePrint("[SM] Usage: sm exts reload <#>");
  1229 				return;
  1230 			}
  1231 			
  1232 			const char *arg = command.Arg(3);
  1233 			unsigned int num = atoi(arg);
  1234 			CExtension *pExt = FindByOrder(num);
  1235 
  1236 			if (!pExt)
  1237 			{
  1238 				g_RootMenu.ConsolePrint("[SM] Extension number %d was not found.", num);
  1239 				return;
  1240 			}
  1241 			
  1242 			if (pExt->IsLoaded())
  1243 			{
  1244 				char filename[PLATFORM_MAX_PATH];
  1245 				char error[255];
  1246 				
  1247 				snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
  1248 				
  1249 				if (pExt->Reload(error, sizeof(error)))
  1250 				{
  1251 					g_RootMenu.ConsolePrint("[SM] Extension %s is now reloaded.", filename);
  1252 				}
  1253 				else
  1254 				{
  1255 					g_RootMenu.ConsolePrint("[SM] Extension %s failed to reload: %s", filename, error);
  1256 				}
  1257 					
  1258 				return;
  1259 			} 
  1260 			else
  1261 			{
  1262 				g_RootMenu.ConsolePrint("[SM] Extension %s is not loaded.", pExt->GetFilename());
  1263 				
  1264 				return;
  1265 			}
  1266 			
  1267 		}
  1268 	}
  1269 
  1270 	g_RootMenu.ConsolePrint("SourceMod Extensions Menu:");
  1271 	g_RootMenu.DrawGenericOption("info", "Extra extension information");
  1272 	g_RootMenu.DrawGenericOption("list", "List extensions");
  1273 	g_RootMenu.DrawGenericOption("load", "Load an extension");
  1274 	g_RootMenu.DrawGenericOption("reload", "Reload an extension");
  1275 	g_RootMenu.DrawGenericOption("unload", "Unload an extension");
  1276 }
  1277 
  1278 CExtension *CExtensionManager::GetExtensionFromIdent(IdentityToken_t *ptr)
  1279 {
  1280 	if (ptr->type == g_ExtType)
  1281 	{
  1282 		return (CExtension *)(ptr->ptr);
  1283 	}
  1284 
  1285 	return NULL;
  1286 }
  1287 
  1288 CExtensionManager::CExtensionManager()
  1289 {
  1290 }
  1291 
  1292 CExtensionManager::~CExtensionManager()
  1293 {
  1294 }
  1295 
  1296 void CExtensionManager::AddLibrary(IExtension *pSource, const char *library)
  1297 {
  1298 	CExtension *pExt = (CExtension *)pSource;
  1299 	pExt->AddLibrary(library);
  1300 	g_PluginSys.OnLibraryAction(library, false, false);
  1301 }
  1302 
  1303 bool CExtensionManager::LibraryExists(const char *library)
  1304 {
  1305 	CExtension *pExt;
  1306 
  1307 	for (List<CExtension *>::iterator iter = m_Libs.begin();
  1308 		 iter != m_Libs.end();
  1309 		 iter++)
  1310 	{
  1311 		pExt = (*iter);
  1312 		for (List<String>::iterator s_iter = pExt->m_Libraries.begin();
  1313 			 s_iter != pExt->m_Libraries.end();
  1314 			 s_iter++)
  1315 		{
  1316 			if ((*s_iter).compare(library) == 0)
  1317 			{
  1318 				return true;
  1319 			}
  1320 		}
  1321 	}
  1322 
  1323 	return false;
  1324 }
  1325 
  1326 IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface,
  1327 											const char *filepath,
  1328 											const char *filename,
  1329 											char *error,
  1330 											size_t maxlength)
  1331 {
  1332 	IExtension *pAlready;
  1333 	if ((pAlready=FindExtensionByFile(filename)) != NULL)
  1334 	{
  1335 		return pAlready;
  1336 	}
  1337 
  1338 	CExtension *pExt = new CRemoteExtension(pInterface, filename, filepath);
  1339 
  1340 	if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
  1341 	{
  1342 		pExt->Unload();
  1343 		delete pExt;
  1344 		return NULL;
  1345 	}
  1346 
  1347 	m_Libs.push_back(pExt);
  1348 
  1349 	return pExt;
  1350 }
  1351 
  1352 void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
  1353 {
  1354 	IExtensionInterface *pAPI;
  1355 	List<CExtension *>::iterator iter;
  1356 
  1357 	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
  1358 	{
  1359 		if ((pAPI = (*iter)->GetAPI()) == NULL)
  1360 		{
  1361 			continue;
  1362 		}
  1363 		if (pAPI->GetExtensionVersion() > 3)
  1364 		{
  1365 			pAPI->OnCoreMapStart(pEdictList, edictCount, clientMax);
  1366 		}
  1367 	}
  1368 }
  1369 
  1370 bool CLocalExtension::IsSameFile(const char *file)
  1371 {
  1372 	/* Only care about the shortened name. */
  1373 	return strcmp(file, m_File.c_str()) == 0;
  1374 }
  1375 
  1376 bool CRemoteExtension::IsSameFile(const char *file)
  1377 {
  1378 	/* :TODO: this could be better, but no one uses this API anyway. */
  1379 	return strcmp(file, m_Path.c_str()) == 0;
  1380 }
  1381