author | eilers <eilers> | 2003-11-03 16:52:18 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-11-03 16:52:18 (UTC) |
commit | d34dc773591a2d467c68875a68a671d6a809f861 (patch) (unidiff) | |
tree | b57e5ae15c51e3d87ca95d57aedfd1ca3db57bfe /rsync/trace.h | |
parent | ce84f2d8bdd65c438821f0457cdad6bbbfa73380 (diff) | |
download | opie-d34dc773591a2d467c68875a68a671d6a809f861.zip opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.gz opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.bz2 |
Porting Opie to MacOS-X.
The base system and all platform independent applications and platforms
should work.
Please see $OPIEDIR/development/macosx for details
-rw-r--r-- | rsync/trace.h | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/rsync/trace.h b/rsync/trace.h index 60a6477..2bb8552 100644 --- a/rsync/trace.h +++ b/rsync/trace.h | |||
@@ -1,122 +1,112 @@ | |||
1 | /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- | 1 | /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- |
2 | * | 2 | * |
3 | * librsync -- generate and apply network deltas | 3 | * librsync -- generate and apply network deltas |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 2000, 2001 by Martin Pool <mbp@samba.org> | 6 | * Copyright (C) 2000, 2001 by Martin Pool <mbp@samba.org> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU Lesser General Public License as published by | 9 | * it under the terms of the GNU Lesser General Public License as published by |
10 | * the Free Software Foundation; either version 2.1 of the License, or | 10 | * the Free Software Foundation; either version 2.1 of the License, or |
11 | * (at your option) any later version. | 11 | * (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU Lesser General Public License for more details. | 16 | * GNU Lesser General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU Lesser General Public License | 18 | * You should have received a copy of the GNU Lesser General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | 23 | ||
24 | /* | 24 | /* |
25 | * TODO: A function like perror that includes strerror output. Apache | 25 | * TODO: A function like perror that includes strerror output. Apache |
26 | * does this by adding flags as well as the severity level which say | 26 | * does this by adding flags as well as the severity level which say |
27 | * whether such information should be included. | 27 | * whether such information should be included. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | /* | 31 | /* |
32 | * trace may be turned off. | 32 | * trace may be turned off. |
33 | * | 33 | * |
34 | * error is always on, but you can return and continue in some way | 34 | * error is always on, but you can return and continue in some way |
35 | * | 35 | * |
36 | * fatal terminates the whole process | 36 | * fatal terminates the whole process |
37 | */ | 37 | */ |
38 | 38 | ||
39 | void rs_fatal0(char const *s, ...); | 39 | #if defined(HAVE_VARARG_MACROS) && defined(__GNUC__) |
40 | void rs_error0(char const *s, ...); | 40 | /* |
41 | void rs_trace0(char const *s, ...); | 41 | * TODO: Don't assume this is a gcc thing; rather test in autoconf for |
42 | 42 | * support for __FUNCTION__. One simple way might just be to try compiling | |
43 | void rs_log0_nofn(int level, char const *fmt, ...); | 43 | * the definition of one of these functions! |
44 | 44 | * | |
45 | #ifdef __GNUC__ | 45 | * TODO: Also look for the C9X predefined identifier `_function', or |
46 | * whatever it's called. | ||
47 | */ | ||
46 | 48 | ||
47 | void rs_log0(int level, char const *fn, char const *fmt, ...) | 49 | void rs_log0(int level, char const *fn, char const *fmt, ...) |
48 | __attribute__ ((format(printf, 3, 4))); | 50 | __attribute__ ((format(printf, 3, 4))); |
49 | 51 | ||
50 | #ifdef DO_RS_TRACE | 52 | #ifdef DO_RS_TRACE |
51 | # define rs_trace(fmt, arg...) \ | 53 | # define rs_trace(fmt, arg...) \ |
52 | do { rs_log0(RS_LOG_DEBUG, __FUNCTION__, fmt , ##arg); \ | 54 | do { rs_log0(RS_LOG_DEBUG, __FUNCTION__, fmt , ##arg); \ |
53 | } while (0) | 55 | } while (0) |
54 | #else | 56 | #else |
55 | # define rs_trace(s, str...) | 57 | # define rs_trace(fmt, arg...) |
56 | #endif/* !DO_RS_TRACE */ | 58 | #endif/* !DO_RS_TRACE */ |
57 | 59 | ||
58 | /* | ||
59 | * TODO: Don't assume this is a gcc thing; rather test in autoconf for | ||
60 | * support for __FUNCTION__ and varargs macros. One simple way might | ||
61 | * just be to try compiling the definition of one of these functions! | ||
62 | * | ||
63 | * TODO: Also look for the C9X predefined identifier `_function', or | ||
64 | * whatever it's called. | ||
65 | */ | ||
66 | |||
67 | #define rs_log(l, s, str...) do { \ | 60 | #define rs_log(l, s, str...) do { \ |
68 | rs_log0((l), __FUNCTION__, (s) , ##str); \ | 61 | rs_log0((l), __FUNCTION__, (s) , ##str); \ |
69 | } while (0) | 62 | } while (0) |
70 | 63 | ||
71 | 64 | ||
72 | #define rs_error(s, str...) do { \ | 65 | #define rs_error(s, str...) do { \ |
73 | rs_log0(RS_LOG_ERR, __FUNCTION__, (s) , ##str); \ | 66 | rs_log0(RS_LOG_ERR, __FUNCTION__, (s) , ##str); \ |
74 | } while (0) | 67 | } while (0) |
75 | 68 | ||
76 | 69 | ||
77 | #define rs_fatal(s, str...) do { \ | 70 | #define rs_fatal(s, str...) do { \ |
78 | rs_log0(RS_LOG_CRIT, __FUNCTION__, \ | 71 | rs_log0(RS_LOG_CRIT, __FUNCTION__, \ |
79 | (s) , ##str); \ | 72 | (s) , ##str); \ |
80 | abort(); \ | 73 | abort(); \ |
81 | } while (0) | 74 | } while (0) |
82 | 75 | ||
83 | 76 | ||
84 | #else /************************* ! __GNUC__ */ | 77 | #else /************************* ! __GNUC__ */ |
85 | 78 | # define rs_trace rs_trace0 | |
86 | # define rs_fatal rs_fatal0 | 79 | # define rs_fatal rs_fatal0 |
87 | # define rs_error rs_error0 | 80 | # define rs_error rs_error0 |
88 | # define rs_log rs_log0_nofn | 81 | # define rs_log rs_log0_nofn |
89 | |||
90 | # ifdef DO_RS_TRACE | ||
91 | # define rs_trace rs_trace0 | ||
92 | # endif /* DO_RS_TRACE */ | ||
93 | #endif /* ! __GNUC__ */ | 82 | #endif /* ! __GNUC__ */ |
94 | 83 | ||
95 | 84 | void rs_trace0(char const *s, ...); | |
85 | void rs_fatal0(char const *s, ...); | ||
86 | void rs_error0(char const *s, ...); | ||
96 | void rs_log0(int level, char const *fn, char const *fmt, ...); | 87 | void rs_log0(int level, char const *fn, char const *fmt, ...); |
97 | 88 | void rs_log0_nofn(int level, char const *fmt, ...); | |
98 | 89 | ||
99 | enum { | 90 | enum { |
100 | RS_LOG_PRIMASK = 7, /**< Mask to extract priority | 91 | RS_LOG_PRIMASK = 7, /**< Mask to extract priority |
101 | part. \internal */ | 92 | part. \internal */ |
102 | 93 | ||
103 | RS_LOG_NONAME = 8 /**< \b Don't show function name in | 94 | RS_LOG_NONAME = 8 /**< \b Don't show function name in |
104 | message. */ | 95 | message. */ |
105 | }; | 96 | }; |
106 | 97 | ||
107 | 98 | ||
108 | |||
109 | /** | 99 | /** |
110 | * \macro rs_trace_enabled() | 100 | * \macro rs_trace_enabled() |
111 | * | 101 | * |
112 | * Call this before putting too much effort into generating trace | 102 | * Call this before putting too much effort into generating trace |
113 | * messages. | 103 | * messages. |
114 | */ | 104 | */ |
115 | 105 | ||
116 | extern int rs_trace_level; | 106 | extern int rs_trace_level; |
117 | 107 | ||
118 | #ifdef DO_RS_TRACE | 108 | #ifdef DO_RS_TRACE |
119 | # define rs_trace_enabled() ((rs_trace_level & RS_LOG_PRIMASK) >= RS_LOG_DEBUG) | 109 | # define rs_trace_enabled() ((rs_trace_level & RS_LOG_PRIMASK) >= RS_LOG_DEBUG) |
120 | #else | 110 | #else |
121 | # define rs_trace_enabled() 0 | 111 | # define rs_trace_enabled() 0 |
122 | #endif | 112 | #endif |