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