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