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