]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
Try to trap seg fault
[bacula/bacula] / bacula / src / baconfig.h
1 /*
2  * General header file configurations that apply to
3  * all daemons.  System dependent stuff goes here.
4  *
5  *   Version $Id$
6  */
7 /*
8    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2 of
13    the License, or (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public
21    License along with this program; if not, write to the Free
22    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23    MA 02111-1307, USA.
24
25  */
26
27
28 #ifndef _BACONFIG_H
29 #define _BACONFIG_H 1
30
31 /* Bacula common configuration defines */
32
33 #define TRUE  1
34 #define FALSE 0
35
36 #ifndef ETIME
37 #define ETIME ETIMEDOUT
38 #endif
39
40 #ifdef PROTOTYPES
41 # define __PROTO(p)     p
42 #else
43 # define __PROTO(p)     ()
44 #endif
45
46 #ifdef DEBUG
47 #define ASSERT(x) if (!(x)) { \
48    char *jcr = NULL; \
49    Emsg1(M_ERROR, 0, "Failed ASSERT: %s\n", #x); \
50    jcr[0] = 0; }
51 #else
52 #define ASSERT(x)
53 #endif
54
55 /* Allow printing of NULL pointers */
56 #define NPRT(x) (x)?(x):"*None*" 
57
58 #ifdef ENABLE_NLS
59 #include <libintl.h>
60 #define _(s) gettext((s))
61 #define N_(s) (s)
62 #else
63 #define _(s) (s)
64 #define N_(s) (s)
65 #define textdomain(x)
66 #endif
67
68
69 /* This should go away! ****FIXME***** */
70 #define MAXSTRING 500
71
72 /* Maximum length to edit time/date */
73 #define MAX_TIME_LENGTH 30
74
75 /* Maximum Name length including EOS */
76 #define MAX_NAME_LENGTH 128
77
78 /* All tape operations MUST be a multiple of this */
79 #define TAPE_BSIZE 1024
80 #if !defined(DEV_BSIZE) && defined(BSIZE)
81 #define DEV_BSIZE BSIZE
82 #endif
83
84 #ifndef DEV_BSIZE
85 #define DEV_BSIZE 512
86 #endif
87
88 /* Maximum number of bytes that you can push into a
89  * socket.
90  */
91 #define MAX_NETWORK_BUFFER_SIZE (32 * 1024)
92
93 /* Stream definitions.  Once defined these must NEVER
94  *   change as they go on the storage media.
95  */
96 #define STREAM_UNIX_ATTRIBUTES   1    /* Generic Unix attributes */
97 #define STREAM_FILE_DATA         2    /* Standard uncompressed data */
98 #define STREAM_MD5_SIGNATURE     3    /* MD5 signature for the file */
99 #define STREAM_GZIP_DATA         4    /* GZip compressed file data */
100 #define STREAM_WIN32_ATTRIBUTES  5    /* Windows attributes (superset of Unix) */
101 #define STREAM_SPARSE_DATA       6    /* Sparse data stream */
102 #define STREAM_SPARSE_GZIP_DATA  7
103 #define STREAM_PROGRAM_NAMES     8    /* program names for program data */
104 #define STREAM_PROGRAM_DATA      9    /* Data needing program */
105
106 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
107 #define SPARSE_FADDR_SIZE (sizeof(uint64_t))
108
109
110 /* This is for dumb compilers/libraries like Solaris. Linux GCC
111  * does it correctly, so it might be worthwhile
112  * to remove the isascii(c) with ifdefs on such
113  * "smart" systems.
114  */
115 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
116 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
117 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
118 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
119
120
121 typedef void (HANDLER)();
122 typedef int (INTHANDLER)();
123
124 #ifdef SETPGRP_VOID
125 # define SETPGRP_ARGS(x, y) /* No arguments */
126 #else
127 # define SETPGRP_ARGS(x, y) (x, y)
128 #endif
129
130 #ifndef S_ISLNK
131 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
132 #endif
133
134 /* Added by KES to deal with Win32 systems */
135 #ifndef S_ISWIN32
136 #define S_ISWIN32 020000
137 #endif
138
139 #ifndef INADDR_NONE
140 #define INADDR_NONE ((unsigned long) -1)
141 #endif
142
143 #ifdef TIME_WITH_SYS_TIME
144 # include <sys/time.h>
145 # include <time.h>
146 #else
147 # ifdef HAVE_SYS_TIME_H
148 #  include <sys/time.h>
149 # else
150 #  include <time.h>
151 # endif
152 #endif
153
154 #ifndef O_BINARY
155 #define O_BINARY 0
156 #endif
157
158 #ifndef MODE_RW
159 #define MODE_RW 0666
160 #endif
161
162 #ifdef DEBUG_MUTEX
163 extern void _p(char *file, int line, pthread_mutex_t *m);
164 extern void _v(char *file, int line, pthread_mutex_t *m);
165
166 #define P(x) _p(__FILE__, __LINE__, &(x))
167 #define V(x) _v(__FILE__, __LINE__, &(x))
168
169 #else
170
171 /* These probably should be subroutines */
172 #define P(x) \
173    do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
174       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
175            strerror(errstat)); \
176    } while(0)
177
178 #define V(x) \
179    do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
180          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
181            strerror(errstat)); \
182    } while(0)
183
184 #endif /* DEBUG_MUTEX */
185
186 /* These probably should be subroutines */
187 #define Pw(x) \
188    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
189       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
190            strerror(errstat)); \
191    } while(0)
192
193 #define Vw(x) \
194    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
195          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
196            strerror(errstat)); \
197    } while(0)
198
199
200 /*
201  * The digit following Dmsg and Emsg indicates the number of substitutions in
202  * the message string. We need to do this kludge because non-GNU compilers
203  * do not handle varargs #defines.
204  */
205 /* Debug Messages that are printed */
206 #ifdef DEBUG
207 #define Dmsg0(lvl, msg)             d_msg(__FILE__, __LINE__, lvl, msg)
208 #define Dmsg1(lvl, msg, a1)         d_msg(__FILE__, __LINE__, lvl, msg, a1)
209 #define Dmsg2(lvl, msg, a1, a2)     d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
210 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
211 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
212 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
213 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
214 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
215 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
216 #define Dmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
217 #define Dmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
218 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
219 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
220 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
221 #else
222 #define Dmsg0(lvl, msg)
223 #define Dmsg1(lvl, msg, a1)
224 #define Dmsg2(lvl, msg, a1, a2)
225 #define Dmsg3(lvl, msg, a1, a2, a3)
226 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
227 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
228 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
229 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
230 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
231 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
232 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
233 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
234 #endif /* DEBUG */
235
236
237 /* Messages that are printed (uses d_msg) */
238 #define Pmsg0(lvl, msg)             d_msg(__FILE__, __LINE__, lvl, msg)
239 #define Pmsg1(lvl, msg, a1)         d_msg(__FILE__, __LINE__, lvl, msg, a1)
240 #define Pmsg2(lvl, msg, a1, a2)     d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
241 #define Pmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
242 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
243 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
244 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
245 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
246 #define Pmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
247 #define Pmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
248 #define Pmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
249 #define Pmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
250 #define Pmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
251 #define Pmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
252 #define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
253
254        
255 /* Daemon Error Messages that are delivered according to the message resource */
256 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
257 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
258 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
259 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
260 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
261 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
262 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
263
264 /* Job Error Messages that are delivered according to the message resource */
265 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
266 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
267 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
268 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
269 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
270 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
271 #define Jmsg6(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
272
273
274 /* Memory Messages that are edited into a Pool Memory buffer */
275 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
276 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
277 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
278 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
279 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
280 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
281 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
282 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
283 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
284 #define Mmsg11(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
285 #define Mmsg15(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)
286
287 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
288 int  Mmsg(char **msgbuf, char *fmt,...);
289
290
291 void d_msg(char *file, int line, int level, char *fmt,...);
292 void e_msg(char *file, int line, int type, int level, char *fmt,...);
293 void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
294 int  m_msg(char *file, int line, char **msgbuf, char *fmt,...);
295
296
297 /* Use our strdup with smartalloc */
298 #undef strdup
299 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
300
301 #ifdef DEBUG
302 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
303 #else
304 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
305 #endif
306
307 #ifdef DEBUG
308 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
309 #endif
310
311 #ifdef __alpha__
312 #define OSF 1
313 #endif
314
315 #ifdef HAVE_SUN_OS
316    /* 
317     * On Solaris 2.5, threads are not timesliced by default, so we need to
318     * explictly increase the conncurrency level.
319     */
320 #include <thread.h>
321 #define set_thread_concurrency(x)  thr_setconcurrency(x)
322 extern int thr_setconcurrency(int);
323 #define SunOS 1
324
325 #else
326
327 /* Not needed on most systems */
328 #define set_thread_concurrency(x)
329
330 #endif
331
332 #ifdef HAVE_IRIX_OS
333 #define socklen_t int
334 #endif
335
336 #ifdef HAVE_CYGWIN
337 /* They don't really have it */
338 #undef HAVE_GETDOMAINNAME
339 #endif
340  
341
342 #define ALIGN_SIZE (sizeof(double))
343 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
344
345
346 /* Added by KES to deal with Win32 systems */
347 #ifndef S_ISWIN32
348 #define S_ISWIN32 020000
349 #endif
350
351 /* Replace codes needed in both file routines and non-file routines */
352 /* Job replace codes -- in "replace" */
353 #define REPLACE_ALWAYS   'a'
354 #define REPLACE_IFNEWER  'w'
355 #define REPLACE_NEVER    'n'
356 #define REPLACE_IFOLDER  'o'
357
358 #endif /* _BACONFIG_H */