- Main Page
- Data Structures
- Files

- File List

# E:/DevIL/src-IL/src/il_error.c

    00001 //-----------------------------------------------------------------------------
    00002 //
    00003 // ImageLib Sources
    00004 // Copyright (C) 2000-2008 by Denton Woods
    00005 // Last modified: 06/02/2007
    00006 //
    00007 // Filename: src-IL/src/il_error.c
    00008 //
    00009 // Description: The error functions
    00010 //
    00011 //-----------------------------------------------------------------------------
    00012
    00013
    00014 #include "il_internal.h"
    00015
    00016
    00017 #define IL_ERROR_STACK_SIZE 32  // Needed elsewhere?
    00018
    00019
    00020 ILenum  ilErrorNum[IL_ERROR_STACK_SIZE];
    00021 ILint   ilErrorPlace = (-1);
    00022
    00023
    00024 // Sets the current error
    00025 //      If you go past the stack size for this, it cycles the errors, almost like a LRU algo.
    00026 ILAPI void ILAPIENTRY ilSetError(ILenum Error)
    00027 {
    00028         ILuint i;
    00029
    00030         ilErrorPlace++;
    00031         if (ilErrorPlace >= IL_ERROR_STACK_SIZE) {
    00032                 for (i = 0; i < IL_ERROR_STACK_SIZE - 2; i++) {
    00033                         ilErrorNum[i] = ilErrorNum[i+1];
    00034                 }
    00035                 ilErrorPlace = IL_ERROR_STACK_SIZE - 1;
    00036         }
    00037         ilErrorNum[ilErrorPlace] = Error;
    00038
    00039         return;
    00040 }
    00041
    00042
    00044 ILenum ILAPIENTRY ilGetError(void)
    00045 {
    00046         ILenum ilReturn;
    00047
    00048         if (ilErrorPlace >= 0) {
    00049                 ilReturn = ilErrorNum[ilErrorPlace];
    00050                 ilErrorPlace--;
    00051         }
    00052         else
    00053                 ilReturn = IL_NO_ERROR;
    00054
    00055         return ilReturn;
    00056 }