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