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