2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 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 Bacula® is a registered trademark of Kern Sibbald.
17 * General header file configurations that apply to
18 * all daemons. System dependent stuff goes here.
26 /* Bacula common configuration defines */
40 #define ETIME ETIMEDOUT
43 #ifdef HAVE_IOCTL_ULINT_REQUEST
44 #define ioctl_req_t unsigned long int
46 #define ioctl_req_t int
49 #define MANUAL_AUTH_URL "http://www.bacula.org/en/rel-manual/Bacula_Freque_Asked_Questi.html#SECTION00260000000000000000"
54 # define __PROTO(p) ()
58 #define ASSERT(x) if (!(x)) { \
60 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
61 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
64 #define ASSERT2(x,y) if (!(x)) { \
65 set_assert_msg(__FILE__, __LINE__, y); \
66 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
67 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
75 /* Allow printing of NULL pointers */
76 #define NPRT(x) (x)?(x):_("*None*")
77 #define NPRTB(x) (x)?(x):""
79 #if defined(HAVE_WIN32)
81 #define WIN32_REPARSE_POINT 1 /* Can be any number of "funny" directories except the next two */
82 #define WIN32_MOUNT_POINT 2 /* Directory link to Volume */
83 #define WIN32_JUNCTION_POINT 3 /* Directory link to a directory */
85 /* Reduce compiler warnings from Windows vss code */
88 void InitWinAPIWrapper();
90 #define OSDependentInit() InitWinAPIWrapper()
94 #define clear_thread_id(x) memset(&(x), 0, sizeof(x))
96 #if defined(BUILDING_DLL)
97 # define DLL_IMP_EXP _declspec(dllexport)
98 #elif defined(USING_DLL)
99 # define DLL_IMP_EXP _declspec(dllimport)
104 #if defined(USING_CATS)
105 # define CATS_IMP_EXP _declspec(dllimport)
107 # define CATS_IMP_EXP
110 #else /* HAVE_WIN32 */
112 #define clear_thread_id(x) x = 0
117 #define OSDependentInit()
119 #endif /* HAVE_WIN32 */
126 #define _(s) gettext((s))
131 #else /* !ENABLE_NLS */
135 #undef bindtextdomain
145 #define textdomain(d)
147 #ifndef bindtextdomain
148 #define bindtextdomain(p, d)
151 #define setlocale(p, d)
153 #endif /* ENABLE_NLS */
156 /* Use the following for strings not to be translated */
159 /* This should go away! ****FIXME***** */
160 #define MAXSTRING 500
162 /* Maximum length to edit time/date */
163 #define MAX_TIME_LENGTH 50
165 /* Maximum Name length including EOS */
166 #define MAX_NAME_LENGTH 128
168 /* Maximum escaped Name lenght including EOS 2*MAX_NAME_LENGTH+1 */
169 #define MAX_ESCAPE_NAME_LENGTH 257
171 /* Maximume number of user entered command args */
172 #define MAX_CMD_ARGS 30
174 /* All tape operations MUST be a multiple of this */
175 #define TAPE_BSIZE 1024
178 #define B_DEV_BSIZE DEV_BSIZE
181 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
182 #define B_DEV_BSIZE BSIZE
186 #define B_DEV_BSIZE 512
190 * Set to time limit for other end to respond to
191 * authentication. Normally 10 minutes is *way*
192 * more than enough. The idea is to keep the Director
193 * from hanging because there is a dead connection on
196 #define AUTH_TIMEOUT 60 * 10
199 * Default network buffer size
201 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
204 * Tape label types -- stored in catalog
206 #define B_BACULA_LABEL 0
207 #define B_ANSI_LABEL 1
208 #define B_IBM_LABEL 2
211 * Actions on purge (bit mask)
213 #define ON_PURGE_TRUNCATE 1
215 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
216 #define OFFSET_FADDR_SIZE (sizeof(uint64_t))
218 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
219 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
223 * This is for dumb compilers/libraries like Solaris. Linux GCC
224 * does it correctly, so it might be worthwhile
225 * to remove the isascii(c) with ifdefs on such
228 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
229 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
230 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
231 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
233 /** For multiplying by 10 with shift and addition */
234 #define B_TIMES10(d) ((d<<3)+(d<<1))
237 typedef void (HANDLER)();
238 typedef int (INTHANDLER)();
241 # define SETPGRP_ARGS(x, y) /* No arguments */
243 # define SETPGRP_ARGS(x, y) (x, y)
247 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
250 /** Added by KES to deal with Win32 systems */
252 #define S_ISWIN32 020000
256 #define INADDR_NONE ((unsigned long) -1)
259 #ifdef TIME_WITH_SYS_TIME
260 # include <sys/time.h>
263 # ifdef HAVE_SYS_TIME_H
264 # include <sys/time.h>
282 #if defined(HAVE_WIN32)
283 typedef int64_t boffset_t;
284 #define caddr_t char *
286 typedef off_t boffset_t;
289 /* These probably should be subroutines */
291 do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
292 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
293 strerror(errstat)); \
297 do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
298 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
299 strerror(errstat)); \
302 #define LockRes() b_LockRes(__FILE__, __LINE__)
303 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
306 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
307 void b_memset(const char *file, int line, void *mem, int val, size_t num);
310 /* First we look if we have a debug_level set,
311 * then we look for simple debug level without tags
312 * then finally we check if tags are set on debug_level and lvl
314 #define chk_dbglvl(lvl) (debug_level > 0 && ( \
315 ((((lvl) & DT_ALL) == 0) && ((lvl) <= (debug_level & ~DT_ALL))) || \
316 (((lvl) & DT_ALL & debug_level) && (((lvl) & ~DT_ALL) <= (debug_level & ~DT_ALL)))))
319 * The digit following Dmsg and Emsg indicates the number of substitutions in
320 * the message string. We need to do this kludge because non-GNU compilers
321 * do not handle varargs #defines.
323 /** Debug Messages that are printed */
325 #define Dmsg0(lvl, msg) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg)
326 #define Dmsg1(lvl, msg, a1) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1)
327 #define Dmsg2(lvl, msg, a1, a2) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
328 #define Dmsg3(lvl, msg, a1, a2, a3) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
329 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
330 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if (chk_dbglvl(lvl)) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
331 #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)
332 #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)
333 #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)
334 #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)
335 #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)
336 #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)
337 #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)
338 #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)
340 #define Dmsg0(lvl, msg)
341 #define Dmsg1(lvl, msg, a1)
342 #define Dmsg2(lvl, msg, a1, a2)
343 #define Dmsg3(lvl, msg, a1, a2, a3)
344 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
345 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
346 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
347 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
348 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
349 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
350 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
351 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
355 #define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg)
356 #define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1)
357 #define Tmsg2(lvl, msg, a1, a2) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
358 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
359 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
360 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
361 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
362 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
363 #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)
364 #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)
365 #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)
366 #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)
367 #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)
368 #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)
370 #define Tmsg0(lvl, msg)
371 #define Tmsg1(lvl, msg, a1)
372 #define Tmsg2(lvl, msg, a1, a2)
373 #define Tmsg3(lvl, msg, a1, a2, a3)
374 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
375 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
376 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
377 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
378 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
379 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
380 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
381 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
382 #endif /* TRACE_FILE */
386 /** Messages that are printed (uses d_msg) */
387 #define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg)
388 #define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1)
389 #define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
390 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
391 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
392 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
393 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
394 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
395 #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)
396 #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)
397 #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)
398 #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)
399 #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)
400 #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)
401 #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)
404 /** Daemon Error Messages that are delivered according to the message resource */
405 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
406 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
407 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
408 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
409 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
410 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
411 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
413 /** Job Error Messages that are delivered according to the message resource */
414 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
415 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
416 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
417 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
418 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
419 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
420 #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)
421 #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)
422 #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)
424 /** Queued Job Error Messages that are delivered according to the message resource */
425 #define Qmsg0(jcr, typ, lvl, msg) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
426 #define Qmsg1(jcr, typ, lvl, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
427 #define Qmsg2(jcr, typ, lvl, msg, a1, a2) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
428 #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
429 #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
430 #define Qmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
431 #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)
434 /** Memory Messages that are edited into a Pool Memory buffer */
435 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
436 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
437 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
438 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
439 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
440 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
441 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
442 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
443 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
444 #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)
445 #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)
448 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
449 int Mmsg(POOLMEM **msgbuf, const char *fmt,...);
450 int Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
451 int Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
455 void d_msg(const char *file, int line, int64_t level, const char *fmt,...);
456 void p_msg(const char *file, int line, int level, const char *fmt,...);
457 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
458 void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
459 void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
460 int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
461 int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
464 /** Use our strdup with smartalloc */
465 #ifndef HAVE_WXCONSOLE
467 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
469 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
474 #undef bindtextdomain
478 /** Use our fgets which handles interrupts */
480 #define fgets(x,y,z) bfgets((x), (y), (z))
482 /** Use our sscanf, which is safer and works with known sizes */
483 #define sscanf bsscanf
486 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
488 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
492 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
495 /** Macro to simplify free/reset pointers */
496 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
499 * Replace codes needed in both file routines and non-file routines
500 * Job replace codes -- in "replace"
502 #define REPLACE_ALWAYS 'a'
503 #define REPLACE_IFNEWER 'w'
504 #define REPLACE_NEVER 'n'
505 #define REPLACE_IFOLDER 'o'
507 /** This probably should be done on a machine by machine basis, but it works */
508 /** This is critical for the smartalloc routines to properly align memory */
509 #define ALIGN_SIZE (sizeof(double))
510 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
513 /* =============================================================
514 * OS Dependent defines
515 * =============================================================
517 #if defined (__digital__) && defined (__unix__)
518 /* Tru64 - it does have fseeko and ftello , but since ftell/fseek are also 64 bit */
519 /* take this 'shortcut' */
524 /* Bad news. This OS cannot handle 64 bit fseeks and ftells */
532 * On Solaris 2.5/2.6/7 and 8, threads are not timesliced by default,
533 * so we need to explictly increase the conncurrency level.
535 #ifdef USE_THR_SETCONCURRENCY
537 #define set_thread_concurrency(x) thr_setconcurrency(x)
538 extern int thr_setconcurrency(int);
541 #define set_thread_concurrency(x)
546 * Not needed on most systems
548 #define set_thread_concurrency(x)
552 #ifdef HAVE_DARWIN_OS
553 /* Apparently someone forgot to wrap getdomainname as a C function */
556 #endif /* __cplusplus */
557 int getdomainname(char *name, int len);
560 #endif /* __cplusplus */
561 #endif /* HAVE_DARWIN_OS */
563 #if defined(HAVE_WIN32)
567 #define PathSeparator '\\'
569 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
570 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
571 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
573 extern void pause_msg(const char *file, const char *func, int line, const char *msg);
574 #define pause(msg) if (debug_level) pause_msg(__FILE__, __func__, __LINE__, (msg))
580 #define PathSeparator '/'
581 /* Define Winsock functions if we aren't on Windows */
583 #define WSA_Init() 0 /* 0 = success */
584 #define WSACleanup() 0 /* 0 = success */
586 inline bool IsPathSeparator(int ch) { return ch == '/'; }
587 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
588 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
593 /** HP-UX 11 specific workarounds */
598 /** the {get,set}domainname() functions exist in HPUX's libc.
599 * the configure script detects that correctly.
600 * the problem is no system headers declares the prototypes for these functions
605 #endif /* __cplusplus */
606 int getdomainname(char *name, int namelen);
607 int setdomainname(char *name, int namelen);
610 #endif /* __cplusplus */
611 #endif /* HAVE_HPUX_OS */
617 #endif /* __cplusplus */
618 int fchdir(int filedes);
619 long gethostid(void);
620 int getdomainname(char *name, int len);
623 #endif /* __cplusplus */
624 #endif /* HAVE_OSF1_OS */
627 /** Disabled because it breaks internationalisation...
628 #undef HAVE_SETLOCALE
629 #ifdef HAVE_SETLOCALE
632 #define setlocale(x, y) ("ANSI_X3.4-1968")
634 #ifdef HAVE_NL_LANGINFO
635 #include <langinfo.h>
637 #define nl_langinfo(x) ("ANSI_X3.4-1968")
641 /** Determine endianes */
642 static inline bool bigendian() { return htonl(1) == 1L; }
645 #define __PRETTY_FUNCTION__ __func__
651 #define Enter(lvl) Dmsg1(lvl, "Enter: %s\n", __PRETTY_FUNCTION__)
652 #define Leave(lvl) Dmsg1(lvl, "Leave: %s\n", __PRETTY_FUNCTION__)
659 # define CHECK_FORMAT(fun, f, a) __attribute__ ((format (fun, f, a)))
661 # define CHECK_FORMAT(fun, f, a)
664 #endif /* _BACONFIG_H */