add listen-timeout to function as an accept timeout
[socat/sam.git] / error.h
blob385738cadd5ad6dec5ad777f072efb797d4a2380
1 /* source: error.h */
2 /* Copyright Gerhard Rieger 2001-2008 */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 #ifndef __error_h_included
6 #define __error_h_included 1
8 /* these must be defines because they are used by cpp! */
9 #define E_DEBUG 0 /* all, including trace */
10 #define E_INFO 1 /* all status changes etc. */
11 #define E_NOTICE 2 /* all interesting, e.g. for firewall relay */
12 #define E_WARN 3 /* all unusual */
13 #define E_ERROR 4 /* errors */
14 #define E_FATAL 5 /* emergency abort */
17 /* here are the macros for diag invocation; use WITH_MSGLEVEL to specify the
18 lowest priority that is compiled into your program */
19 #ifndef WITH_MSGLEVEL
20 # define WITH_MSGLEVEL E_NOTICE
21 #endif
23 #if WITH_MSGLEVEL <= E_FATAL
24 #define Fatal(m) msg(E_FATAL,"%s",m)
25 #define Fatal1(m,a1) msg(E_FATAL,m,a1)
26 #define Fatal2(m,a1,a2) msg(E_FATAL,m,a1,a2)
27 #define Fatal3(m,a1,a2,a3) msg(E_FATAL,m,a1,a2,a3)
28 #define Fatal4(m,a1,a2,a3,a4) msg(E_FATAL,m,a1,a2,a3,a4)
29 #define Fatal5(m,a1,a2,a3,a4,a5) msg(E_FATAL,m,a1,a2,a3,a4,a5)
30 #define Fatal6(m,a1,a2,a3,a4,a5,a6) msg(E_FATAL,m,a1,a2,a3,a4,a5,a6)
31 #define Fatal7(m,a1,a2,a3,a4,a5,a6,a7) msg(E_FATAL,m,a1,a2,a3,a4,a5,a6,a7)
32 #else /* !(WITH_MSGLEVEL <= E_FATAL) */
33 #define Fatal(m)
34 #define Fatal1(m,a1)
35 #define Fatal2(m,a1,a2)
36 #define Fatal3(m,a1,a2,a3)
37 #define Fatal4(m,a1,a2,a3,a4)
38 #define Fatal5(m,a1,a2,a3,a4,a5)
39 #define Fatal6(m,a1,a2,a3,a4,a5,a6)
40 #define Fatal7(m,a1,a2,a3,a4,a5,a6,a7)
41 #endif /* !(WITH_MSGLEVEL <= E_FATAL) */
43 #if WITH_MSGLEVEL <= E_ERROR
44 #define Error(m) msg(E_ERROR,"%s",m)
45 #define Error1(m,a1) msg(E_ERROR,m,a1)
46 #define Error2(m,a1,a2) msg(E_ERROR,m,a1,a2)
47 #define Error3(m,a1,a2,a3) msg(E_ERROR,m,a1,a2,a3)
48 #define Error4(m,a1,a2,a3,a4) msg(E_ERROR,m,a1,a2,a3,a4)
49 #define Error5(m,a1,a2,a3,a4,a5) msg(E_ERROR,m,a1,a2,a3,a4,a5)
50 #define Error6(m,a1,a2,a3,a4,a5,a6) msg(E_ERROR,m,a1,a2,a3,a4,a5,a6)
51 #define Error7(m,a1,a2,a3,a4,a5,a6,a7) msg(E_ERROR,m,a1,a2,a3,a4,a5,a6,a7)
52 #define Error8(m,a1,a2,a3,a4,a5,a6,a7,a8) msg(E_ERROR,m,a1,a2,a3,a4,a5,a6,a7,a8)
53 #define Error9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9) msg(E_ERROR,m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
54 #define Error10(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) msg(E_ERROR,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
55 #define Error11(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) msg(E_ERROR,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
56 #else /* !(WITH_MSGLEVEL >= E_ERROR) */
57 #define Error(m)
58 #define Error1(m,a1)
59 #define Error2(m,a1,a2)
60 #define Error3(m,a1,a2,a3)
61 #define Error4(m,a1,a2,a3,a4)
62 #define Error5(m,a1,a2,a3,a4,a5)
63 #define Error6(m,a1,a2,a3,a4,a5,a6)
64 #define Error7(m,a1,a2,a3,a4,a5,a6,a7)
65 #define Error8(m,a1,a2,a3,a4,a5,a6,a7,a8)
66 #define Error9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
67 #define Error10(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
68 #define Error11(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
69 #endif /* !(WITH_MSGLEVEL <= E_ERROR) */
71 #if WITH_MSGLEVEL <= E_WARN
72 #define Warn(m) msg(E_WARN,"%s",m)
73 #define Warn1(m,a1) msg(E_WARN,m,a1)
74 #define Warn2(m,a1,a2) msg(E_WARN,m,a1,a2)
75 #define Warn3(m,a1,a2,a3) msg(E_WARN,m,a1,a2,a3)
76 #define Warn4(m,a1,a2,a3,a4) msg(E_WARN,m,a1,a2,a3,a4)
77 #define Warn5(m,a1,a2,a3,a4,a5) msg(E_WARN,m,a1,a2,a3,a4,a5)
78 #define Warn6(m,a1,a2,a3,a4,a5,a6) msg(E_WARN,m,a1,a2,a3,a4,a5,a6)
79 #define Warn7(m,a1,a2,a3,a4,a5,a6,a7) msg(E_WARN,m,a1,a2,a3,a4,a5,a6,a7)
80 #else /* !(WITH_MSGLEVEL <= E_WARN) */
81 #define Warn(m)
82 #define Warn1(m,a1)
83 #define Warn2(m,a1,a2)
84 #define Warn3(m,a1,a2,a3)
85 #define Warn4(m,a1,a2,a3,a4)
86 #define Warn5(m,a1,a2,a3,a4,a5)
87 #define Warn6(m,a1,a2,a3,a4,a5,a6)
88 #define Warn7(m,a1,a2,a3,a4,a5,a6,a7)
89 #endif /* !(WITH_MSGLEVEL <= E_WARN) */
91 #if WITH_MSGLEVEL <= E_NOTICE
92 #define Notice(m) msg(E_NOTICE,"%s",m)
93 #define Notice1(m,a1) msg(E_NOTICE,m,a1)
94 #define Notice2(m,a1,a2) msg(E_NOTICE,m,a1,a2)
95 #define Notice3(m,a1,a2,a3) msg(E_NOTICE,m,a1,a2,a3)
96 #define Notice4(m,a1,a2,a3,a4) msg(E_NOTICE,m,a1,a2,a3,a4)
97 #define Notice5(m,a1,a2,a3,a4,a5) msg(E_NOTICE,m,a1,a2,a3,a4,a5)
98 #define Notice6(m,a1,a2,a3,a4,a5,a6) msg(E_NOTICE,m,a1,a2,a3,a4,a5,a6)
99 #define Notice7(m,a1,a2,a3,a4,a5,a6,a7) msg(E_NOTICE,m,a1,a2,a3,a4,a5,a6,a7)
100 #define Notice8(m,a1,a2,a3,a4,a5,a6,a7,a8) msg(E_NOTICE,m,a1,a2,a3,a4,a5,a6,a7,a8)
101 #define Notice9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9) msg(E_NOTICE,m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
102 #else /* !(WITH_MSGLEVEL <= E_NOTICE) */
103 #define Notice(m)
104 #define Notice1(m,a1)
105 #define Notice2(m,a1,a2)
106 #define Notice3(m,a1,a2,a3)
107 #define Notice4(m,a1,a2,a3,a4)
108 #define Notice5(m,a1,a2,a3,a4,a5)
109 #define Notice6(m,a1,a2,a3,a4,a5,a6)
110 #define Notice7(m,a1,a2,a3,a4,a5,a6,a7)
111 #define Notice8(m,a1,a2,a3,a4,a5,a6,a7,a8)
112 #define Notice9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
113 #endif /* !(WITH_MSGLEVEL <= E_NOTICE) */
115 #if WITH_MSGLEVEL <= E_INFO
116 #define Info(m) msg(E_INFO,"%s",m)
117 #define Info1(m,a1) msg(E_INFO,m,a1)
118 #define Info2(m,a1,a2) msg(E_INFO,m,a1,a2)
119 #define Info3(m,a1,a2,a3) msg(E_INFO,m,a1,a2,a3)
120 #define Info4(m,a1,a2,a3,a4) msg(E_INFO,m,a1,a2,a3,a4)
121 #define Info5(m,a1,a2,a3,a4,a5) msg(E_INFO,m,a1,a2,a3,a4,a5)
122 #define Info6(m,a1,a2,a3,a4,a5,a6) msg(E_INFO,m,a1,a2,a3,a4,a5,a6)
123 #define Info7(m,a1,a2,a3,a4,a5,a6,a7) msg(E_INFO,m,a1,a2,a3,a4,a5,a6,a7)
124 #define Info8(m,a1,a2,a3,a4,a5,a6,a7,a8) msg(E_INFO,m,a1,a2,a3,a4,a5,a6,a7,a8)
125 #define Info9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9) msg(E_INFO,m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
126 #define Info10(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) msg(E_INFO,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
127 #define Info11(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) msg(E_INFO,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
128 #else /* !(WITH_MSGLEVEL <= E_INFO) */
129 #define Info(m)
130 #define Info1(m,a1)
131 #define Info2(m,a1,a2)
132 #define Info3(m,a1,a2,a3)
133 #define Info4(m,a1,a2,a3,a4)
134 #define Info5(m,a1,a2,a3,a4,a5)
135 #define Info6(m,a1,a2,a3,a4,a5,a6)
136 #define Info7(m,a1,a2,a3,a4,a5,a6,a7)
137 #define Info8(m,a1,a2,a3,a4,a5,a6,a7,a8)
138 #define Info9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
139 #define Info10(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
140 #define Info11(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
141 #endif /* !(WITH_MSGLEVEL <= E_INFO) */
143 #if WITH_MSGLEVEL <= E_DEBUG
144 #define Debug(m) msg(E_DEBUG,"%s",m)
145 #define Debug1(m,a1) msg(E_DEBUG,m,a1)
146 #define Debug2(m,a1,a2) msg(E_DEBUG,m,a1,a2)
147 #define Debug3(m,a1,a2,a3) msg(E_DEBUG,m,a1,a2,a3)
148 #define Debug4(m,a1,a2,a3,a4) msg(E_DEBUG,m,a1,a2,a3,a4)
149 #define Debug5(m,a1,a2,a3,a4,a5) msg(E_DEBUG,m,a1,a2,a3,a4,a5)
150 #define Debug6(m,a1,a2,a3,a4,a5,a6) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6)
151 #define Debug7(m,a1,a2,a3,a4,a5,a6,a7) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7)
152 #define Debug8(m,a1,a2,a3,a4,a5,a6,a7,a8) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8)
153 #define Debug9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
154 #define Debug10(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
155 #define Debug11(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
156 #define Debug12(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
157 #define Debug13(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
158 #define Debug14(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
159 #define Debug15(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)
160 #define Debug16(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16)
161 #define Debug17(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17)
162 #define Debug18(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18) msg(E_DEBUG,m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18)
163 #else /* !(WITH_MSGLEVEL <= E_DEBUG) */
164 #define Debug(m)
165 #define Debug1(m,a1)
166 #define Debug2(m,a1,a2)
167 #define Debug3(m,a1,a2,a3)
168 #define Debug4(m,a1,a2,a3,a4)
169 #define Debug5(m,a1,a2,a3,a4,a5)
170 #define Debug6(m,a1,a2,a3,a4,a5,a6)
171 #define Debug7(m,a1,a2,a3,a4,a5,a6,a7)
172 #define Debug8(m,a1,a2,a3,a4,a5,a6,a7,a8)
173 #define Debug9(m,a1,a2,a3,a4,a5,a6,a7,a8,a9)
174 #define Debug10(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
175 #define Debug11(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
176 #define Debug12(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
177 #define Debug13(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
178 #define Debug14(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
179 #define Debug15(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)
180 #define Debug16(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16)
181 #define Debug17(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17)
182 #define Debug18(m,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18)
183 #endif /* !(WITH_MSGLEVEL <= E_DEBUG) */
185 /* message with software controlled serverity */
186 #if WITH_MSGLEVEL <= E_FATAL
187 #define Msg(l,m) msg(l,"%s",m)
188 #define Msg1(l,m,a1) msg(l,m,a1)
189 #define Msg2(l,m,a1,a2) msg(l,m,a1,a2)
190 #define Msg3(l,m,a1,a2,a3) msg(l,m,a1,a2,a3)
191 #define Msg4(l,m,a1,a2,a3,a4) msg(l,m,a1,a2,a3,a4)
192 #define Msg5(l,m,a1,a2,a3,a4,a5) msg(l,m,a1,a2,a3,a4,a5)
193 #define Msg6(l,m,a1,a2,a3,a4,a5,a6) msg(l,m,a1,a2,a3,a4,a5,a6)
194 #define Msg7(l,m,a1,a2,a3,a4,a5,a6,a7) msg(l,m,a1,a2,a3,a4,a5,a6,a7)
195 #else /* !(WITH_MSGLEVEL >= E_FATAL) */
196 #define Msg(l,m)
197 #define Msg1(l,m,a1)
198 #define Msg2(l,m,a1,a2)
199 #define Msg3(l,m,a1,a2,a3)
200 #define Msg4(l,m,a1,a2,a3,a4)
201 #define Msg5(l,m,a1,a2,a3,a4,a5)
202 #define Msg6(l,m,a1,a2,a3,a4,a5,a6)
203 #define Msg7(l,m,a1,a2,a3,a4,a5,a6,a7)
204 #endif /* !(WITH_MSGLEVEL <= E_FATAL) */
207 extern void diag_set(char what, const char *arg);
208 extern void diag_set_int(char what, int arg);
209 extern int diag_get_int(char what);
210 extern const char *diag_get_string(char what);
211 extern int diag_dup(void);
212 extern int diag_dup2(int newfd);
213 extern void msg(int level, const char *format, ...);
215 #endif /* !defined(__error_h_included) */