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