-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
60 lines (54 loc) · 1.25 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
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "config.h"
#include "error.h"
#include "aldl-io.h"
/************ SCOPE *********************************
Error handing routines.
****************************************************/
/* list of error code to string, array index matches enumerated values in
error_t. these will have ERROR printed AFTER them, so GENERAL will come
out as GENERAL ERROR. */
char errstr[N_ERRORCODES][24] = {
"GENERAL",
"NULL",
"OUT OF MEMORY",
"COMM DRIVER",
"OUT OF RANGE",
"TIMING",
"CONFIG",
"BUFFER",
"CONFIG OPTION MISSING",
"PLUGIN LOADING",
"THREADLOCKING",
"NETWORK",
"RETARD"
};
void error(errtype_t t, error_t code, char *str, ...) {
va_list arg;
fprintf(stderr,"ALDL-IO: ");
fprintf(stderr,"%s ERROR (%i)\n",errstr[code],code);
if(str != NULL) {
fprintf(stderr,"NOTES: ");
va_start(arg,str);
vfprintf(stderr,str,arg);
va_end(arg);
fprintf(stderr,"\n");
}
#ifndef ALL_ERRORS_FATAL
if(t == EFATAL) {
#endif
fprintf(stderr,"This error is fatal. Exiting...\n");
main_exit();
#ifndef ALL_ERRORS_FATAL
}
#endif
}
#ifdef RETARDED
void retardptr(void *p, char *note) {
error(1,ERROR_RETARD,"null pointer in %s");
}
#endif