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