]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
Restore win32 dir from Branch-5.2 and update it
[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 /* Plugin Features */
257 #define PLUGIN_FEATURE_RESTORELISTFILES "RestoreListFiles"
258
259 /**
260  * This is for dumb compilers/libraries like Solaris. Linux GCC
261  * does it correctly, so it might be worthwhile
262  * to remove the isascii(c) with ifdefs on such
263  * "smart" systems.
264  */
265 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
266 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
267 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
268 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
269 #define B_ISXDIGIT(c) (isascii((int)(c)) && isxdigit((int)(c)))
270
271 /** For multiplying by 10 with shift and addition */
272 #define B_TIMES10(d) ((d<<3)+(d<<1))
273
274
275 typedef void (HANDLER)();
276 typedef int (INTHANDLER)();
277
278 #ifdef SETPGRP_VOID
279 # define SETPGRP_ARGS(x, y) /* No arguments */
280 #else
281 # define SETPGRP_ARGS(x, y) (x, y)
282 #endif
283
284 #ifndef S_ISLNK
285 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
286 #endif
287
288 /** Added by KES to deal with Win32 systems */
289 #ifndef S_ISWIN32
290 #define S_ISWIN32 020000
291 #endif
292
293 #ifndef INADDR_NONE
294 #define INADDR_NONE ((unsigned long) -1)
295 #endif
296
297 #ifdef TIME_WITH_SYS_TIME
298 # include <sys/time.h>
299 # include <time.h>
300 #else
301 # ifdef HAVE_SYS_TIME_H
302 #  include <sys/time.h>
303 # else
304 #  include <time.h>
305 # endif
306 #endif
307
308 #ifndef O_BINARY
309 #define O_BINARY 0
310 #endif
311
312 #ifndef O_NOFOLLOW
313 #define O_NOFOLLOW 0
314 #endif
315
316 #ifndef MODE_RW
317 #define MODE_RW 0666
318 #endif
319
320 #if defined(HAVE_WIN32)
321 typedef int64_t   boffset_t;
322 #define caddr_t  char *
323 #else
324 typedef off_t     boffset_t;
325 #endif
326
327 /* These probably should be subroutines */
328 #define Pw(x) \
329    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
330       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
331            strerror(errstat)); \
332    } while(0)
333
334 #define Vw(x) \
335    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
336          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
337            strerror(errstat)); \
338    } while(0)
339
340 #define LockRes()   b_LockRes(__FILE__, __LINE__)
341 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
342
343 #ifdef DEBUG_MEMSET
344 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
345 void b_memset(const char *file, int line, void *mem, int val, size_t num);
346 #endif
347
348 /* we look for simple debug level 
349  * then finally we check if tags are set on debug_level and lvl
350  */
351
352 /*
353   lvl   |   debug_level  | tags  | result
354  -------+----------------+-------+-------
355   0     |   0            |       |  OK
356   T1|0  |   0            |       |  NOK
357   T1|0  |   0            |  T1   |  OK
358   10    |   0            |       |  NOK
359   10    |   10           |       |  OK
360   T1|10 |   10           |       |  NOK
361   T1|10 |   10           |  T1   |  OK
362   T1|10 |   10           |  T2   |  NOK
363  */
364
365 /* The basic test is working because tags are on high bits */
366 #if 1
367 #define chk_dbglvl(lvl) ((lvl) <= debug_level ||                     \
368     (((lvl) & debug_level_tags) && (((lvl) & ~DT_ALL) <= debug_level)))
369 #else
370 /* Alain's macro for debug */
371 #define chk_dbglvl(lvl) (((lvl) & debug_level_tags) || (((lvl) & ~DT_ALL) <= debug_level))
372 #endif
373 /**
374  * The digit following Dmsg and Emsg indicates the number of substitutions in
375  * the message string. We need to do this kludge because non-GNU compilers
376  * do not handle varargs #defines.
377  */
378 /** Debug Messages that are printed */
379 #ifdef DEBUG
380 #define Dmsg0(lvl, msg)             if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg)
381 #define Dmsg1(lvl, msg, a1)         if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1)
382 #define Dmsg2(lvl, msg, a1, a2)     if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
383 #define Dmsg3(lvl, msg, a1, a2, a3) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
384 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
385 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
386 #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)
387 #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)
388 #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)
389 #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)
390 #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)
391 #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)
392 #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)
393 #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)
394 #else
395 #define Dmsg0(lvl, msg)
396 #define Dmsg1(lvl, msg, a1)
397 #define Dmsg2(lvl, msg, a1, a2)
398 #define Dmsg3(lvl, msg, a1, a2, a3)
399 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
400 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
401 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
402 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
403 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
404 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
405 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
406 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
407 #endif /* DEBUG */
408
409 #ifdef TRACE_FILE
410 #define Tmsg0(lvl, msg)             t_msg(__FILE__, __LINE__, lvl, msg)
411 #define Tmsg1(lvl, msg, a1)         t_msg(__FILE__, __LINE__, lvl, msg, a1)
412 #define Tmsg2(lvl, msg, a1, a2)     t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
413 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
414 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
415 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
416 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
417 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
418 #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)
419 #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)
420 #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)
421 #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)
422 #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)
423 #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)
424 #else
425 #define Tmsg0(lvl, msg)
426 #define Tmsg1(lvl, msg, a1)
427 #define Tmsg2(lvl, msg, a1, a2)
428 #define Tmsg3(lvl, msg, a1, a2, a3)
429 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
430 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
431 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
432 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
433 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
434 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
435 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
436 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
437 #endif /* TRACE_FILE */
438
439
440
441 /** Messages that are printed (uses d_msg) */
442 #define Pmsg0(lvl, msg)             p_msg(__FILE__, __LINE__, lvl, msg)
443 #define Pmsg1(lvl, msg, a1)         p_msg(__FILE__, __LINE__, lvl, msg, a1)
444 #define Pmsg2(lvl, msg, a1, a2)     p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
445 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
446 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
447 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
448 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
449 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
450 #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)
451 #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)
452 #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)
453 #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)
454 #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)
455 #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)
456 #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)
457
458
459 /** Daemon Error Messages that are delivered according to the message resource */
460 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
461 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
462 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
463 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
464 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
465 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
466 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
467
468 /** Job Error Messages that are delivered according to the message resource */
469 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
470 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
471 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
472 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
473 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
474 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
475 #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)
476 #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)
477 #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)
478
479 /** Queued Job Error Messages that are delivered according to the message resource */
480 #define Qmsg0(jcr, typ, mtime, msg)             q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg)
481 #define Qmsg1(jcr, typ, mtime, msg, a1)         q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1)
482 #define Qmsg2(jcr, typ, mtime, msg, a1, a2)     q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2)
483 #define Qmsg3(jcr, typ, mtime, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3)
484 #define Qmsg4(jcr, typ, mtime, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4)
485 #define Qmsg5(jcr, typ, mtime, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4, a5)
486 #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)
487
488
489 /** Memory Messages that are edited into a Pool Memory buffer */
490 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
491 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
492 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
493 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
494 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
495 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
496 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
497 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
498 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
499 #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)
500 #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)
501
502 class POOL_MEM;
503 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
504 int  Mmsg(POOLMEM **msgbuf, const char *fmt,...);
505 int  Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
506 int  Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
507
508 #define MmsgD0(level, msgbuf, fmt) \
509    { Mmsg(msgbuf, fmt); Dmsg1(level, "%s", msgbuf); }
510 #define MmsgD1(level, msgbuf, fmt, a1) \
511    { Mmsg(msgbuf, fmt, a1); Dmsg1(level, "%s", msgbuf); }
512 #define MmsgD2(level, msgbuf, fmt, a1, a2) \
513    { Mmsg(msgbuf, fmt, a1, a2); Dmsg1(level, "%s", msgbuf); }
514 #define MmsgD3(level, msgbuf, fmt, a1, a2, a3) \
515    { Mmsg(msgbuf, fmt, a1, a2, a3); Dmsg1(level, "%s", msgbuf); }
516 #define MmsgD4(level, msgbuf, fmt, a1, a2, a3, a4) \
517    { Mmsg(msgbuf, fmt, a1, a2, a3, a4); Dmsg1(level, "%s", msgbuf); }
518 #define MmsgD5(level, msgbuf, fmt, a1, a2, a3, a4, a5) \
519    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5); Dmsg1(level, "%s", msgbuf); }
520 #define MmsgD6(level, msgbuf, fmt, a1, a2, a3, a4, a5, a6) \
521    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5, a6); Dmsg1(level, "%s", msgbuf); }
522
523 #define MmsgT0(level, msgbuf, fmt) \
524    { Mmsg(msgbuf, fmt); Tmsg1(level, "%s", msgbuf); }
525 #define MmsgT1(level, msgbuf, fmt, a1) \
526    { Mmsg(msgbuf, fmt, a1); Tmsg1(level, "%s", msgbuf); }
527 #define MmsgT2(level, msgbuf, fmt, a1, a2) \
528    { Mmsg(msgbuf, fmt, a1, a2); Tmsg1(level, "%s", msgbuf); }
529 #define MmsgT3(level, msgbuf, fmt, a1, a2, a3) \
530    { Mmsg(msgbuf, fmt, a1, a2, a3); Tmsg1(level, "%s", msgbuf); }
531 #define MmsgT4(level, msgbuf, fmt, a1, a2, a3, a4) \
532    { Mmsg(msgbuf, fmt, a1, a2, a3, a4); Tmsg1(level, "%s", msgbuf); }
533 #define MmsgT5(level, msgbuf, fmt, a1, a2, a3, a4, a5) \
534    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5); Tmsg1(level, "%s", msgbuf); }
535 #define MmsgT6(level, msgbuf, fmt, a1, a2, a3, a4, a5, a6) \
536    { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5, a6); Tmsg1(level, "%s", msgbuf); }
537
538 class JCR;
539 void d_msg(const char *file, int line, int64_t level, const char *fmt,...);
540 void p_msg(const char *file, int line, int level, const char *fmt,...);
541 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
542 void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
543 void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
544 int  m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
545 int  m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
546 void t_msg(const char *file, int line, int64_t level, const char *fmt,...);
547
548
549 /** Use our strdup with smartalloc */
550 #ifndef HAVE_WXCONSOLE
551 #undef strdup
552 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
553 #else 
554 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
555 #ifndef ENABLE_NLS
556 #undef _
557 #undef setlocale
558 #undef textdomain
559 #undef bindtextdomain
560 #endif  
561 #endif
562
563 /** Use our fgets which handles interrupts */
564 #undef fgets
565 #define fgets(x,y,z) bfgets((x), (y), (z))
566
567 /** Use our sscanf, which is safer and works with known sizes */
568 #define sscanf bsscanf
569
570 #ifdef DEBUG
571 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
572 #else
573 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
574 #endif
575
576 #ifdef DEBUG
577 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
578 #endif
579
580 /** Macro to simplify free/reset pointers */
581 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
582
583 /* Use bfopen instead of fopen */
584 #define fopen(path, mode) bfopen(path, mode)
585
586 /**
587  * Replace codes needed in both file routines and non-file routines
588  * Job replace codes -- in "replace"
589  */
590 #define REPLACE_ALWAYS   'a'
591 #define REPLACE_IFNEWER  'w'
592 #define REPLACE_NEVER    'n'
593 #define REPLACE_IFOLDER  'o'
594
595 /** This probably should be done on a machine by machine basis, but it works */
596 /** This is critical for the smartalloc routines to properly align memory */
597 #define ALIGN_SIZE (sizeof(double))
598 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
599
600
601 /* =============================================================
602  *               OS Dependent defines
603  * ============================================================= 
604  */
605 #if defined (__digital__) && defined (__unix__)
606 /* Tru64 - has 64 bit fseeko and ftello */
607 #define  fseeko fseek
608 #define  ftello ftell
609 #endif /* digital stuff */
610
611 #ifndef HAVE_FSEEKO
612 /* This OS does not handle 64 bit fseeks and ftells */
613 #define  fseeko fseek
614 #define  ftello ftell
615 #endif
616
617
618 #ifdef HAVE_WIN32
619 /*
620  *   Windows
621  */
622 #define PathSeparator '\\'
623 #define PathSeparatorUp "..\\"
624 #define PathSeparatorCur ".\\"
625
626 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
627 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
628 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
629
630 extern void pause_msg(const char *file, const char *func, int line, const char *msg);
631 #define pause(msg) if (debug_level) pause_msg(__FILE__, __func__, __LINE__, (msg))
632
633 #else /* Unix/Linux */
634 #define PathSeparator '/'
635 /* Define Winsock functions if we aren't on Windows */
636
637 #define WSA_Init() 0 /* 0 = success */
638 #define WSACleanup() 0 /* 0 = success */
639
640 inline bool IsPathSeparator(int ch) { return ch == '/'; }
641 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
642 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
643 #define pause(msg)
644 #endif /* HAVE_WIN32 */
645
646 #ifdef HAVE_DARWIN_OS
647 /* Apparently someone forgot to wrap getdomainname as a C function */
648 #ifdef __cplusplus
649 extern "C" {
650 #endif
651 int getdomainname(char *name, int namelen);
652 #ifdef __cplusplus
653 }
654 #endif
655 #endif /* HAVE_DARWIN_OS */
656
657
658 /* **** Unix Systems **** */
659 #ifdef HAVE_SUN_OS
660 /*
661  * On Solaris 2.5/2.6/7 and 8, threads are not timesliced by default,
662  * so we need to explictly increase the conncurrency level.
663  */
664 #ifdef USE_THR_SETCONCURRENCY
665 #include <thread.h>
666 #define set_thread_concurrency(x)  thr_setconcurrency(x)
667 extern int thr_setconcurrency(int);
668 #define SunOS 1
669 #else
670 #define set_thread_concurrency(x)
671 #define thr_setconcurrency(x)
672 #endif
673
674 #else
675 #define set_thread_concurrency(x)
676 #endif /* HAVE_SUN_OS */
677
678
679 #ifdef HAVE_OSF1_OS
680 #ifdef __cplusplus
681 extern "C" {
682 #endif
683 int fchdir(int filedes);
684 long gethostid(void);
685 int getdomainname(char *name, int namelen);
686 #ifdef __cplusplus
687 }
688 #endif
689 #endif /* HAVE_OSF1_OS */
690
691
692 #ifdef HAVE_HPUX_OS
693 # undef h_errno
694 extern int h_errno;
695 /** the {get,set}domainname() functions exist in HPUX's libc.
696  * the configure script detects that correctly.
697  * the problem is no system headers declares the prototypes for these functions
698  * this is done below
699  */
700 #ifdef __cplusplus
701 extern  "C" {
702 #endif
703 int getdomainname(char *name, int namlen);
704 int setdomainname(char *name, int namlen);
705 #ifdef __cplusplus
706
707 #endif
708 #endif /* HAVE_HPUX_OS */
709
710
711 /** Disabled because it breaks internationalisation...
712 #undef HAVE_SETLOCALE
713 #ifdef HAVE_SETLOCALE
714 #include <locale.h>
715 #else
716 #define setlocale(x, y) ("ANSI_X3.4-1968")
717 #endif
718 #ifdef HAVE_NL_LANGINFO
719 #include <langinfo.h>
720 #else
721 #define nl_langinfo(x) ("ANSI_X3.4-1968")
722 #endif
723 */
724
725 /** Determine endianes */
726 static inline bool bigendian() { return htonl(1) == 1L; }
727
728 #ifndef __GNUC__
729 #define __PRETTY_FUNCTION__ __func__
730 #endif
731 #ifdef HAVE_SUN_OS
732 #undef ENTER_LEAVE
733 #endif
734 #ifdef ENTER_LEAVE
735 #define Enter(lvl) Dmsg1(lvl, "Enter: %s\n", __PRETTY_FUNCTION__)
736 #define Leave(lvl) Dmsg1(lvl, "Leave: %s\n", __PRETTY_FUNCTION__)
737 #else
738 #define Enter(lvl)
739 #define Leave(lvl)
740 #endif
741
742 #ifdef __GNUC__x
743 # define CHECK_FORMAT(fun, f, a) __attribute__ ((format (fun, f, a)))
744 #else
745 # define CHECK_FORMAT(fun, f, a)
746 #endif
747
748 #endif /* _BACONFIG_H */