diff options
author | Andrey Nazarov <skuller@skuller.net> | 2010-07-03 16:01:48 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2010-07-03 16:01:48 +0000 |
commit | 7a914ef872a436adcdb36d21ceddba6bb24eb993 (patch) | |
tree | dafc86024742e7bbced8ef897754beff5160f1ae /source/error.h | |
parent | 1acd69e9a128e4f3abf06b5ae97c968c87663864 (diff) |
Yet another huge commit.
Implemented new error reporting framework based on errno and custom error codes.
Converted filesystem code, image and model managers, BSP loader to use the new framework and report errors more accurately.
Replaced fileHandle_t with qhandle_t.
Removed INVALID_LENGTH definition.
Killed USE_LOADBUF code.
Defined FS_FileExists(Ex) macro, implemented FS_EasyOpenFile and FS_WriteFile helper functions.
When testing for free screenshot slots, open the file with O_EXCL flag to avoid race conditions (works only on glibc yet).
Don't allow quake paths with high bits set.
Don't tolerate any fatal errors encountered when searching for files and pass errors back to the caller.
FS_Seek() now fails on files from packs instead of returning an invalid position.
Fixed ‘mvdskip’ command not working properly.
Avoid inefficient usage of MakeColor macro in image loading functions.
Prevent memory leak in JPEG and PNG image functions after calling longjmp() by marking some local variables volatile.
Added support for loading monochrome JPEG images.
Fixed signed integer overflow in GetWavinfo().
Fixed missing return statement in BSP_LoadSurfEdges() causing out of range edge indices to be left uncaught.
Fixed possible access to uninitialized memory in BSP_LoadLeafs() for maps with no leafs.
Properly NUL terminate the buffer in SCR_ScoreDump_f(), also check for being in a level.
Always free latched_string when cvar is set back to current value.
Fixed a crash in ‘mvdplay’ command possible when demo file is invalid.
Diffstat (limited to 'source/error.h')
-rw-r--r-- | source/error.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/source/error.h b/source/error.h new file mode 100644 index 0000000..dab50cc --- /dev/null +++ b/source/error.h @@ -0,0 +1,65 @@ +/* +Copyright (C) 2010 skuller.net + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#define ERRNO_MAX 20000 +#if EINVAL > 0 +#define Q_ERRNO(e) ((e == Q_ERR_SUCCESS || e < -ERRNO_MAX) ? 0 : -e) +#define Q_ERR(e) (e == 0 ? Q_ERR_SUCCESS : e > ERRNO_MAX ? -ERRNO_MAX : -e) +#else +#define Q_ERRNO(e) ((e == Q_ERR_SUCCESS || e < -ERRNO_MAX) ? 0 : e) +#define Q_ERR(e) (e == 0 ? Q_ERR_SUCCESS : e < -ERRNO_MAX ? -ERRNO_MAX : e) +#endif +#define _Q_ERR(e) (-ERRNO_MAX-e) + +#define Q_ERR_SUCCESS 0 // Success +#define Q_ERR_FAILURE _Q_ERR(0) // Unspecified error +#define Q_ERR_UNKNOWN_FORMAT _Q_ERR(1) // Unknown file format +#define Q_ERR_INVALID_FORMAT _Q_ERR(2) // Invalid file format +#define Q_ERR_BAD_EXTENT _Q_ERR(3) // Bad lump extent +#define Q_ERR_ODD_SIZE _Q_ERR(4) // Odd lump size +#define Q_ERR_TOO_MANY _Q_ERR(5) // Too many elements +#define Q_ERR_TOO_FEW _Q_ERR(6) // Too few elements +#define Q_ERR_BAD_INDEX _Q_ERR(7) // Index out of range +#define Q_ERR_INVALID_PATH _Q_ERR(8) // Invalid quake path +#define Q_ERR_UNCLEAN_PATH _Q_ERR(9) // Unclean quake path +#define Q_ERR_UNEXPECTED_EOF _Q_ERR(10) // Unexpected end of file +#define Q_ERR_FILE_TOO_SMALL _Q_ERR(11) // File too small +#define Q_ERR_BAD_RLE_PACKET _Q_ERR(12) // Bad run length packet +#define Q_ERR_STRING_TRUNCATED _Q_ERR(13) // String truncated +#define Q_ERR_LIBRARY_ERROR _Q_ERR(14) // Library error +#if USE_ZLIB +#define Q_ERR_INFLATE_FAILED _Q_ERR(15) // Inflate failed +#define Q_ERR_DEFLATE_FAILED _Q_ERR(16) // Deflate failed +#define Q_ERR_NOT_COHERENT _Q_ERR(17) // Coherency check failed +#endif + +#define Q_ERR_NOENT Q_ERR(ENOENT) +#define Q_ERR_NAMETOOLONG Q_ERR(ENAMETOOLONG) +#define Q_ERR_INVAL Q_ERR(EINVAL) +#define Q_ERR_DEADLOCK Q_ERR(EDEADLK) +#define Q_ERR_NOSYS Q_ERR(ENOSYS) +#define Q_ERR_SPIPE Q_ERR(ESPIPE) +#define Q_ERR_FBIG Q_ERR(EFBIG) +#define Q_ERR_ISDIR Q_ERR(EISDIR) +#define Q_ERR_AGAIN Q_ERR(EAGAIN) +#define Q_ERR_NFILE Q_ERR(ENFILE) +#define Q_ERR_EXIST Q_ERR(EEXIST) + +const char *Q_ErrorString( qerror_t error ); |