Renamed err_max to maxlength. Yes, I am crazy.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40761
This commit is contained in:
Scott Ehlert 2007-05-08 00:21:44 +00:00
parent 45d0589585
commit 3851dc9243
11 changed files with 53 additions and 53 deletions

View File

@ -101,7 +101,7 @@ ConfigResult SourceModBase::OnSourceModConfigChanged(const char *key,
return ConfigResult_Ignore;
}
bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late)
{
const char *gamepath = g_SMAPI->GetBaseDir();
@ -141,9 +141,9 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
g_pJIT = g_LibSys.OpenLibrary(file, myerror, sizeof(myerror));
if (!g_pJIT)
{
if (error && err_max)
if (error && maxlength)
{
snprintf(error, err_max, "%s (failed to load bin/sourcepawn.jit.x86.%s)",
snprintf(error, maxlength, "%s (failed to load bin/sourcepawn.jit.x86.%s)",
myerror,
PLATFORM_LIB_EXT);
}
@ -155,9 +155,9 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
if (!jit_init)
{
ShutdownJIT();
if (error && err_max)
if (error && maxlength)
{
snprintf(error, err_max, "Failed to find GiveEnginePointer in JIT!");
snprintf(error, maxlength, "Failed to find GiveEnginePointer in JIT!");
}
return false;
}
@ -165,9 +165,9 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
if ((err=jit_init(g_pSourcePawn)) != 0)
{
ShutdownJIT();
if (error && err_max)
if (error && maxlength)
{
snprintf(error, err_max, "GiveEnginePointer returned %d in the JIT", err);
snprintf(error, maxlength, "GiveEnginePointer returned %d in the JIT", err);
}
return false;
}
@ -177,9 +177,9 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
if (!jit_get)
{
ShutdownJIT();
if (error && err_max)
if (error && maxlength)
{
snprintf(error, err_max, "JIT is missing a necessary export!");
snprintf(error, maxlength, "JIT is missing a necessary export!");
}
return false;
}
@ -188,9 +188,9 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
if (!num || ((g_pVM=jit_get(0)) == NULL))
{
ShutdownJIT();
if (error && err_max)
if (error && maxlength)
{
snprintf(error, err_max, "JIT did not export any virtual machines!");
snprintf(error, maxlength, "JIT did not export any virtual machines!");
}
return false;
}
@ -199,9 +199,9 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
if (api != SOURCEPAWN_VM_API_VERSION)
{
ShutdownJIT();
if (error && err_max)
if (error && maxlength)
{
snprintf(error, err_max, "JIT is not a compatible version");
snprintf(error, maxlength, "JIT is not a compatible version");
}
return false;
}

View File

@ -36,7 +36,7 @@ public:
/**
* @brief Initializes SourceMod, or returns an error on failure.
*/
bool InitializeSourceMod(char *error, size_t err_max, bool late);
bool InitializeSourceMod(char *error, size_t maxlength, bool late);
/**
* @brief Starts everything SourceMod needs to run

View File

@ -25,7 +25,7 @@
CExtensionManager g_Extensions;
IdentityType_t g_ExtType;
CExtension::CExtension(const char *filename, char *error, size_t err_max)
CExtension::CExtension(const char *filename, char *error, size_t maxlength)
{
m_File.assign(filename);
m_pAPI = NULL;
@ -37,7 +37,7 @@ CExtension::CExtension(const char *filename, char *error, size_t err_max)
char path[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "extensions/%s", filename);
m_pLib = g_LibSys.OpenLibrary(path, error, err_max);
m_pLib = g_LibSys.OpenLibrary(path, error, maxlength);
if (m_pLib == NULL)
{
@ -51,7 +51,7 @@ CExtension::CExtension(const char *filename, char *error, size_t err_max)
{
m_pLib->CloseLibrary();
m_pLib = NULL;
snprintf(error, err_max, "Unable to find extension entry point");
snprintf(error, maxlength, "Unable to find extension entry point");
return;
}
@ -60,19 +60,19 @@ CExtension::CExtension(const char *filename, char *error, size_t err_max)
{
m_pLib->CloseLibrary();
m_pLib = NULL;
snprintf(error, err_max, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
snprintf(error, maxlength, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
return;
}
if (m_pAPI->IsMetamodExtension())
{
bool already;
m_PlId = g_pMMPlugins->Load(path, g_PLID, already, error, err_max);
m_PlId = g_pMMPlugins->Load(path, g_PLID, already, error, maxlength);
}
m_pIdentToken = g_ShareSys.CreateIdentity(g_ExtType);
if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, err_max, !g_SourceMod.IsMapLoading()))
if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !g_SourceMod.IsMapLoading()))
{
if (m_pAPI->IsMetamodExtension())
{
@ -403,7 +403,7 @@ IExtension *CExtensionManager::FindExtensionByName(const char *ext)
return NULL;
}
IExtension *CExtensionManager::LoadExtension(const char *file, ExtensionLifetime lifetime, char *error, size_t err_max)
IExtension *CExtensionManager::LoadExtension(const char *file, ExtensionLifetime lifetime, char *error, size_t maxlength)
{
IExtension *pAlready;
if ((pAlready=FindExtensionByFile(file)) != NULL)
@ -411,7 +411,7 @@ IExtension *CExtensionManager::LoadExtension(const char *file, ExtensionLifetime
return pAlready;
}
CExtension *pExt = new CExtension(file, error, err_max);
CExtension *pExt = new CExtension(file, error, maxlength);
/* :NOTE: lifetime is currently ignored */

View File

@ -78,7 +78,7 @@ public: //IExtensionManager
IExtension *LoadExtension(const char *path,
ExtensionLifetime lifetime,
char *error,
size_t err_max);
size_t maxlength);
bool UnloadExtension(IExtension *pExt);
IExtension *FindExtensionByFile(const char *file);
IExtension *FindExtensionByName(const char *ext);

View File

@ -252,9 +252,9 @@ IDirectory *LibrarySystem::OpenDirectory(const char *path)
return dir;
}
void LibrarySystem::GetPlatformError(char *error, size_t err_max)
void LibrarySystem::GetPlatformError(char *error, size_t maxlength)
{
if (error && err_max)
if (error && maxlength)
{
#if defined PLATFORM_WINDOWS
DWORD dw = GetLastError();
@ -264,10 +264,10 @@ void LibrarySystem::GetPlatformError(char *error, size_t err_max)
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)error,
err_max,
maxlength,
NULL);
#elif defined PLATFORM_POSIX
snprintf(error, err_max, "%s", strerror(errno));
snprintf(error, maxlength, "%s", strerror(errno));
#endif
}
}
@ -277,21 +277,21 @@ void LibrarySystem::CloseDirectory(IDirectory *dir)
delete dir;
}
ILibrary *LibrarySystem::OpenLibrary(const char *path, char *error, size_t err_max)
ILibrary *LibrarySystem::OpenLibrary(const char *path, char *error, size_t maxlength)
{
LibraryHandle lib;
#if defined PLATFORM_WINDOWS
lib = LoadLibraryA(path);
if (!lib)
{
GetPlatformError(error, err_max);
GetPlatformError(error, maxlength);
return false;
}
#elif defined PLATFORM_POSIX
lib = dlopen(path, RTLD_NOW);
if (!lib)
{
GetPlatformError(error, err_max);
GetPlatformError(error, maxlength);
return false;
}
#endif

View File

@ -66,13 +66,13 @@ private:
class LibrarySystem : public ILibrarySys
{
public:
ILibrary *OpenLibrary(const char *path, char *error, size_t err_max);
ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength);
IDirectory *OpenDirectory(const char *path);
void CloseDirectory(IDirectory *dir);
bool PathExists(const char *path);
bool IsPathFile(const char *path);
bool IsPathDirectory(const char *path);
void GetPlatformError(char *error, size_t err_max);
void GetPlatformError(char *error, size_t maxlength);
size_t PathFormat(char *buffer, size_t len, const char *fmt, ...);
};

