1 //----------------------------------------------------------------------------- 2 // 3 // ImageLib Sources 4 // Copyright (C) 2000-2008 by Denton Woods 5 // Last modified: 06/02/2007 6 // 7 // Filename: src-IL/src/il_error.c 8 // 9 // Description: The error functions 10 // 11 //----------------------------------------------------------------------------- 12 13 14 #include "il_internal.h" 15 16 17 #define IL_ERROR_STACK_SIZE 32 // Needed elsewhere? 18 19 20 ILenum ilErrorNum[IL_ERROR_STACK_SIZE]; 21 ILint ilErrorPlace = (-1); 22 23 24 // Sets the current error 25 // If you go past the stack size for this, it cycles the errors, almost like a LRU algo. ilSetError(ILenum Error)26ILAPI void ILAPIENTRY ilSetError(ILenum Error) 27 { 28 ILuint i; 29 30 ilErrorPlace++; 31 if (ilErrorPlace >= IL_ERROR_STACK_SIZE) { 32 for (i = 0; i < IL_ERROR_STACK_SIZE - 2; i++) { 33 ilErrorNum[i] = ilErrorNum[i+1]; 34 } 35 ilErrorPlace = IL_ERROR_STACK_SIZE - 1; 36 } 37 ilErrorNum[ilErrorPlace] = Error; 38 39 return; 40 } 41 42 43 //! Gets the last error on the error stack ilGetError(void)44ILenum ILAPIENTRY ilGetError(void) 45 { 46 ILenum ilReturn; 47 48 if (ilErrorPlace >= 0) { 49 ilReturn = ilErrorNum[ilErrorPlace]; 50 ilErrorPlace--; 51 } 52 else 53 ilReturn = IL_NO_ERROR; 54 55 return ilReturn; 56 } 57