diff --git a/metamod/src/commands_meta.cpp b/metamod/src/commands_meta.cpp index 91c599b..c7a7b3e 100644 --- a/metamod/src/commands_meta.cpp +++ b/metamod/src/commands_meta.cpp @@ -356,7 +356,7 @@ void cmd_doplug(PLUG_CMD pcmd) } // Output to both places, because we don't want the admin // to miss this.. - if (!findp && meta_errno == ME_NOTUNIQ) + if (!findp /*&& meta_errno == ME_NOTUNIQ*/) // TODO { META_ERROR("Unique match for required plugin '%s' was not found! Exiting.", arg); META_CONS("\nERROR: Unique match for required plugin '%s' was not found! Exiting.\n", arg); @@ -378,7 +378,7 @@ void cmd_doplug(PLUG_CMD pcmd) if (!findp) { - if (meta_errno == ME_NOTUNIQ) + if (false /*meta_errno == ME_NOTUNIQ*/) // TODO META_CONS("Couldn't find unique plugin matching '%s'", arg); else META_CONS("Couldn't find plugin matching '%s'", arg); @@ -407,7 +407,7 @@ void cmd_doplug(PLUG_CMD pcmd) META_CONS("Unloaded plugin '%s'", findp->desc); g_plugins->show(); } - else if (meta_errno == ME_DELAYED) + else if (false /*meta_errno == ME_DELAYED*/) // TODO META_CONS("Unload delayed for plugin '%s'", findp->desc); else META_CONS("Unload failed for plugin '%s'", findp->desc); @@ -430,9 +430,9 @@ void cmd_doplug(PLUG_CMD pcmd) findp->action = PA_RELOAD; if (findp->reload(PT_ANYTIME, PNL_COMMAND)) META_CONS("Reloaded plugin '%s'", findp->desc); - else if (meta_errno == ME_DELAYED) + else if (0/*meta_errno == ME_DELAYED*/) META_CONS("Reload delayed for plugin '%s'", findp->desc); - else if (meta_errno == ME_NOTALLOWED) + else if (0/*meta_errno == ME_NOTALLOWED*/) META_CONS("Reload not allowed for plugin '%s' now, only allowed %s", findp->desc, findp->str_loadable(SL_ALLOWED)); else META_CONS("Reload failed for plugin '%s'", findp->desc); diff --git a/metamod/src/conf_meta.cpp b/metamod/src/conf_meta.cpp index b492472..64ce70e 100644 --- a/metamod/src/conf_meta.cpp +++ b/metamod/src/conf_meta.cpp @@ -22,7 +22,7 @@ option_t *MConfig::find(const char* lookup) const } } - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } bool MConfig::set(const char* key, const char* value) const @@ -31,7 +31,7 @@ bool MConfig::set(const char* key, const char* value) const if (optp) return set(optp, value); - RETURN_ERRNO(false, ME_NOTFOUND); + return false; } bool MConfig::set(option_t* setp, const char* setstr) @@ -51,7 +51,7 @@ bool MConfig::set(option_t* setp, const char* setstr) if (!isdigit(setstr[0])) { META_ERROR("option '%s' invalid format '%s'", setp->name, setstr); - RETURN_ERRNO(false, ME_FORMAT); + return false; } *optval = Q_atoi(setstr); META_DEBUG(3, ("set config int: %s = %d", setp->name, *optval)); @@ -69,7 +69,7 @@ bool MConfig::set(option_t* setp, const char* setstr) { META_ERROR("option '%s' invalid format '%s'", setp->name, setstr); - RETURN_ERRNO(false, ME_FORMAT); + return false; } META_DEBUG(3, ("set config bool: %s = %s", setp->name, *optval ? "true" : "false")); break; @@ -88,7 +88,7 @@ bool MConfig::set(option_t* setp, const char* setstr) break; default: META_ERROR("unrecognized config type '%d'", setp->type); - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } return true; @@ -111,7 +111,7 @@ bool MConfig::load(const char* fn) if (!fp) { META_ERROR("unable to open config file '%s': %s", loadfile, strerror(errno)); - RETURN_ERRNO(false, ME_NOFILE); + return false; } META_DEBUG(2, ("Loading from config file: %s", loadfile)); diff --git a/metamod/src/game_support.cpp b/metamod/src/game_support.cpp index 2dd35a9..80fed2b 100644 --- a/metamod/src/game_support.cpp +++ b/metamod/src/game_support.cpp @@ -121,7 +121,7 @@ bool setup_gamedll(gamedll_t *gamedll) else { // Neither known-list found a gamedll. - RETURN_ERRNO(false, ME_NOTFOUND); + return false; } Q_snprintf(gamedll->pathname, sizeof(gamedll->pathname), "%s/dlls/%s", gamedll->gamedir, knownfn); diff --git a/metamod/src/log_meta.cpp b/metamod/src/log_meta.cpp index 5f099ed..a321f87 100644 --- a/metamod/src/log_meta.cpp +++ b/metamod/src/log_meta.cpp @@ -15,12 +15,11 @@ static void buffered_ALERT(MLOG_SERVICE service, ALERT_TYPE atype, const char *p // Print to console. void META_CONS(const char *fmt, ...) { - va_list ap; char buf[MAX_LOGMSG_LEN]; - unsigned int len; + va_list ap; va_start(ap, fmt); - len = Q_vsnprintf(buf, sizeof buf, fmt, ap); + size_t len = Q_vsnprintf(buf, sizeof buf - 1, fmt, ap); va_end(ap); buf[len] = '\n'; @@ -43,7 +42,6 @@ void META_DEV(const char *fmt, ...) void META_INFO(const char *fmt, ...) { va_list ap; - va_start(ap, fmt); buffered_ALERT(mlsIWEL, at_logged, "[META] INFO:", fmt, ap); va_end(ap); @@ -52,7 +50,6 @@ void META_INFO(const char *fmt, ...) void META_WARNING(const char *fmt, ...) { va_list ap; - va_start(ap, fmt); buffered_ALERT(mlsIWEL, at_logged, "[META] WARNING:", fmt, ap); va_end(ap); @@ -61,7 +58,6 @@ void META_WARNING(const char *fmt, ...) void META_ERROR(const char *fmt, ...) { va_list ap; - va_start(ap, fmt); buffered_ALERT(mlsIWEL, at_logged, "[META] ERROR:", fmt, ap); va_end(ap); @@ -70,7 +66,6 @@ void META_ERROR(const char *fmt, ...) void META_LOG(const char *fmt, ...) { va_list ap; - va_start(ap, fmt); buffered_ALERT(mlsIWEL, at_logged, "[META]", fmt, ap); va_end(ap); @@ -79,12 +74,11 @@ void META_LOG(const char *fmt, ...) // Print to client. void META_CLIENT(edict_t *pEntity, const char *fmt, ...) { - va_list ap; char buf[MAX_CLIENTMSG_LEN]; - unsigned int len; + va_list ap; va_start(ap, fmt); - len = Q_vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + size_t len = Q_vsnprintf(buf, sizeof buf - 1, fmt, ap); va_end(ap); buf[len] = '\n'; diff --git a/metamod/src/log_meta.h b/metamod/src/log_meta.h index 3e16ed7..724fb25 100644 --- a/metamod/src/log_meta.h +++ b/metamod/src/log_meta.h @@ -1,42 +1,6 @@ #pragma once #include "enginecallbacks.h" // ALERT, etc -#include "sdk_util.h" // UTIL_VarArgs, etc - -// Debug logging. -// -// This is done as a macro, rather than a function. This way, you can add -// DEBUG statements all over, without worrying about performance -// implications. If the debugging level is set low, all those statements -// will only generate a simple float/int compare each; if we were to use a -// function instead of a macro, it would end up wasting a lot of cpu cycles -// calling/returning from the function every time. With a fair number of -// DEBUG statements, or if they're placed in frequently excuted code, the -// overhead of the wasted function calls could significantly impact server -// performance. -// -// For this reason, we also compare directly to the float value of the -// cvar, rather than calling CVAR_GET_FLOAT() and thus generating a string -// compare for each DEBUG statement. -// -// Called as: -// META_DEBUG(3, ("return code: %d", ret)); -// -// Note the double parens, and the missing parens around "args" in the -// macro itself. Note also the "do..while(0)" loop wrapping the -// statements, so they become a single statement when expanded, necessary -// for times when it might be called as a single-statement result of an -// else (or other flow control). -// -// As suggested by Jussi Kivilinna: Use "if (meta_debug.value < level); else -// DO(something);" style because "meta_debug.value < level" is in most common -// case "false". Check disasm, contitional jumps are predicted not to be -// taken by CPU. -// -// Yes, it's all a bit of a hack. - -#define META_DEBUG(level, args) \ - do { if (meta_debug.value < level) break; else ALERT(at_logged, "[META] (debug:%d) %s\n", level, UTIL_VarArgs args ); } while(0) // max buffer size for printed messages #define MAX_LOGMSG_LEN 1024 @@ -46,11 +10,13 @@ extern cvar_t meta_debug; -// META_DEV provides debug logging via the cvar "developer" (when set to 1) -// and uses a function call rather than a macro as it's really intended to -// be used only during startup, before meta_debug has been set from reading -// server.cfg. -// NOTE: META_DEV has now been mostly obsoleted in the code. +template +void META_DEBUG(int level, t_args... args) +{ + if (meta_debug.value < level) + return; + ALERT(at_logged, "[META] (debug:%i) %s\n", level, args...); +} void META_CONS(const char *fmt, ...); void META_DEV(const char *fmt, ...); diff --git a/metamod/src/metamod.cpp b/metamod/src/metamod.cpp index 540891e..961df08 100644 --- a/metamod/src/metamod.cpp +++ b/metamod/src/metamod.cpp @@ -257,7 +257,7 @@ bool meta_init_gamedll(void) if (!_getcwd(buf, sizeof(buf))) { META_WARNING("dll: Couldn't get cwd; %s", strerror(errno)); - RETURN_ERRNO(false, ME_NULLRESULT); + return false; } Q_snprintf(GameDLL.gamedir, sizeof(GameDLL.gamedir), "%s/%s", buf, gamedir); @@ -295,7 +295,7 @@ bool meta_load_gamedll(void) if (!GameDLL.sys_module.load(GameDLL.pathname)) { META_ERROR("dll: Couldn't load game DLL %s: %s", GameDLL.pathname, CSysModule::getloaderror()); - RETURN_ERRNO(false, ME_DLOPEN); + return false; } // prepare meta_engfuncs @@ -313,7 +313,7 @@ bool meta_load_gamedll(void) else { META_ERROR("dll: Couldn't find GiveFnptrsToDll() in game DLL '%s'", GameDLL.name); - RETURN_ERRNO(false, ME_DLMISSING); + return false; } // TODO @@ -373,7 +373,7 @@ bool meta_load_gamedll(void) if (!found) { META_ERROR("dll: Couldn't find either GetEntityAPI nor GetEntityAPI2 in game DLL '%s'", GameDLL.name); - RETURN_ERRNO(false, ME_DLMISSING); + return false; } // prepare gamedll callbacks diff --git a/metamod/src/mlist.cpp b/metamod/src/mlist.cpp index 848bf80..5425ebe 100644 --- a/metamod/src/mlist.cpp +++ b/metamod/src/mlist.cpp @@ -24,7 +24,7 @@ MPluginList::MPluginList(const char* ifile) : max_loaded_count(0) MPlugin *MPluginList::find(module_handle_t handle) { if (!handle) - RETURN_ERRNO(NULL, ME_ARGUMENT); + return NULL; for (int i = 0; i < max_loaded_count; i++) { @@ -34,7 +34,7 @@ MPlugin *MPluginList::find(module_handle_t handle) return &plist[i]; } - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } // Find a plugin based on the plugin index #. @@ -44,11 +44,11 @@ MPlugin *MPluginList::find(module_handle_t handle) MPlugin *MPluginList::find(int pindex) { if (pindex <= 0) - RETURN_ERRNO(NULL, ME_ARGUMENT); + return NULL; auto pfound = &plist[pindex - 1]; if (pfound->status < PL_VALID) - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; else return pfound; } @@ -60,7 +60,7 @@ MPlugin *MPluginList::find(int pindex) MPlugin *MPluginList::find(plid_t id) { if (!id) - RETURN_ERRNO(NULL, ME_ARGUMENT); + return NULL; for (int i = 0; i < max_loaded_count; i++) { @@ -71,7 +71,7 @@ MPlugin *MPluginList::find(plid_t id) return &plist[i]; } - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } // Find a plugin with the given pathname. @@ -81,7 +81,7 @@ MPlugin *MPluginList::find(plid_t id) MPlugin *MPluginList::find(const char* findpath) { if (!findpath) - RETURN_ERRNO(NULL, ME_ARGUMENT); + return NULL; META_DEBUG(8, ("Looking for loaded plugin with dlfnamepath: %s", findpath)); @@ -100,7 +100,7 @@ MPlugin *MPluginList::find(const char* findpath) } META_DEBUG(8, ("No loaded plugin found with path: %s", findpath)); - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } // Find a plugin that uses the given memory location. @@ -130,7 +130,7 @@ MPlugin *MPluginList::find_match(const char *prefix) if (!prefix) { - RETURN_ERRNO(NULL, ME_ARGUMENT); + return NULL; } pfound = NULL; @@ -145,7 +145,7 @@ MPlugin *MPluginList::find_match(const char *prefix) if (iplug->info && Q_strnicmp(iplug->info->name, prefix, len) == 0) { if (pfound) - RETURN_ERRNO(NULL, ME_NOTUNIQ); + return NULL; pfound = iplug; continue; @@ -153,7 +153,7 @@ MPlugin *MPluginList::find_match(const char *prefix) else if (Q_strnicmp(iplug->desc, prefix, len) == 0) { if (pfound) - RETURN_ERRNO(NULL, ME_NOTUNIQ); + return NULL; pfound = iplug; continue; @@ -161,7 +161,7 @@ MPlugin *MPluginList::find_match(const char *prefix) else if (Q_strnicmp(iplug->file, prefix, len) == 0) { if (pfound) - RETURN_ERRNO(NULL, ME_NOTUNIQ); + return NULL; pfound = iplug; continue; @@ -169,7 +169,7 @@ MPlugin *MPluginList::find_match(const char *prefix) else if (Q_strnicmp(iplug->file, buf, Q_strlen(buf)) == 0) { if (pfound) - RETURN_ERRNO(NULL, ME_NOTUNIQ); + return NULL; pfound = iplug; continue; @@ -177,7 +177,7 @@ MPlugin *MPluginList::find_match(const char *prefix) else if (iplug->info && Q_strnicmp(iplug->info->logtag, prefix, len) == 0) { if (pfound) - RETURN_ERRNO(NULL, ME_NOTUNIQ); + return NULL; pfound = iplug; continue; @@ -187,7 +187,7 @@ MPlugin *MPluginList::find_match(const char *prefix) if (pfound) return pfound; - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } // Find a plugin with same file, logtag, desc or significant @@ -201,7 +201,7 @@ MPlugin *MPluginList::find_match(MPlugin* pmatch) MPlugin *iplug, *pfound; if (!pmatch) { - RETURN_ERRNO(NULL, ME_ARGUMENT); + return NULL; } pfound = NULL; @@ -218,7 +218,7 @@ MPlugin *MPluginList::find_match(MPlugin* pmatch) if (pfound) return pfound; - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTIME now) @@ -229,27 +229,27 @@ MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTI if (!(pl_loader = find(plid))) { META_DEBUG(1, ("Couldn't find plugin that gave this loading request!")); - RETURN_ERRNO(NULL, ME_BADREQ); + return NULL; } Q_memset(&pl_temp, 0, sizeof(pl_temp)); if (!pl_temp.plugin_parseline(fname, pl_loader->index)) { - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } if (pl_temp.resolve() != true) { META_DEBUG(1, ("Couldn't resolve given path into a file: %s", pl_temp.file)); - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } if ((pl_found = find(pl_temp.pathname))) { META_DEBUG(1, ("Plugin '%s' already in current list; file=%s desc='%s'", pl_temp.file, pl_found->file, pl_found->desc)); - RETURN_ERRNO(NULL, ME_ALREADY); + return NULL; } if (!(pl_added = add(&pl_temp))) @@ -261,7 +261,7 @@ MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTI pl_added->action = PA_LOAD; if (!pl_added->load(now)) { - if (meta_errno == ME_NOTALLOWED || meta_errno == ME_DELAYED) + if (1/*meta_errno == ME_NOTALLOWED || meta_errno == ME_DELAYED*/) { META_DEBUG(1, ("Plugin '%s' couldn't attach; only allowed %s", pl_added->desc, pl_added->str_loadable(SL_ALLOWED))); pl_added->clear(); @@ -278,7 +278,6 @@ MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTI } META_DEBUG(1, ("Loaded plugin '%s' successfully", pl_added->desc)); - meta_errno = ME_NOERROR; return pl_added; } @@ -308,7 +307,7 @@ MPlugin* MPluginList::add(MPlugin* padd) if (!iplug) { META_ERROR("Couldn't add plugin '%s' to list; reached max plugins (%d)", padd->file, MAX_PLUGINS); - RETURN_ERRNO(NULL, ME_MAXREACHED); + return NULL; } // copy filename into this free slot @@ -350,7 +349,7 @@ bool MPluginList::ini_startup() if (!valid_gamedir_file(inifile)) { META_ERROR("ini: Metamod plugins file empty or missing: %s", inifile); - RETURN_ERRNO(false, ME_NOFILE); + return false; } full_gamedir_path(inifile, inifile); @@ -358,7 +357,7 @@ bool MPluginList::ini_startup() if (!fp) { META_ERROR("ini: Unable to open plugins file '%s': %s", inifile, strerror(errno)); - RETURN_ERRNO(false, ME_NOFILE); + return false; } META_LOG("ini: Begin reading plugins list: %s", inifile); @@ -375,10 +374,7 @@ bool MPluginList::ini_startup() // Parse directly into next entry in array if (!plist[n].ini_parseline(line)) { - if (meta_errno == ME_FORMAT) - { - META_ERROR("ini: Skipping malformed line %d of %s", ln, inifile); - } + META_ERROR("ini: Skipping malformed line %d of %s", ln, inifile); continue; } // Check for a duplicate - an existing entry with this pathname. @@ -435,7 +431,7 @@ bool MPluginList::ini_refresh() if (!fp) { META_ERROR("ini: Unable to open plugins file '%s': %s", inifile, strerror(errno)); - RETURN_ERRNO(false, ME_NOFILE); + return false; } META_LOG("ini: Begin re-reading plugins list: %s", inifile); @@ -453,10 +449,7 @@ bool MPluginList::ini_refresh() Q_memset(&pl_temp, 0, sizeof(pl_temp)); if (!pl_temp.ini_parseline(line)) { - if (meta_errno == ME_FORMAT) - { - META_ERROR("ini: Skipping malformed line %d of %s",ln, inifile); - } + META_ERROR("ini: Skipping malformed line %d of %s",ln, inifile); continue; } // Try to find plugin with this pathname in the current list of @@ -510,7 +503,7 @@ bool MPluginList::ini_refresh() // since we last loaded it. if (!pl_found->newer_file()) { - if (meta_errno == ME_NOFILE) + if (1/*meta_errno == ME_NOFILE*/) { META_ERROR("ini: Skipping plugin, couldn't stat file '%s': %s", pl_found->pathname, strerror(errno)); continue; @@ -588,7 +581,7 @@ bool MPluginList::cmd_addload(const char* args) { // Already in list META_CONS("Plugin '%s' already in current list; file=%s desc='%s'", pl_temp.file, pl_found->file, pl_found->desc); - RETURN_ERRNO(false, ME_ALREADY); + return false; } // new plugin; add to list if (!(pl_added = add(&pl_temp))) @@ -603,9 +596,9 @@ bool MPluginList::cmd_addload(const char* args) if (!pl_added->load(PT_ANYTIME)) { // load failed - if (meta_errno == ME_DELAYED) + if (1/*meta_errno == ME_DELAYED*/) META_CONS("Loaded plugin '%s', but will wait to become active, %s", pl_added->desc, pl_added->str_loadable(SL_ALLOWED)); - else if (meta_errno == ME_NOTALLOWED) + else if (1/*meta_errno == ME_NOTALLOWED*/) { META_CONS("Plugin '%s' couldn't attach; only allowed %s", pl_added->desc, pl_added->str_loadable(SL_ALLOWED)); pl_added->clear(); @@ -694,14 +687,14 @@ bool MPluginList::refresh(PLUG_LOADTIME now) META_DEBUG(1, ("Loading plugin '%s'", iplug->desc)); if (iplug->load(now)) nloaded++; - else if (meta_errno == ME_DELAYED) + else if (1/*meta_errno == ME_DELAYED*/) ndelayed++; break; case PA_RELOAD: META_DEBUG(1, ("Reloading plugin '%s'", iplug->desc)); if (iplug->reload(now, PNL_FILE_NEWER)) nreloaded++; - else if (meta_errno == ME_DELAYED) + else if (1/*meta_errno == ME_DELAYED*/) ndelayed++; break; case PA_NONE: @@ -712,7 +705,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now) iplug->action = PA_UNLOAD; if (iplug->unload(now, PNL_INI_DELETED, PNL_INI_DELETED)) nunloaded++; - else if (meta_errno == ME_DELAYED) + else if (1/*meta_errno == ME_DELAYED*/) ndelayed++; } break; @@ -721,7 +714,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now) META_DEBUG(1, ("Retrying attach plugin '%s'", iplug->desc)); if (iplug->retry(now, PNL_DELAYED)) nloaded++; - else if (meta_errno == ME_DELAYED) + else if (1/*meta_errno == ME_DELAYED*/) ndelayed++; break; case PA_UNLOAD: @@ -729,7 +722,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now) META_DEBUG(1, ("Retrying unload plugin '%s'", iplug->desc)); if (iplug->retry(now, PNL_DELAYED)) nunloaded++; - else if (meta_errno == ME_DELAYED) + else if (1/*meta_errno == ME_DELAYED*/) ndelayed++; break; case PA_NULL: diff --git a/metamod/src/mplayer.cpp b/metamod/src/mplayer.cpp index 911cbd5..b95d829 100644 --- a/metamod/src/mplayer.cpp +++ b/metamod/src/mplayer.cpp @@ -14,7 +14,6 @@ void MPlayer::set_cvar_query(const char *cvar) // client cvar is queried. if (!cvar) { - meta_errno = ME_ARGUMENT; return; } @@ -80,5 +79,5 @@ const char *MPlayerList::is_querying_cvar(const edict_t *pEntity) const if (indx >= 1 && indx <= gpGlobals->maxClients) return players[indx].is_querying_cvar(); - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } diff --git a/metamod/src/mplugin.cpp b/metamod/src/mplugin.cpp index 99335bc..e337410 100644 --- a/metamod/src/mplugin.cpp +++ b/metamod/src/mplugin.cpp @@ -22,19 +22,19 @@ bool MPlugin::ini_parseline(char *line) if (line[0] == '\0') { META_DEBUG(7, ("ini: Ignoring empty line: %s", line)); - RETURN_ERRNO(false, ME_BLANK); + return false; } if (line[0] == '#' || line[0] == ';' || Q_strstr(line, "//") == line) { META_DEBUG(7, ("ini: Ignoring commented line: %s", line)); - RETURN_ERRNO(false, ME_COMMENT); + return false; } // grab platform ("win32" or "linux") token = strtok_r(line, " \t", &ptr_token); if (!token) - RETURN_ERRNO(false, ME_FORMAT); + return false; if (Q_stricmp(token, PLATFORM) == 0) { pfspecific = 0; @@ -47,14 +47,14 @@ bool MPlugin::ini_parseline(char *line) { // plugin is not for this OS META_DEBUG(7, ("ini: Ignoring entry for %s", token)); - RETURN_ERRNO(false, ME_OSNOTSUP); + return false; } // grab filename token = strtok_r(NULL, " \t\r\n", &ptr_token); if (!token) { - RETURN_ERRNO(false, ME_FORMAT); + return false; } Q_strncpy(filename, token, sizeof filename - 1); @@ -104,17 +104,17 @@ bool MPlugin::plugin_unload(plid_t plid, PLUG_LOADTIME now, PL_UNLOAD_REASON rea if (!(pl_unloader = g_plugins->find(plid))) { META_WARNING("dll: Not unloading plugin '%s'; plugin that requested unload is not found.", desc); - RETURN_ERRNO(false, ME_BADREQ); + return false; } else if (pl_unloader->index == index) { META_WARNING("dll: Not unloading plugin '%s'; Plugin tried to unload itself.", desc); - RETURN_ERRNO(false, ME_UNLOAD_SELF); + return false; } else if (is_unloader) { META_WARNING("dll: Not unloading plugin '%s'; Plugin is unloading plugin that tried to unload it.", desc); - RETURN_ERRNO(false, ME_UNLOAD_UNLOADER); + return false; } else { @@ -137,10 +137,9 @@ bool MPlugin::plugin_unload(plid_t plid, PLUG_LOADTIME now, PL_UNLOAD_REASON rea pl_unloader->is_unloader = false; //can't unload plugin now, set delayed - if (meta_errno == ME_DELAYED) + if (0/*meta_errno == ME_DELAYED*/) { action = old_action; - meta_errno = ME_NOTALLOWED; META_DEBUG(2, ("dll: Failed unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(PT_ANYTIME, SL_SIMPLE))); } @@ -196,12 +195,12 @@ bool MPlugin::cmd_parseline(const char *line) // remove "load" token = strtok_r(buf, " \t", &ptr_token); if (!token) - RETURN_ERRNO(false, ME_FORMAT); + return false; // grab filename token = strtok_r(NULL, " \t", &ptr_token); if (!token) - RETURN_ERRNO(false, ME_FORMAT); + return false; Q_strncpy(filename, token, sizeof filename - 1); filename[sizeof filename - 1] = '\0'; @@ -248,22 +247,22 @@ bool MPlugin::check_input(void) if (status < PL_VALID) { META_ERROR("dll: Tried to operate on plugin[%d] with a non-valid status (%d)", index, str_status()); - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } if (!file || !file[0]) { META_ERROR("dll: Tried to operate on plugin[%d] with an empty file", index); - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } if (!filename[0]) { META_ERROR("dll: Tried to operate on plugin[%d] with an empty filename", index); - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } if (!pathname[0]) { META_ERROR("dll: Tried to operate on plugin[%d] with an empty pathname", index); - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } if (!desc[0]) @@ -308,7 +307,7 @@ bool MPlugin::resolve(void) if (!found) { META_DEBUG(2, ("Couldn't resolve '%s' to file", filename)); - RETURN_ERRNO(false, ME_NOTFOUND); + return false; } META_DEBUG(2, ("Resolved '%s' to file '%s'", filename, found)); @@ -574,17 +573,17 @@ bool MPlugin::load(PLUG_LOADTIME now) if (!check_input()) { // details logged, meta_errno set in check_input() - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } if (status >= PL_RUNNING) { META_ERROR("dll: Not loading plugin '%s'; already loaded (status=%s)", desc, str_status()); - RETURN_ERRNO(false, ME_ALREADY); + return false; } if (action != PA_LOAD && action != PA_ATTACH) { META_ERROR("dll: Not loading plugin '%s'; not marked for load (action=%s)", desc, str_action()); - RETURN_ERRNO(false, ME_BADREQ); + return false; } if (status < PL_OPENED) @@ -593,13 +592,10 @@ bool MPlugin::load(PLUG_LOADTIME now) if (!query()) { META_ERROR("dll: Skipping plugin '%s'; couldn't query", desc); - if (meta_errno != ME_DLOPEN) - { if (!sys_module.unload()) { META_ERROR("dll: Couldn't close plugin file '%s': %s", file, "invalid handle"); } - } status = PL_BADFILE; info = NULL; //prevent crash // meta_errno should be already set in query() @@ -615,14 +611,14 @@ bool MPlugin::load(PLUG_LOADTIME now) { // will try to attach again at next opportunity META_DEBUG(2, ("dll: Delaying load plugin '%s'; can't attach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE))); - RETURN_ERRNO(false, ME_DELAYED); + return false; } else { META_DEBUG(2, ("dll: Failed load plugin '%s'; can't attach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE))); // don't try to attach again later action = PA_NONE; - RETURN_ERRNO(false, ME_NOTALLOWED); + return false; } } @@ -683,7 +679,7 @@ bool MPlugin::query(void) if (!sys_module.load(pathname)) { META_ERROR("dll: Failed query plugin '%s'; Couldn't open file '%s': %s", desc, pathname, sys_module.getloaderror()); - RETURN_ERRNO(false, ME_DLOPEN); + return false; } // First, we check to see if they have a Meta_Query. We would normally @@ -701,7 +697,7 @@ bool MPlugin::query(void) { META_ERROR("dll: Failed query plugin '%s'; Couldn't find Meta_Query(): %s", desc, "function not found"); // caller will dlclose() - RETURN_ERRNO(false, ME_DLMISSING); + return false; } // Call Meta_Init, if present. This is an optional plugin routine to @@ -736,14 +732,13 @@ bool MPlugin::query(void) // META_ERROR("dll: Couldn't find GiveFnptrsToDll() in plugin '%s': %s", desc, DLERROR()); META_ERROR("dll: Failed query plugin '%s'; Couldn't find GiveFnptrsToDll(): %s", desc, "function not found"); // caller will dlclose() - RETURN_ERRNO(false, ME_DLMISSING); + return false; } pfn_give_engfuncs(g_engine.pl_funcs, g_engine.globals); META_DEBUG(6, ("dll: Plugin '%s': Called GiveFnptrsToDll()", desc)); // Call plugin's Meta_Query(), to pass our meta interface version, and get // plugin's info structure. - meta_errno = ME_NOERROR; info = NULL; // Make a copy of the meta_util function table for each plugin, for the @@ -754,7 +749,6 @@ bool MPlugin::query(void) { META_ERROR("dll: Failed query plugin '%s'; Meta_Query returned error", desc); - meta_errno = ME_DLERROR; } else { @@ -782,14 +776,12 @@ bool MPlugin::query(void) if (pmajor > mmajor || (pmajor == mmajor && pminor > mminor)) { META_ERROR("dll: Plugin '%s' requires a newer version of Metamod (Metamod needs at least interface %s not the current %s)", desc, info->ifvers, META_INTERFACE_VERSION); - meta_errno = ME_IFVERSION; } // If plugin has older major interface version, it's incompatible // (update plugin). else if (pmajor < mmajor) { META_ERROR("dll: Plugin '%s' is out of date and incompatible with this version of Metamod; please find a newer version of the plugin (plugin needs at least interface %s not the current %s)", desc, META_INTERFACE_VERSION, info->ifvers); - meta_errno = ME_IFVERSION; } // Plugin has identical major, with older minor. This is supposed to be // backwards compatible, so we warn, but we still accept it. @@ -799,14 +791,14 @@ bool MPlugin::query(void) META_LOG("dll: Plugin '%s': unexpected version comparision; metavers=%s, mmajor=%d, mminor=%d; plugvers=%s, pmajor=%d, pminor=%d", desc, META_INTERFACE_VERSION, mmajor, mminor, info->ifvers, pmajor, pminor); } - if (meta_errno == ME_IFVERSION) + if (0/*meta_errno == ME_IFVERSION*/) { META_ERROR("dll: Rejected plugin '%s' due to interface version incompatibility (mm=%s, pl=%s)", desc, META_INTERFACE_VERSION, info->ifvers); // meta_errno is set already above // caller will dlclose() return false; } - else if (meta_errno != ME_NOERROR) + else if (0/*meta_errno != ME_NOERROR*/) // TODO // some other error, already logged return false; @@ -814,7 +806,7 @@ bool MPlugin::query(void) { META_ERROR("dll: Failed query plugin '%s'; Empty info structure", desc); // caller will dlclose() - RETURN_ERRNO(false, ME_NULLRESULT); + return false; } // Replace temporary desc with plugin's internal name. @@ -863,7 +855,7 @@ bool MPlugin::attach(PLUG_LOADTIME now) if (!gamedll_funcs.dllapi_table) { META_ERROR("dll: Failed attach plugin '%s': Failed malloc() for dllapi_table"); - RETURN_ERRNO(false, ME_NOMEM); + return false; } Q_memcpy(gamedll_funcs.dllapi_table, GameDLL.funcs.dllapi_table, sizeof(DLL_FUNCTIONS)); } @@ -873,7 +865,7 @@ bool MPlugin::attach(PLUG_LOADTIME now) if (!gamedll_funcs.newapi_table) { META_ERROR("dll: Failed attach plugin '%s': Failed malloc() for newapi_table"); - RETURN_ERRNO(false, ME_NOMEM); + return false; } static_cast(gamedll_funcs.newapi_table)->set_from(GameDLL.funcs.newapi_table); } @@ -881,7 +873,7 @@ bool MPlugin::attach(PLUG_LOADTIME now) { META_ERROR("dll: Failed attach plugin '%s': Couldn't find Meta_Attach(): %s", desc, "function not found"); // caller will dlclose() - RETURN_ERRNO(false, ME_DLMISSING); + return false; } Q_memset(&meta_table, 0, sizeof(meta_table)); @@ -892,7 +884,7 @@ bool MPlugin::attach(PLUG_LOADTIME now) { META_ERROR("dll: Failed attach plugin '%s': Error from Meta_Attach(): %d", desc, ret); // caller will dlclose() - RETURN_ERRNO(false, ME_DLERROR); + return false; } META_DEBUG(6, ("dll: Plugin '%s': Called Meta_Attach() successfully", desc)); @@ -996,20 +988,20 @@ bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, PL_UNLOAD_REASO if (!check_input()) { // details logged, meta_errno set in check_input() - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } if (status < PL_RUNNING) { if (reason != PNL_CMD_FORCED && reason != PNL_RELOAD) { META_ERROR("dll: Not unloading plugin '%s'; already unloaded (status=%s)", desc, str_status()); - RETURN_ERRNO(false, ME_ALREADY); + return false; } } if (action != PA_UNLOAD && action != PA_RELOAD) { META_WARNING("dll: Not unloading plugin '%s'; not marked for unload (action=%s)", desc, str_action()); - RETURN_ERRNO(false, ME_BADREQ); + return false; } // Are we allowed to detach this plugin at this time? @@ -1027,14 +1019,14 @@ bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, PL_UNLOAD_REASO META_DEBUG(2, ("dll: Delaying unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE))); // caller should give message to user // try to unload again at next opportunity - RETURN_ERRNO(false, ME_DELAYED); + return false; } else { META_DEBUG(2, ("dll: Failed unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE))); // don't try to unload again later action = PA_NONE; - RETURN_ERRNO(false, ME_NOTALLOWED); + return false; } } } @@ -1121,14 +1113,14 @@ bool MPlugin::detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) { META_ERROR("dll: Error detach plugin '%s': Couldn't find Meta_Detach(): %s", desc, "function not found"); // caller will dlclose() - RETURN_ERRNO(false, ME_DLMISSING); + return false; } ret = pfn_detach(now, reason); if (ret != TRUE) { META_ERROR("dll: Failed detach plugin '%s': Error from Meta_Detach(): %d", desc, ret); - RETURN_ERRNO(false, ME_DLERROR); + return false; } META_DEBUG(6, ("dll: Plugin '%s': Called Meta_Detach() successfully", desc)); @@ -1146,7 +1138,7 @@ bool MPlugin::reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) if (!check_input()) { // details logged, meta_errno set in check_input() - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } // Are we allowed to load this plugin at this time? // If we cannot load the plugin after unloading it, we keep it. @@ -1157,14 +1149,14 @@ bool MPlugin::reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) META_DEBUG(2, ("dll: Delaying reload plugin '%s'; would not be able to reattach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE))); // caller should give message to user // try to reload again at next opportunity - RETURN_ERRNO(false, ME_DELAYED); + return false; } else { META_DEBUG(2, ("dll: Failed reload plugin '%s'; would not be able to reattach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE))); // don't try to reload again later action = PA_NONE; - RETURN_ERRNO(false, ME_NOTALLOWED); + return false; } } @@ -1201,12 +1193,12 @@ bool MPlugin::pause() if (status == PL_PAUSED) { META_ERROR("Not pausing plugin '%s'; already paused", desc); - RETURN_ERRNO(false, ME_ALREADY); + return false; } if (status != PL_RUNNING) { META_ERROR("Cannot pause plugin '%s'; not currently running (status=%s)", desc, str_status()); - RETURN_ERRNO(false, ME_BADREQ); + return false; } // are we allowed to pause this plugin? @@ -1214,7 +1206,7 @@ bool MPlugin::pause() { META_ERROR("Cannot pause plugin '%s'; not allowed by plugin (allowed=%s)", desc, str_unloadable()); action = PA_NONE; - RETURN_ERRNO(false, ME_NOTALLOWED); + return false; } status = PL_PAUSED; @@ -1230,7 +1222,7 @@ bool MPlugin::unpause() if (status != PL_PAUSED) { META_ERROR("Cannot unpause plugin '%s'; not currently paused (status=%s)", desc, str_status()); - RETURN_ERRNO(false, ME_BADREQ); + return false; } status = PL_RUNNING; @@ -1257,7 +1249,7 @@ bool MPlugin::retry(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) else { META_ERROR("No pending action to retry for plugin '%s'; (status=%s, action=%s)", desc, str_status(), str_action()); - RETURN_ERRNO(false, ME_BADREQ); + return false; } } @@ -1271,7 +1263,7 @@ bool MPlugin::clear(void) if (status != PL_FAILED && status != PL_BADFILE && status != PL_EMPTY && status != PL_OPENED) { META_ERROR("Cannot clear plugin '%s'; not marked as failed, empty, or open (status=%s)", desc, str_status()); - RETURN_ERRNO(false, ME_BADREQ); + return false; } // If file is open, close the file. Note: after this, attempts to // reference any memory locations in the file will produce a segfault. @@ -1279,7 +1271,7 @@ bool MPlugin::clear(void) { META_ERROR("dll: Couldn't close plugin file '%s': %s", file, "invalid handle"); status = PL_FAILED; - RETURN_ERRNO(false, ME_DLERROR); + return false; } if (gamedll_funcs.dllapi_table) Q_free(gamedll_funcs.dllapi_table); @@ -1417,14 +1409,14 @@ bool MPlugin::newer_file() time_t file_time; if (stat(pathname, &st) != 0) - RETURN_ERRNO(false, ME_NOFILE); + return false; file_time = st.st_ctime > st.st_mtime ? st.st_ctime : st.st_mtime; META_DEBUG(5, ("newer_file? file=%s; load=%d, file=%d; ctime=%d, mtime=%d", file, time_loaded, file_time, st.st_ctime, st.st_mtime)); if (file_time > time_loaded) return true; else - RETURN_ERRNO(false, ME_NOERROR); + return false; } // Return a string describing status of plugin. diff --git a/metamod/src/mreg.cpp b/metamod/src/mreg.cpp index b6c7e54..4dcc2b2 100644 --- a/metamod/src/mreg.cpp +++ b/metamod/src/mreg.cpp @@ -149,7 +149,7 @@ bool MRegCvar::set(cvar_t *src) const if (Q_stricmp(src->name, data->name)) { META_ERROR("Tried to set cvar with mismatched name; src=%s dst=%s", src->name, data->name); - RETURN_ERRNO(false, ME_ARGUMENT); + return false; } // Would like to free() existing string, but can't tell where it was @@ -192,7 +192,7 @@ MRegCvar *MRegCvarList::add(const char *addname) if (!temp) { META_ERROR("Couldn't grow registered cvar list to %d for '%s'; %s", newsize, addname, strerror(errno)); - RETURN_ERRNO(NULL, ME_NOMEM); + return NULL; } vlist = temp; size = newsize; @@ -212,14 +212,14 @@ MRegCvar *MRegCvarList::add(const char *addname) if (!icvar->data) { META_ERROR("Couldn't malloc cvar for adding reg cvar name '%s': %s", addname, strerror(errno)); - RETURN_ERRNO(NULL, ME_NOMEM); + return NULL; } icvar->data->name = Q_strdup(addname); if (!icvar->data->name) { META_ERROR("Couldn't Q_strdup for adding reg cvar name '%s': %s", addname, strerror(errno)); - RETURN_ERRNO(NULL, ME_NOMEM); + return NULL; } endlist++; return icvar; @@ -236,7 +236,7 @@ MRegCvar *MRegCvarList::find(const char *findname) return &vlist[i]; } - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } // Disable any cvars belonging to the given plugin (by index id). @@ -351,7 +351,7 @@ MRegMsg *MRegMsgList::add(const char *addname, int addmsgid, int addsize) { // all slots used META_ERROR("Couldn't add registered msg '%s' to list; reached max msgs (%d)", addname, size); - RETURN_ERRNO(NULL, ME_MAXREACHED); + return NULL; } MRegMsg *imsg = &mlist[endlist]; @@ -378,7 +378,7 @@ MRegMsg *MRegMsgList::find(const char *findname) return &mlist[i]; } - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } // Try to find a registered msg with the given msgid. @@ -392,7 +392,7 @@ MRegMsg *MRegMsgList::find(int findmsgid) return &mlist[i]; } - RETURN_ERRNO(NULL, ME_NOTFOUND); + return NULL; } // List the registered usermsgs for the gamedll. diff --git a/metamod/src/mutil.cpp b/metamod/src/mutil.cpp index 3604191..42e3a68 100644 --- a/metamod/src/mutil.cpp +++ b/metamod/src/mutil.cpp @@ -254,16 +254,15 @@ int EXT_FUNC mutil_LoadMetaPlugin(plid_t plid, const char* fname, PLUG_LOADTIME MPlugin *pl_loaded; if (!fname) { - return ME_ARGUMENT; + return 1; } - meta_errno = ME_NOERROR; if (!(pl_loaded = g_plugins->plugin_addload(plid, fname, now))) { if (plugin_handle) *plugin_handle = nullptr; - return meta_errno; + return 1; } else { @@ -281,7 +280,7 @@ int EXT_FUNC mutil_UnloadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIM if (!fname) { - return ME_ARGUMENT; + return 1; } pindex = strtol(fname, &endptr, 10); @@ -291,14 +290,12 @@ int EXT_FUNC mutil_UnloadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIM findp = g_plugins->find_match(fname); if (!findp) - return meta_errno; - - meta_errno = ME_NOERROR; + return 1; if (findp->plugin_unload(plid, now, reason)) return 0; - return meta_errno; + return 1; } int EXT_FUNC mutil_UnloadMetaPluginByHandle(plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason) @@ -307,18 +304,16 @@ int EXT_FUNC mutil_UnloadMetaPluginByHandle(plid_t plid, void *plugin_handle, PL if (!plugin_handle) { - return ME_ARGUMENT; + return 1; } if (!(findp = g_plugins->find((module_handle_t)plugin_handle))) - return ME_NOTFOUND; - - meta_errno = ME_NOERROR; + return 1; if (findp->plugin_unload(plid, now, reason)) return 0; - return meta_errno; + return 1; } const char* EXT_FUNC mutil_IsQueryingClientCvar(plid_t plid, const edict_t* pEdict) diff --git a/metamod/src/osdep.cpp b/metamod/src/osdep.cpp index 591da38..4c9fa9c 100644 --- a/metamod/src/osdep.cpp +++ b/metamod/src/osdep.cpp @@ -172,7 +172,7 @@ bool IS_VALID_PTR(void *memptr) bool IS_VALID_PTR(void *memptr) { if (IsBadCodePtr((FARPROC) memptr)) - RETURN_ERRNO(false, ME_BADMEMPTR); + return false; else return true; } diff --git a/metamod/src/reg_support.cpp b/metamod/src/reg_support.cpp index 6d838b5..1895030 100644 --- a/metamod/src/reg_support.cpp +++ b/metamod/src/reg_support.cpp @@ -28,12 +28,12 @@ void EXT_FUNC meta_command_handler() // to a generic command-handler function (see above). void EXT_FUNC meta_AddServerCommand(char *cmd_name, void (*function)()) { - MPlugin *iplug = g_plugins->find_memloc(function); + MPlugin *plug = g_plugins->find_memloc(function); - META_DEBUG(4, ("called: meta_AddServerCommand; cmd_name=%s, function=%d", cmd_name, function)); + META_DEBUG(4, ("called: meta_AddServerCommand; cmd_name=%s, function=%d, plugin=%s", cmd_name, function, plug ? plug->file : "unknown")); // try to find which plugin is registering this command - if (!iplug) { + if (!plug) { META_ERROR("Failed to find memloc for regcmd '%s'", cmd_name); } @@ -42,7 +42,7 @@ void EXT_FUNC meta_AddServerCommand(char *cmd_name, void (*function)()) if (!icmd) { // If not found, add. - icmd = g_regCmds->add(cmd_name, function, iplug); + icmd = g_regCmds->add(cmd_name, function, plug); if (!icmd) { return; diff --git a/metamod/src/support_meta.cpp b/metamod/src/support_meta.cpp index f0ec827..96ebb79 100644 --- a/metamod/src/support_meta.cpp +++ b/metamod/src/support_meta.cpp @@ -1,7 +1,5 @@ #include "precompiled.h" -META_ERRNO meta_errno; - void __declspec(noreturn) do_exit(int exitval) { //TerminateProcess(GetCurrentProcess(), 1); diff --git a/metamod/src/types_meta.h b/metamod/src/types_meta.h index 1bdea8a..6f70f09 100644 --- a/metamod/src/types_meta.h +++ b/metamod/src/types_meta.h @@ -1,39 +1 @@ #pragma once - -// Like C's errno, for our various functions; describes causes of failure -// or false returns. -enum META_ERRNO -{ - ME_NOERROR = 0, - ME_FORMAT, // invalid format - ME_COMMENT, // ignored comment - ME_BLANK, // ignored blank (empty) line - ME_ALREADY, // request had already been done - ME_DELAYED, // request is delayed - ME_NOTALLOWED, // request not allowed - ME_SKIPPED, // request is being skipped for whatever reason - ME_BADREQ, // invalid request for this - ME_ARGUMENT, // invalid arguments - ME_NULLRESULT, // resulting data was empty or null - ME_MAXREACHED, // reached max/limit - ME_NOTUNIQ, // not unique (ambigious match) - ME_NOTFOUND, // in find operation, match not found - ME_NOFILE, // file empty or missing - ME_NOMEM, // malloc failed - ME_BADMEMPTR, // invalid memory address - ME_OSNOTSUP, // OS doesn't support this operation - ME_DLOPEN, // failed to open shared lib/dll - ME_DLMISSING, // symbol missing in lib/dll - ME_DLERROR, // some other error encountered calling functions from dll - ME_IFVERSION, // incompatible interface version - ME_UNLOAD_UNLOADER, // tried to unload unloader - ME_UNLOAD_SELF, // tried to unload self -}; - -extern META_ERRNO meta_errno; - -#define RETURN_ERRNO(retval, errval) \ - do { meta_errno = errval; return retval; } while (0) - -#define RETURN_LOGERR_ERRNO(errargs, retval, errval) \ - do { META_ERROR errargs; meta_errno = errval; return retval; } while (0)