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