2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
21 * General header file configurations that apply to
22 * all daemons. System dependent stuff goes here.
30 /* Bacula common configuration defines */
44 #define ETIME ETIMEDOUT
47 #ifdef HAVE_IOCTL_ULINT_REQUEST
48 #define ioctl_req_t unsigned long int
50 #define ioctl_req_t int
53 #define MANUAL_AUTH_URL "http://www.bacula.org/rel-manual/en/problems/Bacula_Frequently_Asked_Que.html"
58 # define __PROTO(p) ()
62 #define ASSERT(x) if (!(x)) { \
64 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
65 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
68 #define ASSERT2(x,y) if (!(x)) { \
69 set_assert_msg(__FILE__, __LINE__, y); \
70 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
71 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
80 #define ASSERTD(x, y) if (!(x)) { \
81 set_assert_msg(__FILE__, __LINE__, y); \
82 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
83 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
90 /* Allow printing of NULL pointers */
91 #define NPRT(x) (x)?(x):_("*None*")
92 #define NPRTB(x) (x)?(x):""
94 #if defined(HAVE_WIN32)
96 #define WIN32_REPARSE_POINT 1 /* Can be any number of "funny" directories except the next two */
97 #define WIN32_MOUNT_POINT 2 /* Directory link to Volume */
98 #define WIN32_JUNCTION_POINT 3 /* Directory link to a directory */
100 /* Reduce compiler warnings from Windows vss code */
103 void InitWinAPIWrapper();
105 #define OSDependentInit() InitWinAPIWrapper()
109 #define clear_thread_id(x) memset(&(x), 0, sizeof(x))
111 #if defined(BUILDING_DLL)
112 # define DLL_IMP_EXP _declspec(dllexport)
113 #elif defined(USING_DLL)
114 # define DLL_IMP_EXP _declspec(dllimport)
119 #if defined(USING_CATS)
120 # define CATS_IMP_EXP _declspec(dllimport)
122 # define CATS_IMP_EXP
125 #else /* HAVE_WIN32 */
127 #define clear_thread_id(x) x = 0
132 #define OSDependentInit()
134 #endif /* HAVE_WIN32 */
141 #define _(s) gettext((s))
146 #else /* !ENABLE_NLS */
150 #undef bindtextdomain
160 #define textdomain(d)
162 #ifndef bindtextdomain
163 #define bindtextdomain(p, d)
166 #define setlocale(p, d)
168 #endif /* ENABLE_NLS */
171 /* Use the following for strings not to be translated */
174 /* This should go away! ****FIXME***** */
175 #define MAXSTRING 500
177 /* Maximum length to edit time/date */
178 #define MAX_TIME_LENGTH 50
180 /* Maximum Name length including EOS */
181 #define MAX_NAME_LENGTH 128
183 /* Maximum escaped Name lenght including EOS 2*MAX_NAME_LENGTH+1 */
184 #define MAX_ESCAPE_NAME_LENGTH 257
186 /* Maximume number of user entered command args */
187 #define MAX_CMD_ARGS 30
189 /* All tape operations MUST be a multiple of this */
190 #define TAPE_BSIZE 1024
193 #define B_DEV_BSIZE DEV_BSIZE
196 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
197 #define B_DEV_BSIZE BSIZE
201 #define B_DEV_BSIZE 512
205 * Set to time limit for other end to respond to
206 * authentication. Normally 10 minutes is *way*
207 * more than enough. The idea is to keep the Director
208 * from hanging because there is a dead connection on
211 #define AUTH_TIMEOUT 60 * 10
214 * Default network buffer size
216 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
219 * Tape label types -- stored in catalog
221 #define B_BACULA_LABEL 0
222 #define B_ANSI_LABEL 1
223 #define B_IBM_LABEL 2
226 * Actions on purge (bit mask)
228 #define ON_PURGE_TRUNCATE 1
230 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
231 #define OFFSET_FADDR_SIZE (sizeof(uint64_t))
233 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
234 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
238 * This is for dumb compilers/libraries like Solaris. Linux GCC
239 * does it correctly, so it might be worthwhile
240 * to remove the isascii(c) with ifdefs on such
243 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
244 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
245 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
246 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
247 #define B_ISXDIGIT(c) (isascii((int)(c)) && isxdigit((int)(c)))
249 /** For multiplying by 10 with shift and addition */
250 #define B_TIMES10(d) ((d<<3)+(d<<1))
253 typedef void (HANDLER)();
254 typedef int (INTHANDLER)();
257 # define SETPGRP_ARGS(x, y) /* No arguments */
259 # define SETPGRP_ARGS(x, y) (x, y)
263 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
266 /** Added by KES to deal with Win32 systems */
268 #define S_ISWIN32 020000
272 #define INADDR_NONE ((unsigned long) -1)
275 #ifdef TIME_WITH_SYS_TIME
276 # include <sys/time.h>
279 # ifdef HAVE_SYS_TIME_H
280 # include <sys/time.h>
298 #if defined(HAVE_WIN32)
299 typedef int64_t boffset_t;
300 #define caddr_t char *
302 typedef off_t boffset_t;
305 /* These probably should be subroutines */
307 do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
308 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
309 strerror(errstat)); \
313 do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
314 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
315 strerror(errstat)); \
318 #define LockRes() b_LockRes(__FILE__, __LINE__)
319 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
322 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
323 void b_memset(const char *file, int line, void *mem, int val, size_t num);
326 /* we look for simple debug level
327 * then finally we check if tags are set on debug_level and lvl
331 lvl | debug_level | tags | result
332 -------+----------------+-------+-------
340 T1|10 | 10 | T2 | NOK
343 /* The basic test is working because tags are on high bits */
345 #define chk_dbglvl(lvl) ((lvl) <= debug_level || \
346 (((lvl) & debug_level_tags) && (((lvl) & ~DT_ALL) <= debug_level)))
348 /* Alain's macro for debug */
349 #define chk_dbglvl(lvl) (((lvl) & debug_level_tags) || (((lvl) & ~DT_ALL) <= debug_level))
352 * The digit following Dmsg and Emsg indicates the number of substitutions in
353 * the message string. We need to do this kludge because non-GNU compilers
354 * do not handle varargs #defines.
356 /** Debug Messages that are printed */
358 #define Dmsg0(lvl, msg) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg)
359 #define Dmsg1(lvl, msg, a1) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1)
360 #define Dmsg2(lvl, msg, a1, a2) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
361 #define Dmsg3(lvl, msg, a1, a2, a3) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
362 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
363 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
364 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
365 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
366 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
367 #define Dmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
368 #define Dmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
369 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
370 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
371 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) if (chk_dbglvl(lvl)) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
373 #define Dmsg0(lvl, msg)
374 #define Dmsg1(lvl, msg, a1)
375 #define Dmsg2(lvl, msg, a1, a2)
376 #define Dmsg3(lvl, msg, a1, a2, a3)
377 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
378 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
379 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
380 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
381 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
382 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
383 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
384 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
388 #define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg)
389 #define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1)
390 #define Tmsg2(lvl, msg, a1, a2) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
391 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
392 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
393 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
394 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
395 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
396 #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)
397 #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)
398 #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)
399 #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)
400 #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)
401 #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)
403 #define Tmsg0(lvl, msg)
404 #define Tmsg1(lvl, msg, a1)
405 #define Tmsg2(lvl, msg, a1, a2)
406 #define Tmsg3(lvl, msg, a1, a2, a3)
407 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
408 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
409 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
410 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
411 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
412 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
413 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
414 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
415 #endif /* TRACE_FILE */
419 /** Messages that are printed (uses d_msg) */
420 #define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg)
421 #define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1)
422 #define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
423 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
424 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
425 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
426 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
427 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
428 #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)
429 #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)
430 #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)
431 #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)
432 #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)
433 #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)
434 #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)
437 /** Daemon Error Messages that are delivered according to the message resource */
438 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
439 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
440 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
441 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
442 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
443 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
444 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
446 /** Job Error Messages that are delivered according to the message resource */
447 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
448 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
449 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
450 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
451 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
452 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
453 #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)
454 #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)
455 #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)
457 /** Queued Job Error Messages that are delivered according to the message resource */
458 #define Qmsg0(jcr, typ, mtime, msg) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg)
459 #define Qmsg1(jcr, typ, mtime, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1)
460 #define Qmsg2(jcr, typ, mtime, msg, a1, a2) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2)
461 #define Qmsg3(jcr, typ, mtime, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3)
462 #define Qmsg4(jcr, typ, mtime, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4)
463 #define Qmsg5(jcr, typ, mtime, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4, a5)
464 #define Qmsg6(jcr, typ, mtime, msg, a1, a2, a3, a4, a5, a6) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4, a5, a6)
467 /** Memory Messages that are edited into a Pool Memory buffer */
468 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
469 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
470 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
471 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
472 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
473 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
474 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
475 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
476 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
477 #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)
478 #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)
481 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
482 int Mmsg(POOLMEM **msgbuf, const char *fmt,...);
483 int Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
484 int Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
486 #define MmsgD0(level, msgbuf, fmt) \
487 { Mmsg(msgbuf, fmt); Dmsg1(level, "%s", msgbuf); }
488 #define MmsgD1(level, msgbuf, fmt, a1) \
489 { Mmsg(msgbuf, fmt, a1); Dmsg1(level, "%s", msgbuf); }
490 #define MmsgD2(level, msgbuf, fmt, a1, a2) \
491 { Mmsg(msgbuf, fmt, a1, a2); Dmsg1(level, "%s", msgbuf); }
492 #define MmsgD3(level, msgbuf, fmt, a1, a2, a3) \
493 { Mmsg(msgbuf, fmt, a1, a2, a3); Dmsg1(level, "%s", msgbuf); }
494 #define MmsgD4(level, msgbuf, fmt, a1, a2, a3, a4) \
495 { Mmsg(msgbuf, fmt, a1, a2, a3, a4); Dmsg1(level, "%s", msgbuf); }
496 #define MmsgD5(level, msgbuf, fmt, a1, a2, a3, a4, a5) \
497 { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5); Dmsg1(level, "%s", msgbuf); }
498 #define MmsgD6(level, msgbuf, fmt, a1, a2, a3, a4, a5, a6) \
499 { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5, a6); Dmsg1(level, "%s", msgbuf); }
502 void d_msg(const char *file, int line, int64_t level, const char *fmt,...);
503 void p_msg(const char *file, int line, int level, const char *fmt,...);
504 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
505 void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
506 void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
507 int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
508 int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
511 /** Use our strdup with smartalloc */
512 #ifndef HAVE_WXCONSOLE
514 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
516 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
521 #undef bindtextdomain
525 /** Use our fgets which handles interrupts */
527 #define fgets(x,y,z) bfgets((x), (y), (z))
529 /** Use our sscanf, which is safer and works with known sizes */
530 #define sscanf bsscanf
533 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
535 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
539 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
542 /** Macro to simplify free/reset pointers */
543 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
546 * Replace codes needed in both file routines and non-file routines
547 * Job replace codes -- in "replace"
549 #define REPLACE_ALWAYS 'a'
550 #define REPLACE_IFNEWER 'w'
551 #define REPLACE_NEVER 'n'
552 #define REPLACE_IFOLDER 'o'
554 /** This probably should be done on a machine by machine basis, but it works */
555 /** This is critical for the smartalloc routines to properly align memory */
556 #define ALIGN_SIZE (sizeof(double))
557 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
560 /* =============================================================
561 * OS Dependent defines
562 * =============================================================
564 #if defined (__digital__) && defined (__unix__)
565 /* Tru64 - has 64 bit fseeko and ftello */
568 #endif /* digital stuff */
571 /* This OS does not handle 64 bit fseeks and ftells */
581 #define PathSeparator '\\'
583 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
584 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
585 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
587 extern void pause_msg(const char *file, const char *func, int line, const char *msg);
588 #define pause(msg) if (debug_level) pause_msg(__FILE__, __func__, __LINE__, (msg))
590 #else /* Unix/Linux */
591 #define PathSeparator '/'
592 /* Define Winsock functions if we aren't on Windows */
594 #define WSA_Init() 0 /* 0 = success */
595 #define WSACleanup() 0 /* 0 = success */
597 inline bool IsPathSeparator(int ch) { return ch == '/'; }
598 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
599 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
601 #endif /* HAVE_WIN32 */
603 #ifdef HAVE_DARWIN_OS
604 /* Apparently someone forgot to wrap getdomainname as a C function */
608 int getdomainname(char *name, int namelen);
612 #endif /* HAVE_DARWIN_OS */
615 /* **** Unix Systems **** */
618 * On Solaris 2.5/2.6/7 and 8, threads are not timesliced by default,
619 * so we need to explictly increase the conncurrency level.
621 #ifdef USE_THR_SETCONCURRENCY
623 #define set_thread_concurrency(x) thr_setconcurrency(x)
624 extern int thr_setconcurrency(int);
627 #define set_thread_concurrency(x)
628 #define thr_setconcurrency(x)
632 #define set_thread_concurrency(x)
633 #endif /* HAVE_SUN_OS */
640 int fchdir(int filedes);
641 long gethostid(void);
642 int getdomainname(char *name, int namelen);
646 #endif /* HAVE_OSF1_OS */
652 /** the {get,set}domainname() functions exist in HPUX's libc.
653 * the configure script detects that correctly.
654 * the problem is no system headers declares the prototypes for these functions
660 int getdomainname(char *name, int namlen);
661 int setdomainname(char *name, int namlen);
665 #endif /* HAVE_HPUX_OS */
668 /** Disabled because it breaks internationalisation...
669 #undef HAVE_SETLOCALE
670 #ifdef HAVE_SETLOCALE
673 #define setlocale(x, y) ("ANSI_X3.4-1968")
675 #ifdef HAVE_NL_LANGINFO
676 #include <langinfo.h>
678 #define nl_langinfo(x) ("ANSI_X3.4-1968")
682 /** Determine endianes */
683 static inline bool bigendian() { return htonl(1) == 1L; }
686 #define __PRETTY_FUNCTION__ __func__
692 #define Enter(lvl) Dmsg1(lvl, "Enter: %s\n", __PRETTY_FUNCTION__)
693 #define Leave(lvl) Dmsg1(lvl, "Leave: %s\n", __PRETTY_FUNCTION__)
700 # define CHECK_FORMAT(fun, f, a) __attribute__ ((format (fun, f, a)))
702 # define CHECK_FORMAT(fun, f, a)
705 #endif /* _BACONFIG_H */