]>
Commit | Line | Data |
---|---|---|
1 | #ifndef __ERROR_H | |
2 | #define __ERROR_H | |
3 | ||
4 | /* error.h: | |
5 | * | |
6 | * Error flagging routines | |
7 | */ | |
8 | ||
9 | /* SEVERITY GUIDELINES: | |
10 | * | |
11 | * ERR_STOP: Something so bad has happened that the whole service must | |
12 | * stop. Something like a malloc() error or similar magnitude | |
13 | * error. | |
14 | * | |
15 | * ERR_FATAL: Something so bad has happened that the module cannot usefully | |
16 | * function any more, but won't necessarily prevent other modules | |
17 | * from working. | |
18 | * | |
19 | * ERR_ERROR: Something is wrong, perhaps a data structure is inconsistent | |
20 | * or something similar has gone wrong internally. This might | |
21 | * indicate a larger problem but the module can continue working | |
22 | * for now. | |
23 | * | |
24 | * ERR_WARNING: Something slightly out of the ordinary has happened (e.g. | |
25 | * the IRCD sent a bogus message). The module can continue | |
26 | * working though without serious harm. | |
27 | * | |
28 | * ERR_INFO: Not an error condition. Something noteworthy has happened, | |
29 | * like a major module has started up. These will typically be | |
30 | * seen all the time on most setups so try not to be too spammy. | |
31 | * | |
32 | * ERR_DEBUG: Not an error condition. Something less significant has | |
33 | * happened which might be of interest if someone is attempting | |
34 | * to debug a problem. Nevertheless try not to be too spammy. | |
35 | */ | |
36 | ||
37 | #define ERR_DEBUG 0 | |
38 | #define ERR_INFO 1 | |
39 | #define ERR_WARNING 2 | |
40 | #define ERR_ERROR 3 | |
41 | #define ERR_FATAL 4 | |
42 | #define ERR_STOP 5 | |
43 | ||
44 | struct error_event { | |
45 | int severity; | |
46 | char *message; | |
47 | char *source; | |
48 | }; | |
49 | ||
50 | typedef void (*CoreHandlerFn)(void *arg); | |
51 | ||
52 | typedef struct corehandler { | |
53 | void *arg; | |
54 | CoreHandlerFn fn; | |
55 | struct corehandler *prev, *next; | |
56 | } corehandler; | |
57 | ||
58 | void Error(char *source, int severity, char *reason, ... ) __attribute__ ((format (printf, 3, 4))); | |
59 | ||
60 | corehandler *registercorehandler(CoreHandlerFn fn, void *arg); | |
61 | void deregistercorehandler(corehandler *c); | |
62 | ||
63 | #endif |