/[vps]/baselayout-vserver/trunk/src/core/librcscripts/debug.h
Gentoo

Contents of /baselayout-vserver/trunk/src/core/librcscripts/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 127 - (show annotations) (download) (as text)
Fri Dec 2 10:56:06 2005 UTC (12 years, 11 months ago) by phreak
File MIME type: text/x-chdr
File size: 2398 byte(s)
Import the latest baselayout changes. Merging revision 1658.
1 /*
2 * debug.h
3 *
4 * Simle debugging/logging macro's and functions.
5 *
6 * Copyright (C) 2004,2005 Martin Schlemmer <azarah@nosferatu.za.org>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * $Header$
23 */
24
25 #ifndef _DEBUG_H
26 #define _DEBUG_H
27
28 #if defined(RC_DEBUG)
29 # define DBG_MSG(_format, _arg...) \
30 do { \
31 int old_errno = errno; \
32 fprintf(stderr, "DEBUG(1): in %s, function %s(), line %i:\n", __FILE__, \
33 __FUNCTION__, __LINE__); \
34 fprintf(stderr, "DEBUG(2): " _format, ## _arg); \
35 errno = old_errno; \
36 if (0 != errno) { \
37 perror("DEBUG(3)"); \
38 /* perror() for some reason sets errno to ESPIPE */ \
39 errno = old_errno; \
40 } \
41 } while (0)
42 #else
43 # define DBG_MSG(_format, _arg...) \
44 do { \
45 int old_errno = errno; \
46 /* Bit of a hack, as how we do things tend to cause seek
47 * errors when reading the parent/child pipes */ \
48 /* if ((0 != errno) && (ESPIPE != errno)) { */ \
49 if (0 != errno) { \
50 fprintf(stderr, "DEBUG(1): in %s, function %s(), line %i:\n", \
51 __FILE__, __FUNCTION__, __LINE__); \
52 fprintf(stderr, "DEBUG(2): " _format, ## _arg); \
53 errno = old_errno; \
54 perror("DEBUG(3)"); \
55 /* perror() for some reason sets errno to ESPIPE */ \
56 errno = old_errno; \
57 } \
58 } while (0)
59 #endif
60
61 #define FATAL_ERROR() \
62 do { \
63 int old_errno = errno; \
64 fprintf(stderr, "ERROR: file '%s', function '%s', line %i.\n", \
65 __FILE__, __FUNCTION__, __LINE__); \
66 errno = old_errno; \
67 if (0 != errno) \
68 perror("ERROR"); \
69 exit(EXIT_FAILURE); \
70 } while (0)
71
72 #define NEG_FATAL_ERROR(_x) \
73 do { \
74 if (-1 == _x) \
75 FATAL_ERROR(); \
76 } while (0)
77
78 #define NULL_FATAL_ERROR(_x) \
79 do { \
80 if (NULL == _x) \
81 FATAL_ERROR(); \
82 } while (0)
83
84 #endif /* _DEBUG_H */
85

  ViewVC Help
Powered by ViewVC 1.1.20