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