]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
Suppress incorrect 'Will not descend from x into y' messages
[bacula/bacula] / bacula / src / baconfig.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file 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
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of John Walker.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  * General header file configurations that apply to
30  * all daemons.  System dependent stuff goes here.
31  *
32  *   Version $Id$
33  */
34
35
36 #ifndef _BACONFIG_H
37 #define _BACONFIG_H 1
38
39 /* Bacula common configuration defines */
40
41 #undef  TRUE
42 #undef  FALSE
43 #define TRUE  1
44 #define FALSE 0
45
46 #ifndef MAX
47 #define MAX(a, b) ((a) > (b) ? (a) : (b))
48 #endif
49 #ifndef MIN
50 #define MIN(a, b) ((a) < (b) ? (a) : (b))
51 #endif
52
53 #ifdef HAVE_TLS
54 #define have_tls 1
55 #else
56 #define have_tls 0
57 #endif
58
59 #ifndef ETIME
60 #define ETIME ETIMEDOUT
61 #endif
62
63 #ifdef PROTOTYPES
64 # define __PROTO(p)     p
65 #else
66 # define __PROTO(p)     ()
67 #endif
68
69 #ifdef DEBUG
70 #define ASSERT(x) if (!(x)) { \
71    char *jcr = NULL; \
72    Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
73    jcr[0] = 0; }
74 #else
75 #define ASSERT(x)
76 #endif
77
78 /* Allow printing of NULL pointers */
79 #define NPRT(x) (x)?(x):_("*None*")
80  
81 #if defined(HAVE_WIN32)
82 void InitWinAPIWrapper();
83
84 #define  OSDependentInit()    InitWinAPIWrapper()
85
86 #define sbrk(x)  0
87
88
89 #if defined(BUILDING_DLL)
90 #  define DLL_IMP_EXP   _declspec(dllexport)
91 #elif defined(USING_DLL)
92 #  define DLL_IMP_EXP   _declspec(dllimport)
93 #else
94 #  define DLL_IMP_EXP
95 #endif
96
97 #if defined(USING_CATS)
98 #  define CATS_IMP_EXP   _declspec(dllimport)
99 #else
100 #  define CATS_IMP_EXP
101 #endif
102
103 #else
104
105 #define DLL_IMP_EXP
106 #define CATS_IMP_EXP
107
108 #define  OSDependentInit()
109 #define  tape_open            open
110 #define  tape_ioctl           ioctl
111 #define  tape_read            ::read
112 #define  tape_write           ::write
113 #define  tape_close           ::close
114
115 #endif
116
117
118 #ifdef ENABLE_NLS
119    #include <libintl.h>
120    #include <locale.h>
121    #ifndef _
122       #define _(s) gettext((s))
123    #endif /* _ */
124    #ifndef N_
125       #define N_(s) (s)
126    #endif /* N_ */
127 #else /* !ENABLE_NLS */
128    #undef _
129    #undef N_
130    #undef textdomain
131    #undef bindtextdomain
132    #undef setlocale
133
134    #ifndef _
135       #define _(s) (s)
136    #endif
137    #ifndef N_
138       #define N_(s) (s)
139    #endif
140    #ifndef textdomain
141       #define textdomain(d)
142    #endif
143    #ifndef bindtextdomain
144       #define bindtextdomain(p, d)
145    #endif
146    #ifndef setlocale
147       #define setlocale(p, d)
148    #endif
149 #endif /* ENABLE_NLS */
150
151
152 /* Use the following for strings not to be translated */
153 #define NT_(s) (s)   
154
155 /* This should go away! ****FIXME***** */
156 #define MAXSTRING 500
157
158 /* Maximum length to edit time/date */
159 #define MAX_TIME_LENGTH 50
160
161 /* Maximum Name length including EOS */
162 #define MAX_NAME_LENGTH 128
163
164 /* Maximume number of user entered command args */
165 #define MAX_CMD_ARGS 30
166
167 /* All tape operations MUST be a multiple of this */
168 #define TAPE_BSIZE 1024
169
170 #ifdef DEV_BSIZE 
171 #define B_DEV_BSIZE DEV_BSIZE
172 #endif
173
174 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
175 #define B_DEV_BSIZE BSIZE
176 #endif
177
178 #ifndef B_DEV_BSIZE
179 #define B_DEV_BSIZE 512
180 #endif
181
182 /*
183  * Set to time limit for other end to respond to
184  *  authentication.  Normally 10 minutes is *way*
185  *  more than enough. The idea is to keep the Director
186  *  from hanging because there is a dead connection on
187  *  the other end.
188  */
189 #define AUTH_TIMEOUT 60 * 10
190
191 /*
192  * Default network buffer size
193  */
194 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
195
196 /*
197  * Stream definitions.  Once defined these must NEVER
198  *   change as they go on the storage media.
199  * Note, the following streams are passed from the SD to the DIR
200  *   so that they may be put into the catalog (actually only the
201  *   stat packet part of the attr record is put in the catalog.
202  *
203  *   STREAM_UNIX_ATTRIBUTES
204  *   STREAM_UNIX_ATTRIBUTES_EX
205  *   STREAM_MD5_DIGEST
206  *   STREAM_SHA1_DIGEST
207  *   STREAM_SHA256_DIGEST
208  *   STREAM_SHA512_DIGEST
209  */
210 #define STREAM_NONE                        0    /* Reserved Non-Stream */
211 #define STREAM_UNIX_ATTRIBUTES             1    /* Generic Unix attributes */
212 #define STREAM_FILE_DATA                   2    /* Standard uncompressed data */
213 #define STREAM_MD5_SIGNATURE               3    /* deprecated */
214 #define STREAM_MD5_DIGEST                  3    /* MD5 digest for the file */
215 #define STREAM_GZIP_DATA                   4    /* GZip compressed file data */
216 /* Extended Unix attributes with Win32 Extended data.  Deprecated. */
217 #define STREAM_UNIX_ATTRIBUTES_EX          5    /* Extended Unix attr for Win32 EX */
218 #define STREAM_SPARSE_DATA                 6    /* Sparse data stream */
219 #define STREAM_SPARSE_GZIP_DATA            7
220 #define STREAM_PROGRAM_NAMES               8    /* program names for program data */
221 #define STREAM_PROGRAM_DATA                9    /* Data needing program */
222 #define STREAM_SHA1_SIGNATURE             10    /* deprecated */
223 #define STREAM_SHA1_DIGEST                10    /* SHA1 digest for the file */
224 #define STREAM_WIN32_DATA                 11    /* Win32 BackupRead data */
225 #define STREAM_WIN32_GZIP_DATA            12    /* Gzipped Win32 BackupRead data */
226 #define STREAM_MACOS_FORK_DATA            13    /* Mac resource fork */
227 #define STREAM_HFSPLUS_ATTRIBUTES         14    /* Mac OS extra attributes */
228 /*** FIXME ***/
229 #define STREAM_UNIX_ACCESS_ACL            15   /* Standard ACL attributes on UNIX */
230 #define STREAM_UNIX_DEFAULT_ACL           16   /* Default ACL attributes on UNIX */
231 /*** FIXME ***/
232 #define STREAM_SHA256_DIGEST              17   /* SHA-256 digest for the file */
233 #define STREAM_SHA512_DIGEST              18   /* SHA-512 digest for the file */
234 #define STREAM_SIGNED_DIGEST              19   /* Signed File Digest, ASN.1, DER Encoded */
235 #define STREAM_ENCRYPTED_FILE_DATA        20   /* Encrypted, uncompressed data */
236 #define STREAM_ENCRYPTED_WIN32_DATA       21   /* Encrypted, uncompressed Win32 BackupRead data */
237 #define STREAM_ENCRYPTED_SESSION_DATA     22   /* Encrypted Session Data, ASN.1, DER Encoded */
238 #define STREAM_ENCRYPTED_FILE_GZIP_DATA   23   /* Encrypted, compressed data */
239 #define STREAM_ENCRYPTED_WIN32_GZIP_DATA  24   /* Encrypted, compressed Win32 BackupRead data */
240 #define STREAM_ENCRYPTED_MACOS_FORK_DATA  25   /* Encrypted, uncompressed Mac resource fork */
241 #define STREAM_PLUGIN_NAME                26   /* Plugin "file" string */
242 #define STREAM_PLUGIN_DATA                27   /* Plugin specific data */
243
244
245 /*
246  *  File type (Bacula defined).
247  *  NOTE!!! These are saved in the Attributes record on the tape, so
248  *          do not change them. If need be, add to them.
249  *
250  *  This is stored as 32 bits on the Volume, but only FT_MASK (16) bits are
251  *    used for the file type. The upper bits are used to indicate
252  *    additional optional fields in the attribute record.
253  */
254 #define FT_MASK       0xFFFF          /* Bits used by FT (type) */
255 #define FT_LNKSAVED   1               /* hard link to file already saved */
256 #define FT_REGE       2               /* Regular file but empty */
257 #define FT_REG        3               /* Regular file */
258 #define FT_LNK        4               /* Soft Link */
259 #define FT_DIREND     5               /* Directory at end (saved) */
260 #define FT_SPEC       6               /* Special file -- chr, blk, fifo, sock */
261 #define FT_NOACCESS   7               /* Not able to access */
262 #define FT_NOFOLLOW   8               /* Could not follow link */
263 #define FT_NOSTAT     9               /* Could not stat file */
264 #define FT_NOCHG     10               /* Incremental option, file not changed */
265 #define FT_DIRNOCHG  11               /* Incremental option, directory not changed */
266 #define FT_ISARCH    12               /* Trying to save archive file */
267 #define FT_NORECURSE 13               /* No recursion into directory */
268 #define FT_NOFSCHG   14               /* Different file system, prohibited */
269 #define FT_NOOPEN    15               /* Could not open directory */
270 #define FT_RAW       16               /* Raw block device */
271 #define FT_FIFO      17               /* Raw fifo device */
272 /* The DIRBEGIN packet is sent to the FD file processing routine so
273  * that it can filter packets, but otherwise, it is not used
274  * or saved */
275 #define FT_DIRBEGIN  18               /* Directory at beginning (not saved) */
276 #define FT_INVALIDFS 19               /* File system not allowed for */
277 #define FT_INVALIDDT 20               /* Drive type not allowed for */
278 #define FT_REPARSE   21               /* Win NTFS reparse point */
279 #define FT_PLUGIN    22               /* Plugin generated filename */
280 #define FT_DELETED   23               /* Deleted file entry */
281
282 /* Definitions for upper part of type word (see above). */
283 #define AR_DATA_STREAM (1<<16)        /* Data stream id present */
284
285 /*
286  * Tape label types -- stored in catalog
287  */
288 #define B_BACULA_LABEL 0
289 #define B_ANSI_LABEL   1
290 #define B_IBM_LABEL    2
291
292 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
293 #define SPARSE_FADDR_SIZE (sizeof(uint64_t))
294
295 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
296 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
297
298
299 /* This is for dumb compilers/libraries like Solaris. Linux GCC
300  * does it correctly, so it might be worthwhile
301  * to remove the isascii(c) with ifdefs on such
302  * "smart" systems.
303  */
304 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
305 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
306 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
307 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
308
309 /* For multiplying by 10 with shift and addition */
310 #define B_TIMES10(d) ((d<<3)+(d<<1))
311
312
313 typedef void (HANDLER)();
314 typedef int (INTHANDLER)();
315
316 #ifdef SETPGRP_VOID
317 # define SETPGRP_ARGS(x, y) /* No arguments */
318 #else
319 # define SETPGRP_ARGS(x, y) (x, y)
320 #endif
321
322 #ifndef S_ISLNK
323 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
324 #endif
325
326 /* Added by KES to deal with Win32 systems */
327 #ifndef S_ISWIN32
328 #define S_ISWIN32 020000
329 #endif
330
331 #ifndef INADDR_NONE
332 #define INADDR_NONE ((unsigned long) -1)
333 #endif
334
335 #ifdef TIME_WITH_SYS_TIME
336 # include <sys/time.h>
337 # include <time.h>
338 #else
339 # ifdef HAVE_SYS_TIME_H
340 #  include <sys/time.h>
341 # else
342 #  include <time.h>
343 # endif
344 #endif
345
346 #ifndef O_BINARY
347 #define O_BINARY 0
348 #endif
349
350 #ifndef O_NOFOLLOW
351 #define O_NOFOLLOW 0
352 #endif
353
354 #ifndef MODE_RW
355 #define MODE_RW 0666
356 #endif
357
358 #if defined(HAVE_WIN32)
359 typedef int64_t   boffset_t;
360 #else
361 typedef off_t     boffset_t;
362 #endif
363
364 #if defined(DEBUG_MUTEX)
365 extern void _p(char *file, int line, pthread_mutex_t *m);
366 extern void _v(char *file, int line, pthread_mutex_t *m);
367
368 #define P(x) _p(__FILE__, __LINE__, &(x))
369 #define V(x) _v(__FILE__, __LINE__, &(x))
370
371 #else
372 extern void _p(pthread_mutex_t *m);
373 extern void _v(pthread_mutex_t *m);
374
375 #define P(x) _p(&(x))
376 #define V(x) _v(&(x))
377
378 #endif /* DEBUG_MUTEX */
379
380 /* These probably should be subroutines */
381 #define Pw(x) \
382    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
383       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
384            strerror(errstat)); \
385    } while(0)
386
387 #define Vw(x) \
388    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
389          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
390            strerror(errstat)); \
391    } while(0)
392
393 #define LockRes()   b_LockRes(__FILE__, __LINE__)
394 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
395
396 #ifdef DEBUG_MEMSET
397 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
398 void b_memset(const char *file, int line, void *mem, int val, size_t num);
399 #endif
400
401
402 /*
403  * The digit following Dmsg and Emsg indicates the number of substitutions in
404  * the message string. We need to do this kludge because non-GNU compilers
405  * do not handle varargs #defines.
406  */
407 /* Debug Messages that are printed */
408 #ifdef DEBUG
409 #define Dmsg0(lvl, msg)             if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg)
410 #define Dmsg1(lvl, msg, a1)         if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1)
411 #define Dmsg2(lvl, msg, a1, a2)     if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
412 #define Dmsg3(lvl, msg, a1, a2, a3) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
413 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
414 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
415 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
416 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
417 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
418 #define Dmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
419 #define Dmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
420 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
421 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
422 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
423 #else
424 #define Dmsg0(lvl, msg)
425 #define Dmsg1(lvl, msg, a1)
426 #define Dmsg2(lvl, msg, a1, a2)
427 #define Dmsg3(lvl, msg, a1, a2, a3)
428 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
429 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
430 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
431 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
432 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
433 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
434 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
435 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
436 #endif /* DEBUG */
437
438 #ifdef TRACE_FILE
439 #define Tmsg0(lvl, msg)             t_msg(__FILE__, __LINE__, lvl, msg)
440 #define Tmsg1(lvl, msg, a1)         t_msg(__FILE__, __LINE__, lvl, msg, a1)
441 #define Tmsg2(lvl, msg, a1, a2)     t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
442 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
443 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
444 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
445 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
446 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
447 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
448 #define Tmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
449 #define Tmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
450 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
451 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
452 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
453 #else
454 #define Tmsg0(lvl, msg)
455 #define Tmsg1(lvl, msg, a1)
456 #define Tmsg2(lvl, msg, a1, a2)
457 #define Tmsg3(lvl, msg, a1, a2, a3)
458 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
459 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
460 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
461 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
462 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
463 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
464 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
465 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
466 #endif /* TRACE_FILE */
467
468
469
470 /* Messages that are printed (uses d_msg) */
471 #define Pmsg0(lvl, msg)             p_msg(__FILE__, __LINE__, lvl, msg)
472 #define Pmsg1(lvl, msg, a1)         p_msg(__FILE__, __LINE__, lvl, msg, a1)
473 #define Pmsg2(lvl, msg, a1, a2)     p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
474 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
475 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
476 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
477 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
478 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
479 #define Pmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
480 #define Pmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
481 #define Pmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
482 #define Pmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
483 #define Pmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
484 #define Pmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
485 #define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
486
487
488 /* Daemon Error Messages that are delivered according to the message resource */
489 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
490 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
491 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
492 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
493 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
494 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
495 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
496
497 /* Job Error Messages that are delivered according to the message resource */
498 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
499 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
500 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
501 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
502 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
503 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
504 #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)
505
506 /* Queued Job Error Messages that are delivered according to the message resource */
507 #define Qmsg0(jcr, typ, lvl, msg)             q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
508 #define Qmsg1(jcr, typ, lvl, msg, a1)         q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
509 #define Qmsg2(jcr, typ, lvl, msg, a1, a2)     q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
510 #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
511 #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
512 #define Qmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
513 #define Qmsg6(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
514
515
516 /* Memory Messages that are edited into a Pool Memory buffer */
517 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
518 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
519 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
520 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
521 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
522 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
523 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
524 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
525 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
526 #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)
527 #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)
528
529 class POOL_MEM;
530 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
531 int  Mmsg(POOLMEM **msgbuf, const char *fmt,...);
532 int  Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
533 int  Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
534
535
536 class JCR;
537 void d_msg(const char *file, int line, int level, const char *fmt,...);
538 void p_msg(const char *file, int line, int level, const char *fmt,...);
539 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
540 void j_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
541 void q_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
542 int  m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
543 int  m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
544
545
546 /* Use our strdup with smartalloc */
547 #ifndef HAVE_WXCONSOLE
548 #undef strdup
549 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
550 #else 
551 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
552 #ifndef ENABLE_NLS
553 #undef _
554 #undef setlocale
555 #undef textdomain
556 #undef bindtextdomain
557 #endif  
558 #endif
559
560 /* Use our fgets which handles interrupts */
561 #undef fgets
562 #define fgets(x,y,z) bfgets((x), (y), (z))
563
564 /* Use our sscanf, which is safer and works with known sizes */
565 #define sscanf bsscanf
566
567 #ifdef DEBUG
568 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
569 #else
570 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
571 #endif
572
573 #ifdef DEBUG
574 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
575 #endif
576
577 /*
578  * Replace codes needed in both file routines and non-file routines
579  * Job replace codes -- in "replace"
580  */
581 #define REPLACE_ALWAYS   'a'
582 #define REPLACE_IFNEWER  'w'
583 #define REPLACE_NEVER    'n'
584 #define REPLACE_IFOLDER  'o'
585
586 /* This probably should be done on a machine by machine basis, but it works */
587 /* This is critical for the smartalloc routines to properly align memory */
588 #define ALIGN_SIZE (sizeof(double))
589 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
590
591
592 /* =============================================================
593  *               OS Dependent defines
594  * ============================================================= 
595  */
596
597 #ifndef HAVE_FSEEKO
598 /* Bad news. This OS cannot handle 64 bit fseeks and ftells */
599 #define fseeko fseek
600 #define ftello ftell
601 #endif
602
603 #if defined (__digital__) && defined (__unix__)
604 /* Tru64 - it does have fseeko and ftello , but since ftell/fseek are also 64 bit */
605 /* take this 'shortcut' */
606 #define fseeko fseek
607 #define ftello ftell
608 #endif
609
610
611 #ifdef __alpha__
612 #define OSF 1
613 #endif
614
615 #ifdef HAVE_SUN_OS
616    /*
617     * On Solaris 2.5, threads are not timesliced by default, so we need to
618     * explictly increase the conncurrency level.
619     */
620 #include <thread.h>
621 #define set_thread_concurrency(x)  thr_setconcurrency(x)
622 extern int thr_setconcurrency(int);
623 #define SunOS 1
624
625 #else
626
627
628 /* Not needed on most systems */
629 #define set_thread_concurrency(x)
630
631 #endif
632
633 #if defined(HAVE_DARWIN_OS) || defined(HAVE_OSF1_OS)
634 /* Apparently someone forgot to wrap getdomainname as a C function */
635 extern "C" int getdomainname(char *name, int len);
636 #endif
637
638
639
640 #if defined(HAVE_WIN32)
641 #define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula"
642 #define PathSeparator '\\'
643
644 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
645 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
646 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
647
648 #else
649 #define PathSeparator '/'
650 /* Define Winsock functions if we aren't on Windows */
651
652 #define WSA_Init() 0 /* 0 = success */
653 #define WSACleanup() 0 /* 0 = success */
654
655 inline bool IsPathSeparator(int ch) { return ch == '/'; }
656 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
657 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
658 #endif
659
660
661 /* HP-UX 11 specific workarounds */
662
663 #ifdef HAVE_HPUX_OS
664 # undef h_errno
665 extern int h_errno;
666 /* the {get,set}domainname() functions exist in HPUX's libc.
667  * the configure script detects that correctly.
668  * the problem is no system headers declares the prototypes for these functions
669  * this is done below
670  */
671 extern "C" int getdomainname(char *name, int namelen);
672 extern "C" int setdomainname(char *name, int namelen);
673 #endif /* HAVE_HPUX_OS */
674
675
676 #ifdef HAVE_OSF1_OS
677 extern "C" int fchdir(int filedes);
678 extern "C" long gethostid(void);
679 extern "C" int mknod ( const char *path, int mode, dev_t device );
680 #endif
681
682
683 /* Disabled because it breaks internationalisation...
684 #undef HAVE_SETLOCALE
685 #ifdef HAVE_SETLOCALE
686 #include <locale.h>
687 #else
688 #define setlocale(x, y) ("ANSI_X3.4-1968")
689 #endif
690 #ifdef HAVE_NL_LANGINFO
691 #include <langinfo.h>
692 #else
693 #define nl_langinfo(x) ("ANSI_X3.4-1968")
694 #endif
695 */
696
697 #endif /* _BACONFIG_H */