View File

@ -748,7 +748,7 @@ void CPluginManager::LoadPluginsFromDir(const char *basedir, const char *localpa
}
//well i have discovered that gabe newell is very fat, so i wrote this comment now
LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t err_max)
LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength)
{
/**
* Does this plugin already exist?
@ -771,7 +771,7 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
}
}
pPlugin = CPlugin::CreatePlugin(path, error, err_max);
pPlugin = CPlugin::CreatePlugin(path, error, maxlength);
assert(pPlugin != NULL);
@ -807,7 +807,7 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
{
if (error)
{
snprintf(error, err_max, "Unable to set JIT option (key \"%s\") (value \"%s\")", key, val);
snprintf(error, maxlength, "Unable to set JIT option (key \"%s\") (value \"%s\")", key, val);
}
pPlugin->CancelMyCompile();
co = NULL;
@ -829,10 +829,10 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
{
AddCoreNativesToPlugin(pPlugin);
pPlugin->InitIdentity();
if (pPlugin->Call_AskPluginLoad(error, err_max))
if (pPlugin->Call_AskPluginLoad(error, maxlength))
{
/* Autoload any modules */
LoadOrRequireExtensions(pPlugin, 1, error, err_max);
LoadOrRequireExtensions(pPlugin, 1, error, maxlength);
}
}
@ -848,13 +848,13 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool de
return (pPlugin->GetStatus() == Plugin_Loaded) ? LoadRes_Successful : LoadRes_Failure;
}
IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t err_max, bool *wasloaded)
IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t maxlength, bool *wasloaded)
{
CPlugin *pl;
LoadRes res;
*wasloaded = false;
if ((res=_LoadPlugin(&pl, path, debug, type, error, err_max)) == LoadRes_Failure)
if ((res=_LoadPlugin(&pl, path, debug, type, error, maxlength)) == LoadRes_Failure)
{
delete pl;
return NULL;
@ -871,7 +871,7 @@ IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType typ
/* Run second pass if we need to */
if (IsLateLoadTime() && pl->GetStatus() == Plugin_Loaded)
{
if (!RunSecondPass(pl, error, err_max))
if (!RunSecondPass(pl, error, maxlength))
{
UnloadPlugin(pl);
return NULL;

View File

@ -281,7 +281,7 @@ public: //IPluginManager
bool debug,
PluginType type,
char error[],
size_t err_max,
size_t maxlength,
bool *wasloaded);
bool UnloadPlugin(IPlugin *plugin);
IPlugin *FindPluginByContext(const sp_context_t *ctx);
@ -363,7 +363,7 @@ public:
void AddFunctionsToForward(const char *name, IChangeableForward *pForward);
private:
LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t err_max);
LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength);
void LoadAutoPlugin(const char *plugin);

View File

@ -124,14 +124,14 @@ namespace SourceMod
* @param me Pointer back to extension.
* @param sys Pointer to interface sharing system of SourceMod.
* @param error Error buffer to print back to, if any.
* @param err_max Maximum size of error buffer.
* @param maxlength Maximum size of error buffer.
* @param late If this extension was loaded "late" (i.e. manually).
* @return True if load should continue, false otherwise.
*/
virtual bool OnExtensionLoad(IExtension *me,
IShareSys *sys,
char *error,
size_t err_max,
size_t maxlength,
bool late) =0;
/**
@ -175,7 +175,7 @@ namespace SourceMod
}
/**
* @brief Return false to tell Core that your extension should be considered usable.
* @brief Return false to tell Core that your extension should be considered unusable.
*
* @param error Error buffer.
* @param maxlength Size of error buffer.
@ -229,13 +229,13 @@ namespace SourceMod
* @param path Path to extension file, relative to the extensions folder.
* @param lifetime Lifetime of the extension (currently ignored).
* @param error Error buffer.
* @param err_max Maximum error buffer length.
* @param maxlength Maximum error buffer length.
* @return New IExtension on success, NULL on failure.
*/
virtual IExtension *LoadExtension(const char *path,
ExtensionLifetime lifetime,
char *error,
size_t err_max) =0;
size_t maxlength) =0;
/**
* @brief Attempts to unload a module.

View File

@ -116,10 +116,10 @@ namespace SourceMod
*
* @param path Path to library file (.dll/.so).
* @param error Buffer for any error message (may be NULL).
* @param err_max Maximum length of error buffer.
* @param maxlength Maximum length of error buffer.
* @return Pointer to an ILibrary, NULL if failed.
*/
virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max) =0;
virtual ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength) =0;
/**
* @brief Opens a directory for reading.
@ -158,9 +158,9 @@ namespace SourceMod
* POSIX equivalent: errno + strerror()
*
* @param error Error message buffer.
* @param err_max Maximum length of error buffer.
* @param maxlength Maximum length of error buffer.
*/
virtual void GetPlatformError(char *error, size_t err_max) =0;
virtual void GetPlatformError(char *error, size_t maxlength) =0;
/**
* @brief Formats a string similar to snprintf(), except

View File

@ -279,7 +279,7 @@ namespace SourceMod
* @param debug Whether or not to default the plugin into debug mode.
* @param type Lifetime of the plugin.
* @param error Buffer to hold any error message.
* @param err_max Maximum length of error message buffer.
* @param maxlength Maximum length of error message buffer.
* @param wasloaded Stores if the plugin is already loaded.
* @return A new plugin pointer on success, false otherwise.
*/
@ -287,7 +287,7 @@ namespace SourceMod
bool debug,
PluginType type,
char error[],
size_t err_max,
size_t maxlength,
bool *wasloaded) =0;
/**