-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
65 lines (61 loc) · 1.68 KB
/
error.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* FilterImage - A 2D Savitzky-Golay Image Filtering tool
*
* Copyright (C) 2021 Forschungszentrum Juelich GmbH
* B. E. Pieters, E. Sovetkin, and M. Gordon
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "error.h"
#include "errormessages.h" /* generated by gen_errorflags.sh, defines error messages for eachg error flag */
int ERRORSTATE=0; /* single boolean indicating whether there were any errors */
int EXITSTATE=0;
char ERRORS[NERR] = {0}; /* zero initialized error flags */
void AddErr(int ERRFLAG)
{
ERRORSTATE=1;
EXITSTATE=1;
if (ERRFLAG>NERR)
{
/* the recursive error :) */
// ERRORFLAG ERROUTRANGE "Error flag out of range!"
AddErr(ERROUTRANGE);
}
else
ERRORS[ERRFLAG]++;
}
int QueryErr(int ERRFLAG)
{
if (ERRFLAG>NERR)
AddErr(ERROUTRANGE);
if (ERRORS[ERRFLAG])
return 1;
return 0;
}
void E_Messages()
{
int i;
for (i=0;i<NERR;i++)
if (ERRORS[i])
fprintf(stderr,"ERROR: %s (%dx)\n", EMessages[i], ERRORS[i]);
}
void ResetErrors()
{
int i;
for (i=0;i<NERR;i++)
ERRORS[i]=0;
ERRORSTATE=0;
}