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