~ubuntu-branches/ubuntu/hoary/devil/hoary

« back to all changes in this revision

Viewing changes to src-IL/src/il_error.c

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2005-01-03 19:57:42 UTC
  • Revision ID: james.westby@ubuntu.com-20050103195742-4ipkplcwygu3irv0
Tags: upstream-1.6.7
ImportĀ upstreamĀ versionĀ 1.6.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-----------------------------------------------------------------------------
 
2
//
 
3
// ImageLib Sources
 
4
// Copyright (C) 2000-2002 by Denton Woods
 
5
// Last modified: 05/25/2001 <--Y2K Compliant! =]
 
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.
 
26
ILAPI ILvoid 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
 
44
ILenum ILAPIENTRY ilGetError(ILvoid)
 
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
}