2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
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
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.
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
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.
29 * General header file configurations that apply to
30 * all daemons. System dependent stuff goes here.
38 /* Bacula common configuration defines */
52 #define ETIME ETIMEDOUT
55 #ifdef HAVE_IOCTL_ULINT_REQUEST
56 #define ioctl_req_t unsigned long int
58 #define ioctl_req_t int
61 #define MANUAL_AUTH_URL "http://www.bacula.org/en/rel-manual/Bacula_Freque_Asked_Questi.html#SECTION00260000000000000000"
66 # define __PROTO(p) ()
70 #define ASSERT(x) if (!(x)) { \
72 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
73 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
76 #define ASSERT2(x,y) if (!(x)) { \
78 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
79 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
87 /* Allow printing of NULL pointers */
88 #define NPRT(x) (x)?(x):_("*None*")
89 #define NPRTB(x) (x)?(x):""
91 #if defined(HAVE_WIN32)
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 */
97 /* Reduce compiler warnings from Windows vss code */
100 void InitWinAPIWrapper();
102 #define OSDependentInit() InitWinAPIWrapper()
106 #define clear_thread_id(x) memset(&(x), 0, sizeof(x))
108 #if defined(BUILDING_DLL)
109 # define DLL_IMP_EXP _declspec(dllexport)
110 #elif defined(USING_DLL)
111 # define DLL_IMP_EXP _declspec(dllimport)
116 #if defined(USING_CATS)
117 # define CATS_IMP_EXP _declspec(dllimport)
119 # define CATS_IMP_EXP
122 #else /* HAVE_WIN32 */
124 #define clear_thread_id(x) x = 0
129 #define OSDependentInit()
131 #endif /* HAVE_WIN32 */
138 #define _(s) gettext((s))
143 #else /* !ENABLE_NLS */
147 #undef bindtextdomain
157 #define textdomain(d)
159 #ifndef bindtextdomain
160 #define bindtextdomain(p, d)
163 #define setlocale(p, d)
165 #endif /* ENABLE_NLS */
168 /* Use the following for strings not to be translated */
171 /* This should go away! ****FIXME***** */
172 #define MAXSTRING 500
174 /* Maximum length to edit time/date */
175 #define MAX_TIME_LENGTH 50
177 /* Maximum Name length including EOS */
178 #define MAX_NAME_LENGTH 128
180 /* Maximum escaped Name lenght including EOS 2*MAX_NAME_LENGTH+1 */
181 #define MAX_ESCAPE_NAME_LENGTH 257
183 /* Maximume number of user entered command args */
184 #define MAX_CMD_ARGS 30
186 /* All tape operations MUST be a multiple of this */
187 #define TAPE_BSIZE 1024
190 #define B_DEV_BSIZE DEV_BSIZE
193 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
194 #define B_DEV_BSIZE BSIZE
198 #define B_DEV_BSIZE 512
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
208 #define AUTH_TIMEOUT 60 * 10
211 * Default network buffer size
213 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
216 * Tape label types -- stored in catalog
218 #define B_BACULA_LABEL 0
219 #define B_ANSI_LABEL 1
220 #define B_IBM_LABEL 2
223 * Actions on purge (bit mask)
225 #define ON_PURGE_TRUNCATE 1
227 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
228 #define OFFSET_FADDR_SIZE (sizeof(uint64_t))
230 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
231 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
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
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)))
245 /** For multiplying by 10 with shift and addition */
246 #define B_TIMES10(d) ((d<<3)+(d<<1))
249 typedef void (HANDLER)();
250 typedef int (INTHANDLER)();
253 # define SETPGRP_ARGS(x, y) /* No arguments */
255 # define SETPGRP_ARGS(x, y) (x, y)
259 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
262 /** Added by KES to deal with Win32 systems */
264 #define S_ISWIN32 020000
268 #define INADDR_NONE ((unsigned long) -1)
271 #ifdef TIME_WITH_SYS_TIME
272 # include <sys/time.h>
275 # ifdef HAVE_SYS_TIME_H
276 # include <sys/time.h>
294 #if defined(HAVE_WIN32)
295 typedef int64_t boffset_t;
296 #define caddr_t char *
298 typedef off_t boffset_t;
301 /* These probably should be subroutines */
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)); \
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)); \
314 #define LockRes() b_LockRes(__FILE__, __LINE__)
315 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
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);
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.
328 /** Debug Messages that are printed */
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)
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)
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)
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 */
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)
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)
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)
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)
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)
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,...);
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, ...);
469 /** Use our strdup with smartalloc */
470 #ifndef HAVE_WXCONSOLE
472 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
474 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
479 #undef bindtextdomain
483 /** Use our fgets which handles interrupts */
485 #define fgets(x,y,z) bfgets((x), (y), (z))
487 /** Use our sscanf, which is safer and works with known sizes */
488 #define sscanf bsscanf
491 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
493 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
497 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
500 /** Macro to simplify free/reset pointers */
501 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
504 * Replace codes needed in both file routines and non-file routines
505 * Job replace codes -- in "replace"
507 #define REPLACE_ALWAYS 'a'
508 #define REPLACE_IFNEWER 'w'
509 #define REPLACE_NEVER 'n'
510 #define REPLACE_IFOLDER 'o'
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))
518 /* =============================================================
519 * OS Dependent defines
520 * =============================================================
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' */
529 /* Bad news. This OS cannot handle 64 bit fseeks and ftells */
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.
540 #ifdef USE_THR_SETCONCURRENCY
542 #define set_thread_concurrency(x) thr_setconcurrency(x)
543 extern int thr_setconcurrency(int);
546 #define set_thread_concurrency(x)
551 * Not needed on most systems
553 #define set_thread_concurrency(x)
557 #ifdef HAVE_DARWIN_OS
558 /* Apparently someone forgot to wrap getdomainname as a C function */
561 #endif /* __cplusplus */
562 int getdomainname(char *name, int len);
565 #endif /* __cplusplus */
566 #endif /* HAVE_DARWIN_OS */
568 #if defined(HAVE_WIN32)
572 #define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula"
573 #define PathSeparator '\\'
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, "/\\"); }
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))
586 #define PathSeparator '/'
587 /* Define Winsock functions if we aren't on Windows */
589 #define WSA_Init() 0 /* 0 = success */
590 #define WSACleanup() 0 /* 0 = success */
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, '/'); }
599 /** HP-UX 11 specific workarounds */
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
611 #endif /* __cplusplus */
612 int getdomainname(char *name, int namelen);
613 int setdomainname(char *name, int namelen);
616 #endif /* __cplusplus */
617 #endif /* HAVE_HPUX_OS */
623 #endif /* __cplusplus */
624 int fchdir(int filedes);
625 long gethostid(void);
626 int getdomainname(char *name, int len);
629 #endif /* __cplusplus */
630 #endif /* HAVE_OSF1_OS */
633 /** Disabled because it breaks internationalisation...
634 #undef HAVE_SETLOCALE
635 #ifdef HAVE_SETLOCALE
638 #define setlocale(x, y) ("ANSI_X3.4-1968")
640 #ifdef HAVE_NL_LANGINFO
641 #include <langinfo.h>
643 #define nl_langinfo(x) ("ANSI_X3.4-1968")
647 /** Determine endianes */
648 static inline bool bigendian() { return htonl(1) == 1L; }
651 #define __PRETTY_FUNCTION__ __func__
654 #define Enter(lvl) Dmsg1(lvl, "Enter: %s\n", __PRETTY_FUNCTION__)
655 #define Leave(lvl) Dmsg1(lvl, "Leave: %s\n", __PRETTY_FUNCTION__)
661 #endif /* _BACONFIG_H */