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