]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
Merge branch 'master' into basejobv3
[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 #define FT_BASE      24               /* Duplicate base file entry */
336
337 /* Definitions for upper part of type word (see above). */
338 #define AR_DATA_STREAM (1<<16)        /* Data stream id present */
339
340 /*
341  * Tape label types -- stored in catalog
342  */
343 #define B_BACULA_LABEL 0
344 #define B_ANSI_LABEL   1
345 #define B_IBM_LABEL    2
346
347 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
348 #define SPARSE_FADDR_SIZE (sizeof(uint64_t))
349
350 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
351 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
352
353
354 /* This is for dumb compilers/libraries like Solaris. Linux GCC
355  * does it correctly, so it might be worthwhile
356  * to remove the isascii(c) with ifdefs on such
357  * "smart" systems.
358  */
359 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
360 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
361 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
362 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
363
364 /* For multiplying by 10 with shift and addition */
365 #define B_TIMES10(d) ((d<<3)+(d<<1))
366
367
368 typedef void (HANDLER)();
369 typedef int (INTHANDLER)();
370
371 #ifdef SETPGRP_VOID
372 # define SETPGRP_ARGS(x, y) /* No arguments */
373 #else
374 # define SETPGRP_ARGS(x, y) (x, y)
375 #endif
376
377 #ifndef S_ISLNK
378 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
379 #endif
380
381 /* Added by KES to deal with Win32 systems */
382 #ifndef S_ISWIN32
383 #define S_ISWIN32 020000
384 #endif
385
386 #ifndef INADDR_NONE
387 #define INADDR_NONE ((unsigned long) -1)
388 #endif
389
390 #ifdef TIME_WITH_SYS_TIME
391 # include <sys/time.h>
392 # include <time.h>
393 #else
394 # ifdef HAVE_SYS_TIME_H
395 #  include <sys/time.h>
396 # else
397 #  include <time.h>
398 # endif
399 #endif
400
401 #ifndef O_BINARY
402 #define O_BINARY 0
403 #endif
404
405 #ifndef O_NOFOLLOW
406 #define O_NOFOLLOW 0
407 #endif
408
409 #ifndef MODE_RW
410 #define MODE_RW 0666
411 #endif
412
413 #if defined(HAVE_WIN32)
414 typedef int64_t   boffset_t;
415 #define caddr_t  char *
416 #else
417 typedef off_t     boffset_t;
418 #endif
419
420 /* These probably should be subroutines */
421 #define Pw(x) \
422    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
423       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
424            strerror(errstat)); \
425    } while(0)
426
427 #define Vw(x) \
428    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
429          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
430            strerror(errstat)); \
431    } while(0)
432
433 #define LockRes()   b_LockRes(__FILE__, __LINE__)
434 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
435
436 #ifdef DEBUG_MEMSET
437 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
438 void b_memset(const char *file, int line, void *mem, int val, size_t num);
439 #endif
440
441
442 /*
443  * The digit following Dmsg and Emsg indicates the number of substitutions in
444  * the message string. We need to do this kludge because non-GNU compilers
445  * do not handle varargs #defines.
446  */
447 /* Debug Messages that are printed */
448 #ifdef DEBUG
449 #define Dmsg0(lvl, msg)             if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg)
450 #define Dmsg1(lvl, msg, a1)         if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1)
451 #define Dmsg2(lvl, msg, a1, a2)     if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
452 #define Dmsg3(lvl, msg, a1, a2, a3) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
453 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
454 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
455 #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)
456 #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)
457 #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)
458 #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)
459 #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)
460 #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)
461 #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)
462 #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)
463 #else
464 #define Dmsg0(lvl, msg)
465 #define Dmsg1(lvl, msg, a1)
466 #define Dmsg2(lvl, msg, a1, a2)
467 #define Dmsg3(lvl, msg, a1, a2, a3)
468 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
469 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
470 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
471 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
472 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
473 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
474 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
475 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
476 #endif /* DEBUG */
477
478 #ifdef TRACE_FILE
479 #define Tmsg0(lvl, msg)             t_msg(__FILE__, __LINE__, lvl, msg)
480 #define Tmsg1(lvl, msg, a1)         t_msg(__FILE__, __LINE__, lvl, msg, a1)
481 #define Tmsg2(lvl, msg, a1, a2)     t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
482 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
483 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
484 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
485 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
486 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
487 #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)
488 #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)
489 #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)
490 #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)
491 #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)
492 #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)
493 #else
494 #define Tmsg0(lvl, msg)
495 #define Tmsg1(lvl, msg, a1)
496 #define Tmsg2(lvl, msg, a1, a2)
497 #define Tmsg3(lvl, msg, a1, a2, a3)
498 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
499 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
500 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
501 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
502 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
503 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
504 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
505 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
506 #endif /* TRACE_FILE */
507
508
509
510 /* Messages that are printed (uses d_msg) */
511 #define Pmsg0(lvl, msg)             p_msg(__FILE__, __LINE__, lvl, msg)
512 #define Pmsg1(lvl, msg, a1)         p_msg(__FILE__, __LINE__, lvl, msg, a1)
513 #define Pmsg2(lvl, msg, a1, a2)     p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
514 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
515 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
516 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
517 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
518 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
519 #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)
520 #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)
521 #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)
522 #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)
523 #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)
524 #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)
525 #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)
526
527
528 /* Daemon Error Messages that are delivered according to the message resource */
529 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
530 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
531 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
532 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
533 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
534 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
535 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
536
537 /* Job Error Messages that are delivered according to the message resource */
538 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
539 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
540 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
541 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
542 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
543 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
544 #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)
545
546 /* Queued Job Error Messages that are delivered according to the message resource */
547 #define Qmsg0(jcr, typ, lvl, msg)             q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
548 #define Qmsg1(jcr, typ, lvl, msg, a1)         q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
549 #define Qmsg2(jcr, typ, lvl, msg, a1, a2)     q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
550 #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
551 #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
552 #define Qmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
553 #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)
554
555
556 /* Memory Messages that are edited into a Pool Memory buffer */
557 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
558 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
559 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
560 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
561 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
562 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
563 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
564 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
565 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
566 #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)
567 #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)
568
569 class POOL_MEM;
570 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
571 int  Mmsg(POOLMEM **msgbuf, const char *fmt,...);
572 int  Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
573 int  Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
574
575
576 class JCR;
577 void d_msg(const char *file, int line, int level, const char *fmt,...);
578 void p_msg(const char *file, int line, int level, const char *fmt,...);
579 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
580 void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
581 void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
582 int  m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
583 int  m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
584
585
586 /* Use our strdup with smartalloc */
587 #ifndef HAVE_WXCONSOLE
588 #undef strdup
589 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
590 #else 
591 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
592 #ifndef ENABLE_NLS
593 #undef _
594 #undef setlocale
595 #undef textdomain
596 #undef bindtextdomain
597 #endif  
598 #endif
599
600 /* Use our fgets which handles interrupts */
601 #undef fgets
602 #define fgets(x,y,z) bfgets((x), (y), (z))
603
604 /* Use our sscanf, which is safer and works with known sizes */
605 #define sscanf bsscanf
606
607 #ifdef DEBUG
608 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
609 #else
610 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
611 #endif
612
613 #ifdef DEBUG
614 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
615 #endif
616
617 /* Macro to simplify free/reset pointers */
618 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
619
620 /*
621  * Replace codes needed in both file routines and non-file routines
622  * Job replace codes -- in "replace"
623  */
624 #define REPLACE_ALWAYS   'a'
625 #define REPLACE_IFNEWER  'w'
626 #define REPLACE_NEVER    'n'
627 #define REPLACE_IFOLDER  'o'
628
629 /* This probably should be done on a machine by machine basis, but it works */
630 /* This is critical for the smartalloc routines to properly align memory */
631 #define ALIGN_SIZE (sizeof(double))
632 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
633
634
635 /* =============================================================
636  *               OS Dependent defines
637  * ============================================================= 
638  */
639
640 #ifndef HAVE_FSEEKO
641 /* Bad news. This OS cannot handle 64 bit fseeks and ftells */
642 #define fseeko fseek
643 #define ftello ftell
644 #endif
645
646 #if defined (__digital__) && defined (__unix__)
647 /* Tru64 - it does have fseeko and ftello , but since ftell/fseek are also 64 bit */
648 /* take this 'shortcut' */
649 #define fseeko fseek
650 #define ftello ftell
651 #undef  ioctl_req_t
652 #define ioctl_req_t int
653 #endif
654
655
656 #ifdef __alpha__
657 #define OSF 1
658 #undef  ioctl_req_t
659 #define ioctl_req_t int
660 #endif
661
662 #ifdef HAVE_SUN_OS
663    /*
664     * On Solaris 2.5, threads are not timesliced by default, so we need to
665     * explictly increase the conncurrency level.
666     */
667 #include <thread.h>
668 #define set_thread_concurrency(x)  thr_setconcurrency(x)
669 extern int thr_setconcurrency(int);
670 #define SunOS 1
671 #undef  ioctl_req_t
672 #define ioctl_req_t int
673
674 #else
675
676
677 /* Not needed on most systems */
678 #define set_thread_concurrency(x)
679
680 #endif
681
682 #if defined(HAVE_DARWIN_OS) || defined(HAVE_OSF1_OS)
683 /* Apparently someone forgot to wrap getdomainname as a C function */
684 extern "C" int getdomainname(char *name, int len);
685 #endif
686
687
688
689 #if defined(HAVE_WIN32)
690 #define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula"
691 #define PathSeparator '\\'
692
693 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
694 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
695 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
696
697 extern void pause_msg(const char *file, const char *func, int line, const char *msg);
698 #define pause(msg) if (debug_level) pause_msg(__FILE__, __func__, __LINE__, (msg))
699
700 #else
701 #define PathSeparator '/'
702 /* Define Winsock functions if we aren't on Windows */
703
704 #define WSA_Init() 0 /* 0 = success */
705 #define WSACleanup() 0 /* 0 = success */
706
707 inline bool IsPathSeparator(int ch) { return ch == '/'; }
708 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
709 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
710 #define pause(msg)
711 #endif
712
713
714 /* HP-UX 11 specific workarounds */
715
716 #ifdef HAVE_HPUX_OS
717 # undef h_errno
718 extern int h_errno;
719 /* the {get,set}domainname() functions exist in HPUX's libc.
720  * the configure script detects that correctly.
721  * the problem is no system headers declares the prototypes for these functions
722  * this is done below
723  */
724 extern "C" int getdomainname(char *name, int namelen);
725 extern "C" int setdomainname(char *name, int namelen);
726 #undef  ioctl_req_t
727 #define ioctl_req_t int
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 #undef  ioctl_req_t
736 #define ioctl_req_t int
737 #endif
738
739
740 /* Disabled because it breaks internationalisation...
741 #undef HAVE_SETLOCALE
742 #ifdef HAVE_SETLOCALE
743 #include <locale.h>
744 #else
745 #define setlocale(x, y) ("ANSI_X3.4-1968")
746 #endif
747 #ifdef HAVE_NL_LANGINFO
748 #include <langinfo.h>
749 #else
750 #define nl_langinfo(x) ("ANSI_X3.4-1968")
751 #endif
752 */
753
754 /* Determine endiannes */
755 static inline bool bigendian() { return htonl(1) == 1L; }
756
757 #endif /* _BACONFIG_H */