File: bug.h

package info (click to toggle)
noflushd 2.7.5-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 792 kB
  • ctags: 302
  • sloc: ansic: 2,537; sh: 1,142; makefile: 85
file content (67 lines) | stat: -rw-r--r-- 2,073 bytes parent folder | download | duplicates (4)
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
66
67
/*
 * <bug.h>
 * Debugging aids.
 * 
 * (C) 2000 Daniel Kobras <kobras@linux.de>
 * 
 * $Id: bug.h,v 1.6 2003/09/06 17:37:01 nold Exp $
 *
 * 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */             

#ifndef _NFD_BUG_H
#define _NFD_BUG_H

#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <syslog.h>

#include "noflushd.h"
#include "kupdate.h"

/* FIXME: ... is a gcc extension. Get rid of that! */
/* Note: The whitespace between __LINE__ and the following comma is subtle!
 * If you leave it out, cpp will eat not only the comma but also the __LINE__
 * macro if ##x expands to nothing. Same goes for all the other ##x args 
 * below.
 */
#define BUG(msg,x...)	do { \
				if (released) \
					syslog(LOG_DEBUG, "BUG: " msg , ##x); \
				else \
					fprintf(stderr, "BUG at %s line %d: " \
					        msg "\n", __FILE__, __LINE__ , \
					        ##x); \
				kupdate->start(kupdate); \
				raise(11); \
			} while (0)

#define DEBUG(msg,x...)	do { if (verbose > 1 && !released) \
				fprintf(stderr, msg "\n" , ##x); \
			} while (0)
#define INFO(msg,x...)	do { if (verbose) { \
				if (released) \
					syslog(LOG_NOTICE, msg , ##x); \
			     	else \
					printf(msg "\n" , ##x); \
			     } \
			} while (0)
#define ERR(msg,x...)	do { if (released) \
				syslog(LOG_ERR, msg ": %m" , ##x); \
			     else \
				fprintf(stderr, "Error: " msg "\n" , ##x); \
			} while (0)
#endif