2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * General header file configurations that apply to
21 * all daemons. System dependent stuff goes here.
28 /* Bacula common configuration defines */
42 #define ETIME ETIMEDOUT
45 #ifdef HAVE_IOCTL_ULINT_REQUEST
46 #define ioctl_req_t unsigned long int
48 #define ioctl_req_t int
51 #define MANUAL_AUTH_URL "http://www.bacula.org/rel-manual/en/problems/Bacula_Frequently_Asked_Que.html"
56 # define __PROTO(p) ()
60 #define ASSERT(x) if (!(x)) { \
62 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
63 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
66 #define ASSERT2(x,y) if (!(x)) { \
67 set_assert_msg(__FILE__, __LINE__, y); \
68 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
69 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
78 #define ASSERTD(x, y) if (!(x)) { \
79 set_assert_msg(__FILE__, __LINE__, y); \
80 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
81 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
88 /* Allow printing of NULL pointers */
89 #define NPRT(x) (x)?(x):_("*None*")
90 #define NPRTB(x) (x)?(x):""
92 #if defined(HAVE_WIN32)
94 #define WIN32_REPARSE_POINT 1 /* Can be any number of "funny" directories except the next two */
95 #define WIN32_MOUNT_POINT 2 /* Directory link to Volume */
96 #define WIN32_JUNCTION_POINT 3 /* Directory link to a directory */
98 /* Reduce compiler warnings from Windows vss code */
101 void InitWinAPIWrapper();
103 #define OSDependentInit() InitWinAPIWrapper()
107 #define clear_thread_id(x) memset(&(x), 0, sizeof(x))
109 #if defined(BUILDING_DLL)
110 # define DLL_IMP_EXP _declspec(dllexport)
111 #elif defined(USING_DLL)
112 # define DLL_IMP_EXP _declspec(dllimport)
117 #if defined(USING_CATS)
118 # define CATS_IMP_EXP _declspec(dllimport)
120 # define CATS_IMP_EXP
123 #else /* HAVE_WIN32 */
125 #define clear_thread_id(x) x = 0
130 #define OSDependentInit()
132 #endif /* HAVE_WIN32 */
139 #define _(s) gettext((s))
144 #else /* !ENABLE_NLS */
148 #undef bindtextdomain
158 #define textdomain(d)
160 #ifndef bindtextdomain
161 #define bindtextdomain(p, d)
164 #define setlocale(p, d)
166 #endif /* ENABLE_NLS */
169 /* Use the following for strings not to be translated */
172 /* This should go away! ****FIXME***** */
173 #define MAXSTRING 500
175 /* Maximum length to edit time/date */
176 #define MAX_TIME_LENGTH 50
178 /* Maximum Name length including EOS */
179 #define MAX_NAME_LENGTH 128
181 /* Maximum escaped Name lenght including EOS 2*MAX_NAME_LENGTH+1 */
182 #define MAX_ESCAPE_NAME_LENGTH 257
184 /* Maximume number of user entered command args */
185 #define MAX_CMD_ARGS 30
187 /* All tape operations MUST be a multiple of this */
188 #define TAPE_BSIZE 1024
191 #define B_DEV_BSIZE DEV_BSIZE
194 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
195 #define B_DEV_BSIZE BSIZE
199 #define B_DEV_BSIZE 512
203 * Set to time limit for other end to respond to
204 * authentication. Normally 10 minutes is *way*
205 * more than enough. The idea is to keep the Director
206 * from hanging because there is a dead connection on
209 #define AUTH_TIMEOUT 60 * 10
212 * Default network buffer size
214 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
217 * Tape label types -- stored in catalog
219 #define B_BACULA_LABEL 0
220 #define B_ANSI_LABEL 1
221 #define B_IBM_LABEL 2
225 * If you update this table, be sure to add an
226 * entry in prt_dev_types[] in stored/dev.c
227 * This number is stored in the Catalog as VolType or VolParts, do not change.
234 B_VTAPE_DEV= 5, /* change to B_TAPE_DEV after init */
236 B_VTL_DEV = 7, /* Virtual tape library device */
237 B_ADATA_DEV = 8, /* Aligned data Data file */
238 B_ALIGNED_DEV = 9, /* Aligned data Meta file */
239 B_NULL_DEV = 11, /* /dev/null for testing */
240 B_VALIGNED_DEV = 12, /* Virtual for Aligned device (not stored) */
241 B_VDEDUP_DEV = 13, /* Virtual for Dedup device (not stored) */
242 B_CLOUD_DEV = 14 /* New Cloud device type (available in 8.8) */
246 * Actions on purge (bit mask)
248 #define ON_PURGE_TRUNCATE 1
250 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
251 #define OFFSET_FADDR_SIZE (sizeof(uint64_t))
253 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
254 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
258 * This is for dumb compilers/libraries like Solaris. Linux GCC
259 * does it correctly, so it might be worthwhile
260 * to remove the isascii(c) with ifdefs on such
263 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
264 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
265 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
266 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
267 #define B_ISXDIGIT(c) (isascii((int)(c)) && isxdigit((int)(c)))
269 /** For multiplying by 10 with shift and addition */
270 #define B_TIMES10(d) ((d<<3)+(d<<1))
273 typedef void (HANDLER)();
274 typedef int (INTHANDLER)();
277 # define SETPGRP_ARGS(x, y) /* No arguments */
279 # define SETPGRP_ARGS(x, y) (x, y)
283 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
286 /** Added by KES to deal with Win32 systems */
288 #define S_ISWIN32 020000
292 #define INADDR_NONE ((unsigned long) -1)
295 #ifdef TIME_WITH_SYS_TIME
296 # include <sys/time.h>
299 # ifdef HAVE_SYS_TIME_H
300 # include <sys/time.h>
318 #if defined(HAVE_WIN32)
319 typedef int64_t boffset_t;
320 #define caddr_t char *
322 typedef off_t boffset_t;
325 /* These probably should be subroutines */
327 do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
328 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
329 strerror(errstat)); \
333 do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
334 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
335 strerror(errstat)); \
338 #define LockRes() b_LockRes(__FILE__, __LINE__)
339 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
342 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
343 void b_memset(const char *file, int line, void *mem, int val, size_t num);
346 /* we look for simple debug level
347 * then finally we check if tags are set on debug_level and lvl
351 lvl | debug_level | tags | result
352 -------+----------------+-------+-------
360 T1|10 | 10 | T2 | NOK
363 /* The basic test is working because tags are on high bits */
365 #define chk_dbglvl(lvl) ((lvl) <= debug_level || \
366 (((lvl) & debug_level_tags) && (((lvl) & ~DT_ALL) <= debug_level)))
368 /* Alain's macro for debug */
369 #define chk_dbglvl(lvl) (((lvl) & debug_level_tags) || (((lvl) & ~DT_ALL) <= debug_level))
372 * The digit following Dmsg and Emsg indicates the number of substitutions in
373 * the message string. We need to do this kludge because non-GNU compilers
374 * do not handle varargs #defines.
376 /** Debug Messages that are printed */
378 #define Dmsg0(lvl, msg) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg)
379 #define Dmsg1(lvl, msg, a1) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1)
380 #define Dmsg2(lvl, msg, a1, a2) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
381 #define Dmsg3(lvl, msg, a1, a2, a3) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
382 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
383 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
384 #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)
385 #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)
386 #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)
387 #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)
388 #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)
389 #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)
390 #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)
391 #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)
393 #define Dmsg0(lvl, msg)
394 #define Dmsg1(lvl, msg, a1)
395 #define Dmsg2(lvl, msg, a1, a2)
396 #define Dmsg3(lvl, msg, a1, a2, a3)
397 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
398 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
399 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
400 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
401 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
402 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
403 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
404 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
408 #define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg)
409 #define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1)
410 #define Tmsg2(lvl, msg, a1, a2) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
411 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
412 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
413 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
414 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
415 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
416 #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)
417 #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)
418 #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)
419 #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)
420 #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)
421 #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)
423 #define Tmsg0(lvl, msg)
424 #define Tmsg1(lvl, msg, a1)
425 #define Tmsg2(lvl, msg, a1, a2)
426 #define Tmsg3(lvl, msg, a1, a2, a3)
427 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
428 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
429 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
430 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
431 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
432 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
433 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
434 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
435 #endif /* TRACE_FILE */
439 /** Messages that are printed (uses d_msg) */
440 #define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg)
441 #define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1)
442 #define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
443 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
444 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
445 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
446 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
447 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
448 #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)
449 #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)
450 #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)
451 #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)
452 #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)
453 #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)
454 #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)
457 /** Daemon Error Messages that are delivered according to the message resource */
458 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
459 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
460 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
461 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
462 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
463 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
464 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
466 /** Job Error Messages that are delivered according to the message resource */
467 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
468 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
469 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
470 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
471 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
472 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
473 #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)
474 #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)
475 #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)
477 /** Queued Job Error Messages that are delivered according to the message resource */
478 #define Qmsg0(jcr, typ, mtime, msg) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg)
479 #define Qmsg1(jcr, typ, mtime, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1)
480 #define Qmsg2(jcr, typ, mtime, msg, a1, a2) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2)
481 #define Qmsg3(jcr, typ, mtime, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3)
482 #define Qmsg4(jcr, typ, mtime, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4)
483 #define Qmsg5(jcr, typ, mtime, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, mtime, msg, a1, a2, a3, a4, a5)
484 #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)
487 /** Memory Messages that are edited into a Pool Memory buffer */
488 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
489 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
490 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
491 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
492 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
493 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
494 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
495 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
496 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
497 #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)
498 #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)
501 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
502 int Mmsg(POOLMEM **msgbuf, const char *fmt,...);
503 int Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
504 int Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
506 #define MmsgD0(level, msgbuf, fmt) \
507 { Mmsg(msgbuf, fmt); Dmsg1(level, "%s", msgbuf); }
508 #define MmsgD1(level, msgbuf, fmt, a1) \
509 { Mmsg(msgbuf, fmt, a1); Dmsg1(level, "%s", msgbuf); }
510 #define MmsgD2(level, msgbuf, fmt, a1, a2) \
511 { Mmsg(msgbuf, fmt, a1, a2); Dmsg1(level, "%s", msgbuf); }
512 #define MmsgD3(level, msgbuf, fmt, a1, a2, a3) \
513 { Mmsg(msgbuf, fmt, a1, a2, a3); Dmsg1(level, "%s", msgbuf); }
514 #define MmsgD4(level, msgbuf, fmt, a1, a2, a3, a4) \
515 { Mmsg(msgbuf, fmt, a1, a2, a3, a4); Dmsg1(level, "%s", msgbuf); }
516 #define MmsgD5(level, msgbuf, fmt, a1, a2, a3, a4, a5) \
517 { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5); Dmsg1(level, "%s", msgbuf); }
518 #define MmsgD6(level, msgbuf, fmt, a1, a2, a3, a4, a5, a6) \
519 { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5, a6); Dmsg1(level, "%s", msgbuf); }
521 #define MmsgT0(level, msgbuf, fmt) \
522 { Mmsg(msgbuf, fmt); Tmsg1(level, "%s", msgbuf); }
523 #define MmsgT1(level, msgbuf, fmt, a1) \
524 { Mmsg(msgbuf, fmt, a1); Tmsg1(level, "%s", msgbuf); }
525 #define MmsgT2(level, msgbuf, fmt, a1, a2) \
526 { Mmsg(msgbuf, fmt, a1, a2); Tmsg1(level, "%s", msgbuf); }
527 #define MmsgT3(level, msgbuf, fmt, a1, a2, a3) \
528 { Mmsg(msgbuf, fmt, a1, a2, a3); Tmsg1(level, "%s", msgbuf); }
529 #define MmsgT4(level, msgbuf, fmt, a1, a2, a3, a4) \
530 { Mmsg(msgbuf, fmt, a1, a2, a3, a4); Tmsg1(level, "%s", msgbuf); }
531 #define MmsgT5(level, msgbuf, fmt, a1, a2, a3, a4, a5) \
532 { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5); Tmsg1(level, "%s", msgbuf); }
533 #define MmsgT6(level, msgbuf, fmt, a1, a2, a3, a4, a5, a6) \
534 { Mmsg(msgbuf, fmt, a1, a2, a3, a4, a5, a6); Tmsg1(level, "%s", msgbuf); }
537 void d_msg(const char *file, int line, int64_t level, const char *fmt,...);
538 void p_msg(const char *file, int line, int level, const char *fmt,...);
539 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
540 void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
541 void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
542 int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
543 int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
544 void t_msg(const char *file, int line, int64_t level, const char *fmt,...);
547 /** Use our strdup with smartalloc */
548 #ifndef HAVE_WXCONSOLE
550 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
552 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
557 #undef bindtextdomain
561 /** Use our fgets which handles interrupts */
563 #define fgets(x,y,z) bfgets((x), (y), (z))
565 /** Use our sscanf, which is safer and works with known sizes */
566 #define sscanf bsscanf
569 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
571 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
575 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
578 /** Macro to simplify free/reset pointers */
579 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
581 /* Use bfopen instead of fopen */
582 #define fopen(path, mode) bfopen(path, mode)
585 * Replace codes needed in both file routines and non-file routines
586 * Job replace codes -- in "replace"
588 #define REPLACE_ALWAYS 'a'
589 #define REPLACE_IFNEWER 'w'
590 #define REPLACE_NEVER 'n'
591 #define REPLACE_IFOLDER 'o'
593 /** This probably should be done on a machine by machine basis, but it works */
594 /** This is critical for the smartalloc routines to properly align memory */
595 #define ALIGN_SIZE (sizeof(double))
596 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
599 /* =============================================================
600 * OS Dependent defines
601 * =============================================================
603 #if defined (__digital__) && defined (__unix__)
604 /* Tru64 - has 64 bit fseeko and ftello */
607 #endif /* digital stuff */
610 /* This OS does not handle 64 bit fseeks and ftells */
620 #define PathSeparator '\\'
622 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
623 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
624 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
626 extern void pause_msg(const char *file, const char *func, int line, const char *msg);
627 #define pause(msg) if (debug_level) pause_msg(__FILE__, __func__, __LINE__, (msg))
629 #else /* Unix/Linux */
630 #define PathSeparator '/'
631 /* Define Winsock functions if we aren't on Windows */
633 #define WSA_Init() 0 /* 0 = success */
634 #define WSACleanup() 0 /* 0 = success */
636 inline bool IsPathSeparator(int ch) { return ch == '/'; }
637 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
638 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
640 #endif /* HAVE_WIN32 */
642 #ifdef HAVE_DARWIN_OS
643 /* Apparently someone forgot to wrap getdomainname as a C function */
647 int getdomainname(char *name, int namelen);
651 #endif /* HAVE_DARWIN_OS */
654 /* **** Unix Systems **** */
657 * On Solaris 2.5/2.6/7 and 8, threads are not timesliced by default,
658 * so we need to explictly increase the conncurrency level.
660 #ifdef USE_THR_SETCONCURRENCY
662 #define set_thread_concurrency(x) thr_setconcurrency(x)
663 extern int thr_setconcurrency(int);
666 #define set_thread_concurrency(x)
667 #define thr_setconcurrency(x)
671 #define set_thread_concurrency(x)
672 #endif /* HAVE_SUN_OS */
679 int fchdir(int filedes);
680 long gethostid(void);
681 int getdomainname(char *name, int namelen);
685 #endif /* HAVE_OSF1_OS */
691 /** the {get,set}domainname() functions exist in HPUX's libc.
692 * the configure script detects that correctly.
693 * the problem is no system headers declares the prototypes for these functions
699 int getdomainname(char *name, int namlen);
700 int setdomainname(char *name, int namlen);
704 #endif /* HAVE_HPUX_OS */
707 /** Disabled because it breaks internationalisation...
708 #undef HAVE_SETLOCALE
709 #ifdef HAVE_SETLOCALE
712 #define setlocale(x, y) ("ANSI_X3.4-1968")
714 #ifdef HAVE_NL_LANGINFO
715 #include <langinfo.h>
717 #define nl_langinfo(x) ("ANSI_X3.4-1968")
721 /** Determine endianes */
722 static inline bool bigendian() { return htonl(1) == 1L; }
725 #define __PRETTY_FUNCTION__ __func__
731 #define Enter(lvl) Dmsg1(lvl, "Enter: %s\n", __PRETTY_FUNCTION__)
732 #define Leave(lvl) Dmsg1(lvl, "Leave: %s\n", __PRETTY_FUNCTION__)
739 # define CHECK_FORMAT(fun, f, a) __attribute__ ((format (fun, f, a)))
741 # define CHECK_FORMAT(fun, f, a)
744 #endif /* _BACONFIG_H */