1998-04-22 20:58:34 +08:00
|
|
|
/*
|
|
|
|
* BIRD Library
|
|
|
|
*
|
|
|
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BIRD_BIRDLIB_H_
|
|
|
|
#define _BIRD_BIRDLIB_H_
|
|
|
|
|
|
|
|
/* Ugly structure offset handling macros */
|
|
|
|
|
|
|
|
#define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i)
|
|
|
|
#define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
|
1998-05-04 00:43:39 +08:00
|
|
|
#define ALIGN(s, a) (((s)+a-1)&~(a-1))
|
|
|
|
|
1998-07-10 03:36:05 +08:00
|
|
|
/* Utility-Macros */
|
|
|
|
#define MIN(a,b) ((a<b)?a:b)
|
|
|
|
#define MAX(a,b) ((a>b)?a:b)
|
|
|
|
|
1998-05-04 00:43:39 +08:00
|
|
|
/* Functions which don't return */
|
|
|
|
|
|
|
|
#define NORET __attribute__((noreturn))
|
1998-04-22 20:58:34 +08:00
|
|
|
|
1998-04-23 22:01:15 +08:00
|
|
|
/* Logging and dying */
|
|
|
|
|
1998-05-15 15:56:13 +08:00
|
|
|
void log(char *msg, ...) __attribute__((format(printf,1,2)));
|
|
|
|
void die(char *msg, ...) __attribute__((format(printf,1,2))) NORET;
|
1998-04-23 22:01:15 +08:00
|
|
|
|
|
|
|
#define L_DEBUG "\001" /* Debugging messages */
|
|
|
|
#define L_INFO "\002" /* Informational messages */
|
|
|
|
#define L_WARN "\003" /* Warnings */
|
|
|
|
#define L_ERR "\004" /* Errors */
|
|
|
|
#define L_AUTH "\005" /* Authorization failed etc. */
|
1998-05-04 00:43:39 +08:00
|
|
|
#define L_FATAL "\006" /* Fatal errors */
|
|
|
|
|
|
|
|
void log_init(char *); /* Initialize logging to given file (NULL=stderr, ""=syslog) */
|
|
|
|
void log_init_debug(char *); /* Initialize debug dump to given file (NULL=stderr, ""=off) */
|
|
|
|
|
|
|
|
void debug(char *msg, ...); /* Printf to debug output */
|
1998-04-23 22:01:15 +08:00
|
|
|
|
|
|
|
/* Debugging */
|
|
|
|
|
|
|
|
#ifdef LOCAL_DEBUG
|
1998-05-27 05:36:17 +08:00
|
|
|
#define DBG(x, y...) debug(x, ##y)
|
1998-04-23 22:01:15 +08:00
|
|
|
#else
|
|
|
|
#define DBG(x, y...)
|
|
|
|
#endif
|
|
|
|
|
1998-04-22 20:58:34 +08:00
|
|
|
#endif
|