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