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