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