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