]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
aa6299b3a8781ff2972cd0a1a48a54806b10149b
[bacula/bacula] / bacula / src / baconfig.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2017 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  * General header file configurations that apply to
21  * all daemons.  System dependent stuff goes here.
22  */
23
24
25 #ifndef _BACONFIG_H
26 #define _BACONFIG_H 1
27
28 /* Bacula common configuration defines */
29
30 #undef  TRUE
31 #undef  FALSE
32 #define TRUE  1
33 #define FALSE 0
34
35 #ifdef HAVE_TLS
36 #define have_tls 1
37 #else
38 #define have_tls 0
39 #endif
40
41 #ifndef ETIME
42 #define ETIME ETIMEDOUT
43 #endif
44
45 #ifdef HAVE_IOCTL_ULINT_REQUEST
46 #define ioctl_req_t unsigned long int
47 #else
48 #define ioctl_req_t int
49 #endif
50
51 #define MANUAL_AUTH_URL "http://www.bacula.org/rel-manual/en/problems/Bacula_Frequently_Asked_Que.html"
52  
53 #ifdef PROTOTYPES
54 # define __PROTO(p)     p
55 #else
56 # define __PROTO(p)     ()
57 #endif
58
59 #ifdef DEBUG
60 #define ASSERT(x) if (!(x)) { \
61    char *tjcr = NULL; \
62    Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
63    Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
64    tjcr[0] = 0; }
65
66 #define ASSERT2(x,y) if (!(x)) { \
67    set_assert_msg(__FILE__, __LINE__, y); \
68    Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
69    Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
70    char *tjcr = NULL; \
71    tjcr[0] = 0; }
72 #else
73 #define ASSERT(x)
74 #define ASSERT2(x, y)
75 #endif
76
77 #ifdef DEVELOPER
78 #define ASSERTD(x, y) if (!(x)) { \
79    set_assert_msg(__FILE__, __LINE__, y); \
80    Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
81    Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
82    char *jcr = NULL; \
83    jcr[0] = 0; }
84 #else
85 #define ASSERTD(x, y)
86 #endif
87
88 /* Allow printing of NULL pointers */
89 #define NPRT(x) (x)?(x):_("*None*")
90 #define NPRTB(x) (x)?(x):""
91
92 #if defined(HAVE_WIN32)
93
94 #define WIN32_REPARSE_POINT  1   /* Can be any number of "funny" directories except the next two */
95 #define WIN32_MOUNT_POINT    2   /* Directory link to Volume */
96 #define WIN32_JUNCTION_POINT 3   /* Directory link to a directory */
97
98 /* Reduce compiler warnings from Windows vss code */
99 #define uuid(x)
100
101 void InitWinAPIWrapper();
102
103 #define  OSDependentInit()    InitWinAPIWrapper()
104
105 #define sbrk(x)  0
106
107 #define clear_thread_id(x) memset(&(x), 0, sizeof(x))
108
109 #if defined(BUILDING_DLL)
110 #  define DLL_IMP_EXP   _declspec(dllexport)
111 #elif defined(USING_DLL)
112 #  define DLL_IMP_EXP   _declspec(dllimport)
113 #else
114 #  define DLL_IMP_EXP
115 #endif
116
117 #if defined(USING_CATS)
118 #  define CATS_IMP_EXP   _declspec(dllimport)
119 #else
120 #  define CATS_IMP_EXP
121 #endif
122
123 #else  /* HAVE_WIN32 */
124
125 #define clear_thread_id(x) x = 0
126
127 #define DLL_IMP_EXP
128 #define CATS_IMP_EXP
129
130 #define  OSDependentInit()
131
132 #endif /* HAVE_WIN32 */
133
134
135 #ifdef ENABLE_NLS
136    #include <libintl.h>
137    #include <locale.h>
138    #ifndef _
139       #define _(s) gettext((s))
140    #endif /* _ */
141    #ifndef N_
142       #define N_(s) (s)
143    #endif /* N_ */
144 #else /* !ENABLE_NLS */
145    #undef _
146    #undef N_
147    #undef textdomain
148    #undef bindtextdomain
149    #undef setlocale
150
151    #ifndef _
152       #define _(s) (s)
153    #endif
154    #ifndef N_
155       #define N_(s) (s)
156    #endif
157    #ifndef textdomain
158       #define textdomain(d)
159    #endif
160    #ifndef bindtextdomain
161       #define bindtextdomain(p, d)
162    #endif
163    #ifndef setlocale
164       #define setlocale(p, d)
165    #endif
166 #endif /* ENABLE_NLS */
167
168
169 /* Use the following for strings not to be translated */
170 #define NT_(s) (s)   
171
172 /* This should go away! ****FIXME***** */
173 #define MAXSTRING 500
174
175 /* Maximum length to edit time/date */
176 #define MAX_TIME_LENGTH 50
177
178 /* Maximum Name length including EOS */
179 #define MAX_NAME_LENGTH 128
180
181 /* Maximum escaped Name lenght including EOS 2*MAX_NAME_LENGTH+1 */
182 #define MAX_ESCAPE_NAME_LENGTH 257
183
184 /* Maximume number of user entered command args */
185 #define MAX_CMD_ARGS 30
186
187 /* All tape operations MUST be a multiple of this */
188 #define TAPE_BSIZE 1024
189
190 #ifdef DEV_BSIZE 
191 #define B_DEV_BSIZE DEV_BSIZE
192 #endif
193
194 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
195 #define B_DEV_BSIZE BSIZE
196 #endif
197
198 #ifndef B_DEV_BSIZE
199 #define B_DEV_BSIZE 512
200 #endif
201
202 /**
203  * Set to time limit for other end to respond to
204  *  authentication.  Normally 10 minutes is *way*
205  *  more than enough. The idea is to keep the Director
206  *  from hanging because there is a dead connection on
207  *  the other end.
208  */
209 #define AUTH_TIMEOUT 60 * 10
210
211 /*
212  * Default network buffer size
213  */
214 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
215
216 /**
217  * Tape label types -- stored in catalog
218  */
219 #define B_BACULA_LABEL 0
220 #define B_ANSI_LABEL   1
221 #define B_IBM_LABEL    2
222
223 /*
224  * Device types
225  * If you update this table, be sure to add an
226  *  entry in prt_dev_types[] in stored/dev.c
227  *  This number is stored in the Catalog as VolType or VolParts, do not change.
228  */
229 enum {
230    B_FILE_DEV = 1,
231    B_TAPE_DEV = 2,
232    B_DVD_DEV  = 3,
233    B_FIFO_DEV = 4,
234    B_VTAPE_DEV= 5,                    /* change to B_TAPE_DEV after init */
235    B_FTP_DEV =  6,
236    B_VTL_DEV =  7,                    /* Virtual tape library device */
237    B_ADATA_DEV = 8,                   /* Aligned data Data file */
238    B_ALIGNED_DEV = 9,                 /* Aligned data Meta file */
239    B_NULL_DEV  = 11,                  /* /dev/null for testing */
240    B_VALIGNED_DEV = 12,               /* Virtual for Aligned device (not stored) */
241    B_VDEDUP_DEV = 13,                 /* Virtual for Dedup device (not stored) */
242    B_CLOUD_DEV  = 14                  /* New Cloud device type (available in 8.8) */
243 };
244
245 /**
246  * Actions on purge (bit mask)
247  */
248 #define ON_PURGE_TRUNCATE 1
249
250 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
251 #define OFFSET_FADDR_SIZE (sizeof(uint64_t))
252
253 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
254 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
255
256
257 /**
258  * This is for dumb compilers/libraries like Solaris. Linux GCC
259  * does it correctly, so it might be worthwhile
260  * to remove the isascii(c) with ifdefs on such
261  * "smart" systems.
262  */
263 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
264 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
265 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
266 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
267 #define B_ISXDIGIT(c) (isascii((int)(c)) && isxdigit((int)(c)))
268
269 /** For multiplying by 10 with shift and addition */
270 #define B_TIMES10(d) ((d<<3)+(d<<1))
271
272
273 typedef void (HANDLER)();
274 typedef int (INTHANDLER)();
275
276 #ifdef SETPGRP_VOID
277 # define SETPGRP_ARGS(x, y) /* No arguments */
278 #else
279 # define SETPGRP_ARGS(x, y) (x, y)
280 #endif
281
282 #ifndef S_ISLNK
283 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
284 #endif
285
286 /** Added by KES to deal with Win32 systems */
287 #ifndef S_ISWIN32
288 #define S_ISWIN32 020000
289 #endif
290
291 #ifndef INADDR_NONE
292 #define INADDR_NONE ((unsigned long) -1)
293 #endif
294
295 #ifdef TIME_WITH_SYS_TIME
296 # include <sys/time.h>
297 # include <time.h>
298 #else
299 # ifdef HAVE_SYS_TIME_H
300 #  include <sys/time.h>
301 # else
302 #  include <time.h>
303 # endif
304 #endif
305
306 #ifndef O_BINARY
307 #define O_BINARY 0
308 #endif
309
310 #ifndef O_NOFOLLOW
311 #define O_NOFOLLOW 0
312 #endif
313
314 #ifndef MODE_RW
315 #define MODE_RW 0666
316 #endif
317
318 #if defined(HAVE_WIN32)
319 typedef int64_t   boffset_t;
320 #define caddr_t  char *
321 #else
322 typedef off_t     boffset_t;
323 #endif
324
325 /* These probably should be subroutines */
326 #define Pw(x) \
327    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
328       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
329            strerror(errstat)); \
330    } while(0)
331
332 #define Vw(x) \
333    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
334          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
335            strerror(errstat)); \
336    } while(0)
337
338 #define LockRes()   b_LockRes(__FILE__, __LINE__)
339 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
340
341 #ifdef DEBUG_MEMSET
342 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
343 void b_memset(const char *file, int line, void *mem, int val, size_t num);
344 #endif
345
346 /* we look for simple debug level 
347  * then finally we check if tags are set on debug_level and lvl
348  */
349
350 /*
351   lvl   |   debug_level  | tags  | result
352  -------+----------------+-------+-------
353   0     |   0            |       |  OK
354   T1|0  |   0            |       |  NOK
355   T1|0  |   0            |  T1   |  OK
356   10    |   0            |       |  NOK
357   10    |   10           |       |  OK
358   T1|10 |   10           |       |  NOK
359   T1|10 |   10           |  T1   |  OK
360   T1|10 |   10           |  T2   |  NOK
361  */
362
363 /* The basic test is working because tags are on high bits */
364 #if 1
365 #define chk_dbglvl(lvl) ((lvl) <= debug_level ||                     \
366     (((lvl) & debug_level_tags) && (((lvl) & ~DT_ALL) <= debug_level)))
367 #else
368 /* Alain's macro for debug */
369 #define chk_dbglvl(lvl) (((lvl) & debug_level_tags) || (((lvl) & ~DT_ALL) <= debug_level))
370 #endif
371 /**
372  * The digit following Dmsg and Emsg indicates the number of substitutions in
373  * the message string. We need to do this kludge because non-GNU compilers
374  * do not handle varargs #defines.
375  */
376 /** Debug Messages that are printed */
377 #ifdef DEBUG
378 #define Dmsg0(lvl, msg)             if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg)
379 #define Dmsg1(lvl, msg, a1)         if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1)
380 #define Dmsg2(lvl, msg, a1, a2)     if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
381 #define Dmsg3(lvl, msg, a1, a2, a3) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
382 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
383 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
384 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
385 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
386 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
387 #define Dmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
388 #define Dmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
389 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
390 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
391 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
392 #else
393 #define Dmsg0(lvl, msg)
394 #define Dmsg1(lvl, msg, a1)
395 #define Dmsg2(lvl, msg, a1, a2)
396 #define Dmsg3(lvl, msg, a1, a2, a3)
397 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
398 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
399 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
400 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
401 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
402 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
403 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
404 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
405 #endif /* DEBUG */
406
407 #ifdef TRACE_FILE
408 #define Tmsg0(lvl, msg)             t_msg(__FILE__, __LINE__, lvl, msg)
409 #define Tmsg1(lvl, msg, a1)         t_msg(__FILE__, __LINE__, lvl, msg, a1)
410 #define Tmsg2(lvl, msg, a1, a2)     t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
411 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
412 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
413 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
414 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
415 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
416 #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)
417 #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)
418 #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)
419 #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)
420 #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)
421 #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)
422 #else
423 #define Tmsg0(lvl, msg)
424 #define Tmsg1(lvl, msg, a1)
425 #define Tmsg2(lvl, msg, a1, a2)
426 #define Tmsg3(lvl, msg, a1, a2, a3)
427 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
428 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
429 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
430 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
431 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
432 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
433 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
434 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
435 #endif /* TRACE_FILE */
436
437
438
439 /** Messages that are printed (uses d_msg) */
440 #define Pmsg0(lvl, msg)             p_msg(__FILE__, __LINE__, lvl, msg)
441 #define Pmsg1(lvl, msg, a1)         p_msg(__FILE__, __LINE__, lvl, msg, a1)
442 #define Pmsg2(lvl, msg, a1, a2)     p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
443 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
444 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
445 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
446 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
447 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
448 #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)
449 #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)
450 #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)
451 #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)
452 #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)
453 #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)
454 #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)
455
456
457 /** Daemon Error Messages that are delivered according to the message resource */
458 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
459 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
460 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
461 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
462 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
463 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
464 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
465
466 /** Job Error Messages that are delivered according to the message resource */
467 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
468 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
469 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
470 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
471 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
472 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
473 #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)
474 #define Jmsg7(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6, a7) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
475 #define Jmsg8(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
476
477 /** Queued Job Error Messages that are delivered according to the message resource */
478 #define Qmsg0(jcr, typ, mtime, msg)             q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg)
479 #define Qmsg1(jcr, typ, mtime, msg, a1)         q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1)
480 #define Qmsg2(jcr, typ, mtime, msg, a1, a2)     q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2)
481 #define Qmsg3(jcr, typ, mtime, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3)
482 #define Qmsg4(jcr, typ, mtime, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4)
483 #define Qmsg5(jcr, typ, mtime, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4, a5)
484 #define Qmsg6(jcr, typ, mtime, msg, a1, a2, a3, a4, a5, a6) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4, a5, a6)
485
486
487 /** Memory Messages that are edited into a Pool Memory buffer */
488 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
489 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
490 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
491 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
492 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
493 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
494 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
495 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
496 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
497 #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)
498 #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)
499
500 class POOL_MEM;
501 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
502 int  Mmsg(POOLMEM **msgbuf, const char *fmt,...);
503 int  Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
504 int  Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
505
506 #define MmsgD0(level, msgbuf, fmt) \
507    { Mmsg(msgbuf, fmt); Dmsg1(level, "%s", msgbuf); }
508 #define MmsgD1(level, msgbuf, fmt, a1) \
509    { Mmsg(msgbuf, fmt, a1); Dmsg1(level, "%s", msgbuf); }
510 #define MmsgD2(level, msgbuf, fmt, a1, a2) \
511    { Mmsg(msgbuf, fmt, a1, a2); Dmsg1(level, "%s", msgbuf); }
512 #define MmsgD3(level, msgbuf, fmt, a1, a2, a3) \
513    { Mmsg(msgbuf, fmt, a1, a2, a3); Dmsg1(level, "%s", msgbuf); }
514 #define MmsgD4(level, msgbuf, fmt, a1, a2, a3, a4) \
515    { Mmsg(msgbuf, fmt, a1, a2, a3, a4); Dmsg1(level, "%s", msgbuf); }
516 #define MmsgD5(level, msgbuf, fmt, a1, a2, a3, a4, a5) \
517    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5); Dmsg1(level, "%s", msgbuf); }
518 #define MmsgD6(level, msgbuf, fmt, a1, a2, a3, a4, a5, a6) \
519    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5, a6); Dmsg1(level, "%s", msgbuf); }
520
521 #define MmsgT0(level, msgbuf, fmt) \
522    { Mmsg(msgbuf, fmt); Tmsg1(level, "%s", msgbuf); }
523 #define MmsgT1(level, msgbuf, fmt, a1) \
524    { Mmsg(msgbuf, fmt, a1); Tmsg1(level, "%s", msgbuf); }
525 #define MmsgT2(level, msgbuf, fmt, a1, a2) \
526    { Mmsg(msgbuf, fmt, a1, a2); Tmsg1(level, "%s", msgbuf); }
527 #define MmsgT3(level, msgbuf, fmt, a1, a2, a3) \
528    { Mmsg(msgbuf, fmt, a1, a2, a3); Tmsg1(level, "%s", msgbuf); }
529 #define MmsgT4(level, msgbuf, fmt, a1, a2, a3, a4) \
530    { Mmsg(msgbuf, fmt, a1, a2, a3, a4); Tmsg1(level, "%s", msgbuf); }
531 #define MmsgT5(level, msgbuf, fmt, a1, a2, a3, a4, a5) \
532    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5); Tmsg1(level, "%s", msgbuf); }
533 #define MmsgT6(level, msgbuf, fmt, a1, a2, a3, a4, a5, a6) \
534    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5, a6); Tmsg1(level, "%s", msgbuf); }
535
536 class JCR;
537 void d_msg(const char *file, int line, int64_t level, const char *fmt,...);
538 void p_msg(const char *file, int line, int level, const char *fmt,...);
539 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
540 void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
541 void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
542 int  m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
543 int  m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
544 void t_msg(const char *file, int line, int64_t level, const char *fmt,...);
545
546
547 /** Use our strdup with smartalloc */
548 #ifndef HAVE_WXCONSOLE
549 #undef strdup
550 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
551 #else 
552 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
553 #ifndef ENABLE_NLS
554 #undef _
555 #undef setlocale
556 #undef textdomain
557 #undef bindtextdomain
558 #endif  
559 #endif
560
561 /** Use our fgets which handles interrupts */
562 #undef fgets
563 #define fgets(x,y,z) bfgets((x), (y), (z))
564
565 /** Use our sscanf, which is safer and works with known sizes */
566 #define sscanf bsscanf
567
568 #ifdef DEBUG
569 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
570 #else
571 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
572 #endif
573
574 #ifdef DEBUG
575 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
576 #endif
577
578 /** Macro to simplify free/reset pointers */
579 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
580
581 /* Use bfopen instead of fopen */
582 #define fopen(path, mode) bfopen(path, mode)
583
584 /**
585  * Replace codes needed in both file routines and non-file routines
586  * Job replace codes -- in "replace"
587  */
588 #define REPLACE_ALWAYS   'a'
589 #define REPLACE_IFNEWER  'w'
590 #define REPLACE_NEVER    'n'
591 #define REPLACE_IFOLDER  'o'
592
593 /** This probably should be done on a machine by machine basis, but it works */
594 /** This is critical for the smartalloc routines to properly align memory */
595 #define ALIGN_SIZE (sizeof(double))
596 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
597
598
599 /* =============================================================
600  *               OS Dependent defines
601  * ============================================================= 
602  */
603 #if defined (__digital__) && defined (__unix__)
604 /* Tru64 - has 64 bit fseeko and ftello */
605 #define  fseeko fseek
606 #define  ftello ftell
607 #endif /* digital stuff */
608
609 #ifndef HAVE_FSEEKO
610 /* This OS does not handle 64 bit fseeks and ftells */
611 #define  fseeko fseek
612 #define  ftello ftell
613 #endif
614
615
616 #ifdef HAVE_WIN32
617 /*
618  *   Windows
619  */
620 #define PathSeparator '\\'
621
622 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
623 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
624 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
625
626 extern void pause_msg(const char *file, const char *func, int line, const char *msg);
627 #define pause(msg) if (debug_level) pause_msg(__FILE__, __func__, __LINE__, (msg))
628
629 #else /* Unix/Linux */
630 #define PathSeparator '/'
631 /* Define Winsock functions if we aren't on Windows */
632
633 #define WSA_Init() 0 /* 0 = success */
634 #define WSACleanup() 0 /* 0 = success */
635
636 inline bool IsPathSeparator(int ch) { return ch == '/'; }
637 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
638 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
639 #define pause(msg)
640 #endif /* HAVE_WIN32 */
641
642 #ifdef HAVE_DARWIN_OS
643 /* Apparently someone forgot to wrap getdomainname as a C function */
644 #ifdef __cplusplus
645 extern "C" {
646 #endif
647 int getdomainname(char *name, int namelen);
648 #ifdef __cplusplus
649 }
650 #endif
651 #endif /* HAVE_DARWIN_OS */
652
653
654 /* **** Unix Systems **** */
655 #ifdef HAVE_SUN_OS
656 /*
657  * On Solaris 2.5/2.6/7 and 8, threads are not timesliced by default,
658  * so we need to explictly increase the conncurrency level.
659  */
660 #ifdef USE_THR_SETCONCURRENCY
661 #include <thread.h>
662 #define set_thread_concurrency(x)  thr_setconcurrency(x)
663 extern int thr_setconcurrency(int);
664 #define SunOS 1
665 #else
666 #define set_thread_concurrency(x)
667 #define thr_setconcurrency(x)
668 #endif
669
670 #else
671 #define set_thread_concurrency(x)
672 #endif /* HAVE_SUN_OS */
673
674
675 #ifdef HAVE_OSF1_OS
676 #ifdef __cplusplus
677 extern "C" {
678 #endif
679 int fchdir(int filedes);
680 long gethostid(void);
681 int getdomainname(char *name, int namelen);
682 #ifdef __cplusplus
683 }
684 #endif
685 #endif /* HAVE_OSF1_OS */
686
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 #ifdef __cplusplus
697 extern  "C" {
698 #endif
699 int getdomainname(char *name, int namlen);
700 int setdomainname(char *name, int namlen);
701 #ifdef __cplusplus
702
703 #endif
704 #endif /* HAVE_HPUX_OS */
705
706
707 /** Disabled because it breaks internationalisation...
708 #undef HAVE_SETLOCALE
709 #ifdef HAVE_SETLOCALE
710 #include <locale.h>
711 #else
712 #define setlocale(x, y) ("ANSI_X3.4-1968")
713 #endif
714 #ifdef HAVE_NL_LANGINFO
715 #include <langinfo.h>
716 #else
717 #define nl_langinfo(x) ("ANSI_X3.4-1968")
718 #endif
719 */
720
721 /** Determine endianes */
722 static inline bool bigendian() { return htonl(1) == 1L; }
723
724 #ifndef __GNUC__
725 #define __PRETTY_FUNCTION__ __func__
726 #endif
727 #ifdef HAVE_SUN_OS
728 #undef ENTER_LEAVE
729 #endif
730 #ifdef ENTER_LEAVE
731 #define Enter(lvl) Dmsg1(lvl, "Enter: %s\n", __PRETTY_FUNCTION__)
732 #define Leave(lvl) Dmsg1(lvl, "Leave: %s\n", __PRETTY_FUNCTION__)
733 #else
734 #define Enter(lvl)
735 #define Leave(lvl)
736 #endif
737
738 #ifdef __GNUC__x
739 # define CHECK_FORMAT(fun, f, a) __attribute__ ((format (fun, f, a)))
740 #else
741 # define CHECK_FORMAT(fun, f, a)
742 #endif
743
744 #endif /* _BACONFIG_H */