Renamed err_max to maxlength. Yes, I am crazy.
authorScott Ehlert <ds@alliedmods.net>
Tue May 08 00:21:44 2007 +0000 (2007-05-08)
changeset 75566c9fde7f632
parent 754 75f3f2196bd7
child 756 34c2c73893ee
Renamed err_max to maxlength. Yes, I am crazy.
core/sourcemod.cpp
core/sourcemod.h
core/systems/ExtensionSys.cpp
core/systems/ExtensionSys.h
core/systems/LibrarySys.cpp
core/systems/LibrarySys.h
core/systems/PluginSys.cpp
core/systems/PluginSys.h
public/IExtensionSys.h
public/ILibrarySys.h
public/IPluginSys.h
     1.1 --- a/core/sourcemod.cpp	Mon May 07 04:17:24 2007 +0000
     1.2 +++ b/core/sourcemod.cpp	Tue May 08 00:21:44 2007 +0000
     1.3 @@ -101,7 +101,7 @@
     1.4  	return ConfigResult_Ignore;
     1.5  }
     1.6  
     1.7 -bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
     1.8 +bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late)
     1.9  {
    1.10  	const char *gamepath = g_SMAPI->GetBaseDir();
    1.11  
    1.12 @@ -141,9 +141,9 @@
    1.13  	g_pJIT = g_LibSys.OpenLibrary(file, myerror, sizeof(myerror));
    1.14  	if (!g_pJIT)
    1.15  	{
    1.16 -		if (error && err_max)
    1.17 +		if (error && maxlength)
    1.18  		{
    1.19 -			snprintf(error, err_max, "%s (failed to load bin/sourcepawn.jit.x86.%s)", 
    1.20 +			snprintf(error, maxlength, "%s (failed to load bin/sourcepawn.jit.x86.%s)", 
    1.21  				myerror,
    1.22  				PLATFORM_LIB_EXT);
    1.23  		}
    1.24 @@ -155,9 +155,9 @@
    1.25  	if (!jit_init)
    1.26  	{
    1.27  		ShutdownJIT();
    1.28 -		if (error && err_max)
    1.29 +		if (error && maxlength)
    1.30  		{
    1.31 -			snprintf(error, err_max, "Failed to find GiveEnginePointer in JIT!");
    1.32 +			snprintf(error, maxlength, "Failed to find GiveEnginePointer in JIT!");
    1.33  		}
    1.34  		return false;
    1.35  	}
    1.36 @@ -165,9 +165,9 @@
    1.37  	if ((err=jit_init(g_pSourcePawn)) != 0)
    1.38  	{
    1.39  		ShutdownJIT();
    1.40 -		if (error && err_max)
    1.41 +		if (error && maxlength)
    1.42  		{
    1.43 -			snprintf(error, err_max, "GiveEnginePointer returned %d in the JIT", err);
    1.44 +			snprintf(error, maxlength, "GiveEnginePointer returned %d in the JIT", err);
    1.45  		}
    1.46  		return false;
    1.47  	}
    1.48 @@ -177,9 +177,9 @@
    1.49  	if (!jit_get)
    1.50  	{
    1.51  		ShutdownJIT();
    1.52 -		if (error && err_max)
    1.53 +		if (error && maxlength)
    1.54  		{
    1.55 -			snprintf(error, err_max, "JIT is missing a necessary export!");
    1.56 +			snprintf(error, maxlength, "JIT is missing a necessary export!");
    1.57  		}
    1.58  		return false;
    1.59  	}
    1.60 @@ -188,9 +188,9 @@
    1.61  	if (!num || ((g_pVM=jit_get(0)) == NULL))
    1.62  	{
    1.63  		ShutdownJIT();
    1.64 -		if (error && err_max)
    1.65 +		if (error && maxlength)
    1.66  		{
    1.67 -			snprintf(error, err_max, "JIT did not export any virtual machines!");
    1.68 +			snprintf(error, maxlength, "JIT did not export any virtual machines!");
    1.69  		}
    1.70  		return false;
    1.71  	}
    1.72 @@ -199,9 +199,9 @@
    1.73  	if (api != SOURCEPAWN_VM_API_VERSION)
    1.74  	{
    1.75  		ShutdownJIT();
    1.76 -		if (error && err_max)
    1.77 +		if (error && maxlength)
    1.78  		{
    1.79 -			snprintf(error, err_max, "JIT is not a compatible version");
    1.80 +			snprintf(error, maxlength, "JIT is not a compatible version");
    1.81  		}
    1.82  		return false;
    1.83  	}
     2.1 --- a/core/sourcemod.h	Mon May 07 04:17:24 2007 +0000
     2.2 +++ b/core/sourcemod.h	Tue May 08 00:21:44 2007 +0000
     2.3 @@ -36,7 +36,7 @@
     2.4  	/**
     2.5  	 * @brief Initializes SourceMod, or returns an error on failure.
     2.6  	 */
     2.7 -	bool InitializeSourceMod(char *error, size_t err_max, bool late);
     2.8 +	bool InitializeSourceMod(char *error, size_t maxlength, bool late);
     2.9  
    2.10  	/** 
    2.11  	 * @brief Starts everything SourceMod needs to run
     3.1 --- a/core/systems/ExtensionSys.cpp	Mon May 07 04:17:24 2007 +0000
     3.2 +++ b/core/systems/ExtensionSys.cpp	Tue May 08 00:21:44 2007 +0000
     3.3 @@ -25,7 +25,7 @@
     3.4  CExtensionManager g_Extensions;
     3.5  IdentityType_t g_ExtType;
     3.6  
     3.7 -CExtension::CExtension(const char *filename, char *error, size_t err_max)
     3.8 +CExtension::CExtension(const char *filename, char *error, size_t maxlength)
     3.9  {
    3.10  	m_File.assign(filename);
    3.11  	m_pAPI = NULL;
    3.12 @@ -37,7 +37,7 @@
    3.13  	char path[PLATFORM_MAX_PATH];
    3.14  	g_SourceMod.BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "extensions/%s", filename);
    3.15  
    3.16 -	m_pLib = g_LibSys.OpenLibrary(path, error, err_max);
    3.17 +	m_pLib = g_LibSys.OpenLibrary(path, error, maxlength);
    3.18  
    3.19  	if (m_pLib == NULL)
    3.20  	{
    3.21 @@ -51,7 +51,7 @@
    3.22  	{
    3.23  		m_pLib->CloseLibrary();
    3.24  		m_pLib = NULL;
    3.25 -		snprintf(error, err_max, "Unable to find extension entry point");
    3.26 +		snprintf(error, maxlength, "Unable to find extension entry point");
    3.27  		return;
    3.28  	}
    3.29  
    3.30 @@ -60,19 +60,19 @@
    3.31  	{
    3.32  		m_pLib->CloseLibrary();
    3.33  		m_pLib = NULL;
    3.34 -		snprintf(error, err_max, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
    3.35 +		snprintf(error, maxlength, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
    3.36  		return;
    3.37  	}
    3.38  
    3.39  	if (m_pAPI->IsMetamodExtension())
    3.40  	{
    3.41  		bool already;
    3.42 -		m_PlId = g_pMMPlugins->Load(path, g_PLID, already, error, err_max);
    3.43 +		m_PlId = g_pMMPlugins->Load(path, g_PLID, already, error, maxlength);
    3.44  	}
    3.45  
    3.46  	m_pIdentToken = g_ShareSys.CreateIdentity(g_ExtType);
    3.47  
    3.48 -	if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, err_max, !g_SourceMod.IsMapLoading()))
    3.49 +	if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !g_SourceMod.IsMapLoading()))
    3.50  	{
    3.51  		if (m_pAPI->IsMetamodExtension())
    3.52  		{
    3.53 @@ -403,7 +403,7 @@
    3.54  	return NULL;
    3.55  }
    3.56  
    3.57 -IExtension *CExtensionManager::LoadExtension(const char *file, ExtensionLifetime lifetime, char *error, size_t err_max)
    3.58 +IExtension *CExtensionManager::LoadExtension(const char *file, ExtensionLifetime lifetime, char *error, size_t maxlength)
    3.59  {
    3.60  	IExtension *pAlready;
    3.61  	if ((pAlready=FindExtensionByFile(file)) != NULL)
    3.62 @@ -411,7 +411,7 @@
    3.63  		return pAlready;
    3.64  	}
    3.65  
    3.66 -	CExtension *pExt = new CExtension(file, error, err_max);
    3.67 +	CExtension *pExt = new CExtension(file, error, maxlength);
    3.68  
    3.69  	/* :NOTE: lifetime is currently ignored */
    3.70  
     4.1 --- a/core/systems/ExtensionSys.h	Mon May 07 04:17:24 2007 +0000
     4.2 +++ b/core/systems/ExtensionSys.h	Tue May 08 00:21:44 2007 +0000
     4.3 @@ -78,7 +78,7 @@
     4.4  	IExtension *LoadExtension(const char *path, 
     4.5  		ExtensionLifetime lifetime, 
     4.6  		char *error,
     4.7 -		size_t err_max);
     4.8 +		size_t maxlength);
     4.9  	bool UnloadExtension(IExtension *pExt);
    4.10  	IExtension *FindExtensionByFile(const char *file);
    4.11  	IExtension *FindExtensionByName(const char *ext);
     5.1 --- a/core/systems/LibrarySys.cpp	Mon May 07 04:17:24 2007 +0000
     5.2 +++ b/core/systems/LibrarySys.cpp	Tue May 08 00:21:44 2007 +0000
     5.3 @@ -252,9 +252,9 @@
     5.4  	return dir;
     5.5  }
     5.6  
     5.7 -void LibrarySystem::GetPlatformError(char *error, size_t err_max)
     5.8 +void LibrarySystem::GetPlatformError(char *error, size_t maxlength)
     5.9  {
    5.10 -	if (error && err_max)
    5.11 +	if (error && maxlength)
    5.12  	{
    5.13  #if defined PLATFORM_WINDOWS
    5.14  		DWORD dw = GetLastError();
    5.15 @@ -264,10 +264,10 @@
    5.16  			dw,
    5.17  			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    5.18  			(LPSTR)error,
    5.19 -			err_max,
    5.20 +			maxlength,
    5.21  			NULL);
    5.22  #elif defined PLATFORM_POSIX
    5.23 -		snprintf(error, err_max, "%s", strerror(errno));
    5.24 +		snprintf(error, maxlength, "%s", strerror(errno));
    5.25  #endif
    5.26  	}
    5.27  }
    5.28 @@ -277,21 +277,21 @@
    5.29  	delete dir;
    5.30  }
    5.31  
    5.32 -ILibrary *LibrarySystem::OpenLibrary(const char *path, char *error, size_t err_max)
    5.33 +ILibrary *LibrarySystem::OpenLibrary(const char *path, char *error, size_t maxlength)
    5.34  {
    5.35  	LibraryHandle lib;
    5.36  #if defined PLATFORM_WINDOWS
    5.37  	lib = LoadLibraryA(path);
    5.38  	if (!lib)
    5.39  	{
    5.40 -		GetPlatformError(error, err_max);
    5.41 +		GetPlatformError(error, maxlength);
    5.42  		return false;
    5.43  	}
    5.44  #elif defined PLATFORM_POSIX
    5.45  	lib = dlopen(path, RTLD_NOW);
    5.46  	if (!lib)
    5.47  	{
    5.48 -		GetPlatformError(error, err_max);
    5.49 +		GetPlatformError(error, maxlength);
    5.50  		return false;
    5.51  	}
    5.52  #endif
     6.1 --- a/core/systems/LibrarySys.h	Mon May 07 04:17:24 2007 +0000
     6.2 +++ b/core/systems/LibrarySys.h	Tue May 08 00:21:44 2007 +0000
     6.3 @@ -66,13 +66,13 @@
     6.4  class LibrarySystem : public ILibrarySys
     6.5  {
     6.6  public:
     6.7 -	ILibrary *OpenLibrary(const char *path, char *error, size_t err_max);
     6.8 +	ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength);
     6.9  	IDirectory *OpenDirectory(const char *path);
    6.10  	void CloseDirectory(IDirectory *dir);
    6.11  	bool PathExists(const char *path);
    6.12  	bool IsPathFile(const char *path);
    6.13  	bool IsPathDirectory(const char *path);
    6.14 -	void GetPlatformError(char *error, size_t err_max);
    6.15 +	void GetPlatformError(char *error, size_t maxlength);
    6.16  	size_t PathFormat(char *buffer, size_t len, const char *fmt, ...);
    6.17  };
    6.18  
     7.1 --- a/core/systems/PluginSys.cpp	Mon May 07 04:17:24 2007 +0000
     7.2 +++ b/core/systems/PluginSys.cpp	Tue May 08 00:21:44 2007 +0000
     7.3 @@ -748,7 +748,7 @@
     7.4  }
     7.5  
     7.6  //well i have discovered that gabe newell is very fat, so i wrote this comment now
     7.7 -LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t err_max)
     7.8 +LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength)
     7.9  {
    7.10  	/**
    7.11  	 * Does this plugin already exist?
    7.12 @@ -771,7 +771,7 @@
    7.13  		}
    7.14  	}
    7.15  
    7.16 -	pPlugin = CPlugin::CreatePlugin(path, error, err_max);
    7.17 +	pPlugin = CPlugin::CreatePlugin(path, error, maxlength);
    7.18  
    7.19  	assert(pPlugin != NULL);
    7.20  
    7.21 @@ -807,7 +807,7 @@
    7.22  				{
    7.23  					if (error)
    7.24  					{
    7.25 -						snprintf(error, err_max, "Unable to set JIT option (key \"%s\") (value \"%s\")", key, val);
    7.26 +						snprintf(error, maxlength, "Unable to set JIT option (key \"%s\") (value \"%s\")", key, val);
    7.27  					}
    7.28  					pPlugin->CancelMyCompile();
    7.29  					co = NULL;
    7.30 @@ -829,10 +829,10 @@
    7.31  	{
    7.32  		AddCoreNativesToPlugin(pPlugin);
    7.33  		pPlugin->InitIdentity();
    7.34 -		if (pPlugin->Call_AskPluginLoad(error, err_max))
    7.35 +		if (pPlugin->Call_AskPluginLoad(error, maxlength))
    7.36  		{
    7.37  			/* Autoload any modules */
    7.38 -			LoadOrRequireExtensions(pPlugin, 1, error, err_max);
    7.39 +			LoadOrRequireExtensions(pPlugin, 1, error, maxlength);
    7.40  		}
    7.41  	}
    7.42  
    7.43 @@ -848,13 +848,13 @@
    7.44  	return (pPlugin->GetStatus() == Plugin_Loaded) ? LoadRes_Successful : LoadRes_Failure;
    7.45  }
    7.46  
    7.47 -IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t err_max, bool *wasloaded)
    7.48 +IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t maxlength, bool *wasloaded)
    7.49  {
    7.50  	CPlugin *pl;
    7.51  	LoadRes res;
    7.52  
    7.53  	*wasloaded = false;
    7.54 -	if ((res=_LoadPlugin(&pl, path, debug, type, error, err_max)) == LoadRes_Failure)
    7.55 +	if ((res=_LoadPlugin(&pl, path, debug, type, error, maxlength)) == LoadRes_Failure)
    7.56  	{
    7.57  		delete pl;
    7.58  		return NULL;
    7.59 @@ -871,7 +871,7 @@
    7.60  	/* Run second pass if we need to */
    7.61  	if (IsLateLoadTime() && pl->GetStatus() == Plugin_Loaded)
    7.62  	{
    7.63 -		if (!RunSecondPass(pl, error, err_max))
    7.64 +		if (!RunSecondPass(pl, error, maxlength))
    7.65  		{
    7.66  			UnloadPlugin(pl);
    7.67  			return NULL;
     8.1 --- a/core/systems/PluginSys.h	Mon May 07 04:17:24 2007 +0000
     8.2 +++ b/core/systems/PluginSys.h	Tue May 08 00:21:44 2007 +0000
     8.3 @@ -281,7 +281,7 @@
     8.4  								bool debug,
     8.5  								PluginType type,
     8.6  								char error[],
     8.7 -								size_t err_max,
     8.8 +								size_t maxlength,
     8.9  								bool *wasloaded);
    8.10  	bool UnloadPlugin(IPlugin *plugin);
    8.11  	IPlugin *FindPluginByContext(const sp_context_t *ctx);
    8.12 @@ -363,7 +363,7 @@
    8.13  	void AddFunctionsToForward(const char *name, IChangeableForward *pForward);
    8.14  
    8.15  private:
    8.16 -	LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t err_max);
    8.17 +	LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength);
    8.18  
    8.19  	void LoadAutoPlugin(const char *plugin);
    8.20  
     9.1 --- a/public/IExtensionSys.h	Mon May 07 04:17:24 2007 +0000
     9.2 +++ b/public/IExtensionSys.h	Tue May 08 00:21:44 2007 +0000
     9.3 @@ -124,14 +124,14 @@
     9.4  		 * @param me		Pointer back to extension.
     9.5  		 * @param sys		Pointer to interface sharing system of SourceMod.
     9.6  		 * @param error		Error buffer to print back to, if any.
     9.7 -		 * @param err_max	Maximum size of error buffer.
     9.8 +		 * @param maxlength	Maximum size of error buffer.
     9.9  		 * @param late		If this extension was loaded "late" (i.e. manually).
    9.10  		 * @return			True if load should continue, false otherwise.
    9.11  		 */
    9.12  		virtual bool OnExtensionLoad(IExtension *me,
    9.13  								  IShareSys *sys, 
    9.14  								  char *error, 
    9.15 -								  size_t err_max, 
    9.16 +								  size_t maxlength, 
    9.17  								  bool late) =0;
    9.18  
    9.19  		/**
    9.20 @@ -175,7 +175,7 @@
    9.21  		}
    9.22  
    9.23  		/**
    9.24 -		 * @brief Return false to tell Core that your extension should be considered usable.
    9.25 +		 * @brief Return false to tell Core that your extension should be considered unusable.
    9.26  		 *
    9.27  		 * @param error				Error buffer.
    9.28  		 * @param maxlength			Size of error buffer.
    9.29 @@ -229,13 +229,13 @@
    9.30  		 * @param path		Path to extension file, relative to the extensions folder.
    9.31  		 * @param lifetime	Lifetime of the extension (currently ignored).
    9.32  		 * @param error		Error buffer.
    9.33 -		 * @param err_max	Maximum error buffer length.
    9.34 +		 * @param maxlength	Maximum error buffer length.
    9.35  		 * @return			New IExtension on success, NULL on failure.
    9.36  		 */
    9.37  		virtual IExtension *LoadExtension(const char *path, 
    9.38  									ExtensionLifetime lifetime, 
    9.39  									char *error,
    9.40 -									size_t err_max) =0;
    9.41 +									size_t maxlength) =0;
    9.42  
    9.43  		/**
    9.44  		 * @brief Attempts to unload a module.
    10.1 --- a/public/ILibrarySys.h	Mon May 07 04:17:24 2007 +0000
    10.2 +++ b/public/ILibrarySys.h	Tue May 08 00:21:44 2007 +0000
    10.3 @@ -116,10 +116,10 @@
    10.4  		 * 
    10.5  		 * @param path		Path to library file (.dll/.so).
    10.6  		 * @param error		Buffer for any error message (may be NULL).
    10.7 -		 * @param err_max	Maximum length of error buffer.
    10.8 +		 * @param maxlength	Maximum length of error buffer.
    10.9  		 * @return			Pointer to an ILibrary, NULL if failed.
   10.10  		 */
   10.11 -		virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max) =0;
   10.12 +		virtual ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength) =0;
   10.13  
   10.14  		/**
   10.15  		 * @brief Opens a directory for reading.
   10.16 @@ -158,9 +158,9 @@
   10.17  		 * POSIX equivalent: errno + strerror()
   10.18  		 *
   10.19  		 * @param error		Error message buffer.
   10.20 -		 * @param err_max	Maximum length of error buffer.
   10.21 +		 * @param maxlength	Maximum length of error buffer.
   10.22  		 */
   10.23 -		virtual void GetPlatformError(char *error, size_t err_max) =0;
   10.24 +		virtual void GetPlatformError(char *error, size_t maxlength) =0;
   10.25  
   10.26  		/**
   10.27  		 * @brief Formats a string similar to snprintf(), except
    11.1 --- a/public/IPluginSys.h	Mon May 07 04:17:24 2007 +0000
    11.2 +++ b/public/IPluginSys.h	Tue May 08 00:21:44 2007 +0000
    11.3 @@ -279,7 +279,7 @@
    11.4  		 * @param debug		Whether or not to default the plugin into debug mode.
    11.5  		 * @param type		Lifetime of the plugin.
    11.6  		 * @param error		Buffer to hold any error message.
    11.7 -		 * @param err_max	Maximum length of error message buffer.
    11.8 +		 * @param maxlength	Maximum length of error message buffer.
    11.9  		 * @param wasloaded	Stores if the plugin is already loaded.
   11.10  		 * @return			A new plugin pointer on success, false otherwise.
   11.11  		 */
   11.12 @@ -287,7 +287,7 @@
   11.13  									bool debug,
   11.14  									PluginType type,
   11.15  									char error[],
   11.16 -									size_t err_max,
   11.17 +									size_t maxlength,
   11.18  									bool *wasloaded) =0;
   11.19  
   11.20  		/**