diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index 8de6ab61..a0576d71 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -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; } diff --git a/core/sourcemod.h b/core/sourcemod.h index 6f3460bf..c675d22d 100644 --- a/core/sourcemod.h +++ b/core/sourcemod.h @@ -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 diff --git a/core/systems/ExtensionSys.cpp b/core/systems/ExtensionSys.cpp index 6be78c36..b09aefd8 100644 --- a/core/systems/ExtensionSys.cpp +++ b/core/systems/ExtensionSys.cpp @@ -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 */ diff --git a/core/systems/ExtensionSys.h b/core/systems/ExtensionSys.h index ae294182..e714cb8b 100644 --- a/core/systems/ExtensionSys.h +++ b/core/systems/ExtensionSys.h @@ -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); diff --git a/core/systems/LibrarySys.cpp b/core/systems/LibrarySys.cpp index 63784c88..76e2f2df 100644 --- a/core/systems/LibrarySys.cpp +++ b/core/systems/LibrarySys.cpp @@ -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 diff --git a/core/systems/LibrarySys.h b/core/systems/LibrarySys.h index df35b2f7..7b15e062 100644 --- a/core/systems/LibrarySys.h +++ b/core/systems/LibrarySys.h @@ -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, ...); }; diff --git a/core/systems/PluginSys.cpp b/core/systems/PluginSys.cpp index fbfa8ee9..9fc1615a 100644 --- a/core/systems/PluginSys.cpp +++ b/core/systems/PluginSys.cpp @@ -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; diff --git a/core/systems/PluginSys.h b/core/systems/PluginSys.h index 075c738a..ba0a2b5f 100644 --- a/core/systems/PluginSys.h +++ b/core/systems/PluginSys.h @@ -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); diff --git a/public/IExtensionSys.h b/public/IExtensionSys.h index 8dfab75d..d8ce50dd 100644 --- a/public/IExtensionSys.h +++ b/public/IExtensionSys.h @@ -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. diff --git a/public/ILibrarySys.h b/public/ILibrarySys.h index 18dfbc1a..2af2d162 100644 --- a/public/ILibrarySys.h +++ b/public/ILibrarySys.h @@ -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 diff --git a/public/IPluginSys.h b/public/IPluginSys.h index f9154c3d..451f4334 100644 --- a/public/IPluginSys.h +++ b/public/IPluginSys.h @@ -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; /**