]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
ebl update
[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 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
281 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
282
283
284 /* This is for dumb compilers/libraries like Solaris. Linux GCC
285  * does it correctly, so it might be worthwhile
286  * to remove the isascii(c) with ifdefs on such
287  * "smart" systems.
288  */
289 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
290 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
291 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
292 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
293
294 /* For multiplying by 10 with shift and addition */
295 #define B_TIMES10(d) ((d<<3)+(d<<1))
296
297
298 typedef void (HANDLER)();
299 typedef int (INTHANDLER)();
300
301 #ifdef SETPGRP_VOID
302 # define SETPGRP_ARGS(x, y) /* No arguments */
303 #else
304 # define SETPGRP_ARGS(x, y) (x, y)
305 #endif
306
307 #ifndef S_ISLNK
308 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
309 #endif
310
311 /* Added by KES to deal with Win32 systems */
312 #ifndef S_ISWIN32
313 #define S_ISWIN32 020000
314 #endif
315
316 #ifndef INADDR_NONE
317 #define INADDR_NONE ((unsigned long) -1)
318 #endif
319
320 #ifdef TIME_WITH_SYS_TIME
321 # include <sys/time.h>
322 # include <time.h>
323 #else
324 # ifdef HAVE_SYS_TIME_H
325 #  include <sys/time.h>
326 # else
327 #  include <time.h>
328 # endif
329 #endif
330
331 #ifndef O_BINARY
332 #define O_BINARY 0
333 #endif
334
335 #ifndef O_NOFOLLOW
336 #define O_NOFOLLOW 0
337 #endif
338
339 #ifndef MODE_RW
340 #define MODE_RW 0666
341 #endif
342
343 #if defined(HAVE_WIN32)
344 typedef int64_t   boffset_t;
345 #else
346 typedef off_t     boffset_t;
347 #endif
348
349 #if defined(DEBUG_MUTEX)
350 extern void _p(char *file, int line, pthread_mutex_t *m);
351 extern void _v(char *file, int line, pthread_mutex_t *m);
352
353 #define P(x) _p(__FILE__, __LINE__, &(x))
354 #define V(x) _v(__FILE__, __LINE__, &(x))
355
356 #else
357 extern void _p(pthread_mutex_t *m);
358 extern void _v(pthread_mutex_t *m);
359
360 #define P(x) _p(&(x))
361 #define V(x) _v(&(x))
362
363 #endif /* DEBUG_MUTEX */
364
365 /* These probably should be subroutines */
366 #define Pw(x) \
367    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
368       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
369            strerror(errstat)); \
370    } while(0)
371
372 #define Vw(x) \
373    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
374          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
375            strerror(errstat)); \
376    } while(0)
377
378 #define LockRes()   b_LockRes(__FILE__, __LINE__)
379 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
380
381 #ifdef DEBUG_MEMSET
382 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
383 void b_memset(const char *file, int line, void *mem, int val, size_t num);
384 #endif
385
386
387 /*
388  * The digit following Dmsg and Emsg indicates the number of substitutions in
389  * the message string. We need to do this kludge because non-GNU compilers
390  * do not handle varargs #defines.
391  */
392 /* Debug Messages that are printed */
393 #ifdef DEBUG
394 #define Dmsg0(lvl, msg)             if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg)
395 #define Dmsg1(lvl, msg, a1)         if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1)
396 #define Dmsg2(lvl, msg, a1, a2)     if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
397 #define Dmsg3(lvl, msg, a1, a2, a3) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
398 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
399 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
400 #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)
401 #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)
402 #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)
403 #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)
404 #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)
405 #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)
406 #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)
407 #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)
408 #else
409 #define Dmsg0(lvl, msg)
410 #define Dmsg1(lvl, msg, a1)
411 #define Dmsg2(lvl, msg, a1, a2)
412 #define Dmsg3(lvl, msg, a1, a2, a3)
413 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
414 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
415 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
416 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
417 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
418 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
419 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
420 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
421 #endif /* DEBUG */
422
423 #ifdef TRACE_FILE
424 #define Tmsg0(lvl, msg)             t_msg(__FILE__, __LINE__, lvl, msg)
425 #define Tmsg1(lvl, msg, a1)         t_msg(__FILE__, __LINE__, lvl, msg, a1)
426 #define Tmsg2(lvl, msg, a1, a2)     t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
427 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
428 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
429 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
430 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
431 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
432 #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)
433 #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)
434 #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)
435 #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)
436 #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)
437 #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)
438 #else
439 #define Tmsg0(lvl, msg)
440 #define Tmsg1(lvl, msg, a1)
441 #define Tmsg2(lvl, msg, a1, a2)
442 #define Tmsg3(lvl, msg, a1, a2, a3)
443 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
444 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
445 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
446 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
447 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
448 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
449 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
450 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
451 #endif /* TRACE_FILE */
452
453
454
455 /* Messages that are printed (uses d_msg) */
456 #define Pmsg0(lvl, msg)             p_msg(__FILE__, __LINE__, lvl, msg)
457 #define Pmsg1(lvl, msg, a1)         p_msg(__FILE__, __LINE__, lvl, msg, a1)
458 #define Pmsg2(lvl, msg, a1, a2)     p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
459 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
460 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
461 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
462 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
463 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
464 #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)
465 #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)
466 #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)
467 #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)
468 #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)
469 #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)
470 #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)
471
472
473 /* Daemon Error Messages that are delivered according to the message resource */
474 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
475 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
476 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
477 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
478 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
479 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
480 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
481
482 /* Job Error Messages that are delivered according to the message resource */
483 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
484 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
485 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
486 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
487 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
488 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
489 #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)
490
491 /* Queued Job Error Messages that are delivered according to the message resource */
492 #define Qmsg0(jcr, typ, lvl, msg)             q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
493 #define Qmsg1(jcr, typ, lvl, msg, a1)         q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
494 #define Qmsg2(jcr, typ, lvl, msg, a1, a2)     q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
495 #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
496 #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
497 #define Qmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
498 #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)
499
500
501 /* Memory Messages that are edited into a Pool Memory buffer */
502 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
503 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
504 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
505 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
506 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
507 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
508 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
509 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
510 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
511 #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)
512 #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)
513
514 class POOL_MEM;
515 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
516 int  Mmsg(POOLMEM **msgbuf, const char *fmt,...);
517 int  Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
518 int  Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
519
520
521 class JCR;
522 void d_msg(const char *file, int line, int level, const char *fmt,...);
523 void p_msg(const char *file, int line, int level, const char *fmt,...);
524 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
525 void j_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
526 void q_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
527 int  m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
528 int  m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
529
530
531 /* Use our strdup with smartalloc */
532 #ifndef HAVE_WXCONSOLE
533 #undef strdup
534 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
535 #endif
536
537 /* Use our fgets which handles interrupts */
538 #undef fgets
539 #define fgets(x,y,z) bfgets((x), (y), (z))
540
541 /* Use our sscanf, which is safer and works with known sizes */
542 #define sscanf bsscanf
543
544 #ifdef DEBUG
545 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
546 #else
547 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
548 #endif
549
550 #ifdef DEBUG
551 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
552 #endif
553
554 /*
555  * Replace codes needed in both file routines and non-file routines
556  * Job replace codes -- in "replace"
557  */
558 #define REPLACE_ALWAYS   'a'
559 #define REPLACE_IFNEWER  'w'
560 #define REPLACE_NEVER    'n'
561 #define REPLACE_IFOLDER  'o'
562
563 /* This probably should be done on a machine by machine basis, but it works */
564 /* This is critical for the smartalloc routines to properly align memory */
565 #define ALIGN_SIZE (sizeof(double))
566 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
567
568
569 /* =============================================================
570  *               OS Dependent defines
571  * ============================================================= 
572  */
573
574 #ifndef HAVE_FSEEKO
575 /* Bad news. This OS cannot handle 64 bit fseeks and ftells */
576 #define fseeko fseek
577 #define ftello ftell
578 #endif
579
580 #if defined (__digital__) && defined (__unix__)
581 /* Tru64 - it does have fseeko and ftello , but since ftell/fseek are also 64 bit */
582 /* take this 'shortcut' */
583 #define fseeko fseek
584 #define ftello ftell
585 #endif
586
587
588 #ifdef __alpha__
589 #define OSF 1
590 #endif
591
592 #ifdef HAVE_SUN_OS
593    /*
594     * On Solaris 2.5, threads are not timesliced by default, so we need to
595     * explictly increase the conncurrency level.
596     */
597 #include <thread.h>
598 #define set_thread_concurrency(x)  thr_setconcurrency(x)
599 extern int thr_setconcurrency(int);
600 #define SunOS 1
601
602 #else
603
604
605 /* Not needed on most systems */
606 #define set_thread_concurrency(x)
607
608 #endif
609
610 #if defined(HAVE_DARWIN_OS) || defined(HAVE_OSF1_OS)
611 /* Apparently someone forgot to wrap getdomainname as a C function */
612 extern "C" int getdomainname(char *name, int len);
613 #endif
614
615 #ifdef HAVE_OSF1_OS
616 extern "C" int mknod ( const char *path, int mode, dev_t device );
617 #endif
618
619
620 #if defined(HAVE_WIN32)
621 #define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula"
622
623 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
624 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
625 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
626
627 #else
628 /* Define Winsock functions if we aren't on Windows */
629
630 #define WSA_Init() 0 /* 0 = success */
631 #define WSACleanup() 0 /* 0 = success */
632
633 inline bool IsPathSeparator(int ch) { return ch == '/'; }
634 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
635 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
636 #endif
637
638
639 /* HP-UX 11 specific workarounds */
640
641 #ifdef HAVE_HPUX_OS
642 # undef h_errno
643 extern int h_errno;
644 /* the {get,set}domainname() functions exist in HPUX's libc.
645  * the configure script detects that correctly.
646  * the problem is no system headers declares the prototypes for these functions
647  * this is done below
648  */
649 extern "C" int getdomainname(char *name, int namelen);
650 extern "C" int setdomainname(char *name, int namelen);
651 #define uLong unsigned long
652 #endif /* HAVE_HPUX_OS */
653
654
655 #ifdef HAVE_OSF1_OS
656 #undef HAVE_CHFLAGS  /* chflags is incorrectly detected */
657 extern "C" int fchdir(int filedes);
658 extern "C" long gethostid(void);
659 #endif
660
661
662 /* Disabled because it breaks internationalisation...
663 #undef HAVE_SETLOCALE
664 #ifdef HAVE_SETLOCALE
665 #include <locale.h>
666 #else
667 #define setlocale(x, y) ("ANSI_X3.4-1968")
668 #endif
669 #ifdef HAVE_NL_LANGINFO
670 #include <langinfo.h>
671 #else
672 #define nl_langinfo(x) ("ANSI_X3.4-1968")
673 #endif
674 */
675
676 #endif /* _BACONFIG_H */