]>
Commit | Line | Data |
---|---|---|
58ef912c MM |
1 | /* |
2 | * BIRD Library | |
3 | * | |
4 | * (c) 1998 Martin Mares <mj@ucw.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | #ifndef _BIRD_BIRDLIB_H_ | |
10 | #define _BIRD_BIRDLIB_H_ | |
11 | ||
12 | /* Ugly structure offset handling macros */ | |
13 | ||
14 | #define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i) | |
15 | #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i))) | |
18c8241a MM |
16 | #define ALIGN(s, a) (((s)+a-1)&~(a-1)) |
17 | ||
18 | /* Functions which don't return */ | |
19 | ||
20 | #define NORET __attribute__((noreturn)) | |
58ef912c | 21 | |
c40e05a0 MM |
22 | /* Logging and dying */ |
23 | ||
25697773 MM |
24 | void log(char *msg, ...) __attribute__((format(printf,1,2))); |
25 | void die(char *msg, ...) __attribute__((format(printf,1,2))) NORET; | |
c40e05a0 MM |
26 | |
27 | #define L_DEBUG "\001" /* Debugging messages */ | |
28 | #define L_INFO "\002" /* Informational messages */ | |
29 | #define L_WARN "\003" /* Warnings */ | |
30 | #define L_ERR "\004" /* Errors */ | |
31 | #define L_AUTH "\005" /* Authorization failed etc. */ | |
18c8241a MM |
32 | #define L_FATAL "\006" /* Fatal errors */ |
33 | ||
34 | void log_init(char *); /* Initialize logging to given file (NULL=stderr, ""=syslog) */ | |
35 | void log_init_debug(char *); /* Initialize debug dump to given file (NULL=stderr, ""=off) */ | |
36 | ||
37 | void debug(char *msg, ...); /* Printf to debug output */ | |
c40e05a0 MM |
38 | |
39 | /* Debugging */ | |
40 | ||
41 | #ifdef LOCAL_DEBUG | |
42 | #define DBG(x, y...) log(L_DEBUG x, ##y) | |
43 | #else | |
44 | #define DBG(x, y...) | |
45 | #endif | |
46 | ||
58ef912c | 47 | #endif |