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