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