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
64 # define __PROTO(p) ()
68 #define ASSERT(x) if (!(x)) { \
70 Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
71 Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
77 /* Allow printing of NULL pointers */
78 #define NPRT(x) (x)?(x):_("*None*")
79 #define NPRTB(x) (x)?(x):""
81 #if defined(HAVE_WIN32)
83 #define WIN32_REPARSE_POINT 1 /* Can be any number of "funny" directories except the next two */
84 #define WIN32_MOUNT_POINT 2 /* Directory link to Volume */
85 #define WIN32_JUNCTION_POINT 3 /* Directory link to a directory */
87 /* Reduce compiler warnings from Windows vss code */
90 void InitWinAPIWrapper();
92 #define OSDependentInit() InitWinAPIWrapper()
96 #define clear_thread_id(x) memset(&(x), 0, sizeof(x))
98 #if defined(BUILDING_DLL)
99 # define DLL_IMP_EXP _declspec(dllexport)
100 #elif defined(USING_DLL)
101 # define DLL_IMP_EXP _declspec(dllimport)
106 #if defined(USING_CATS)
107 # define CATS_IMP_EXP _declspec(dllimport)
109 # define CATS_IMP_EXP
112 #else /* HAVE_WIN32 */
114 #define clear_thread_id(x) x = 0
119 #define OSDependentInit()
121 #endif /* HAVE_WIN32 */
128 #define _(s) gettext((s))
133 #else /* !ENABLE_NLS */
137 #undef bindtextdomain
147 #define textdomain(d)
149 #ifndef bindtextdomain
150 #define bindtextdomain(p, d)
153 #define setlocale(p, d)
155 #endif /* ENABLE_NLS */
158 /* Use the following for strings not to be translated */
161 /* This should go away! ****FIXME***** */
162 #define MAXSTRING 500
164 /* Maximum length to edit time/date */
165 #define MAX_TIME_LENGTH 50
167 /* Maximum Name length including EOS */
168 #define MAX_NAME_LENGTH 128
170 /* Maximum escaped Name lenght including EOS 2*MAX_NAME_LENGTH+1 */
171 #define MAX_ESCAPE_NAME_LENGTH 257
173 /* Maximume number of user entered command args */
174 #define MAX_CMD_ARGS 30
176 /* All tape operations MUST be a multiple of this */
177 #define TAPE_BSIZE 1024
180 #define B_DEV_BSIZE DEV_BSIZE
183 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
184 #define B_DEV_BSIZE BSIZE
188 #define B_DEV_BSIZE 512
192 * Set to time limit for other end to respond to
193 * authentication. Normally 10 minutes is *way*
194 * more than enough. The idea is to keep the Director
195 * from hanging because there is a dead connection on
198 #define AUTH_TIMEOUT 60 * 10
201 * Default network buffer size
203 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
206 * Tape label types -- stored in catalog
208 #define B_BACULA_LABEL 0
209 #define B_ANSI_LABEL 1
210 #define B_IBM_LABEL 2
213 * Actions on purge (bit mask)
215 #define ON_PURGE_TRUNCATE 1
217 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
218 #define OFFSET_FADDR_SIZE (sizeof(uint64_t))
220 /* Size of crypto length stored at head of crypto buffer. Do NOT change! */
221 #define CRYPTO_LEN_SIZE ((int)sizeof(uint32_t))
225 * This is for dumb compilers/libraries like Solaris. Linux GCC
226 * does it correctly, so it might be worthwhile
227 * to remove the isascii(c) with ifdefs on such
230 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
231 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
232 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
233 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
235 /** For multiplying by 10 with shift and addition */
236 #define B_TIMES10(d) ((d<<3)+(d<<1))
239 typedef void (HANDLER)();
240 typedef int (INTHANDLER)();
243 # define SETPGRP_ARGS(x, y) /* No arguments */
245 # define SETPGRP_ARGS(x, y) (x, y)
249 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
252 /** Added by KES to deal with Win32 systems */
254 #define S_ISWIN32 020000
258 #define INADDR_NONE ((unsigned long) -1)
261 #ifdef TIME_WITH_SYS_TIME
262 # include <sys/time.h>
265 # ifdef HAVE_SYS_TIME_H
266 # include <sys/time.h>
284 #if defined(HAVE_WIN32)
285 typedef int64_t boffset_t;
286 #define caddr_t char *
288 typedef off_t boffset_t;
291 /* These probably should be subroutines */
293 do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
294 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
295 strerror(errstat)); \
299 do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
300 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
301 strerror(errstat)); \
304 #define LockRes() b_LockRes(__FILE__, __LINE__)
305 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
308 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
309 void b_memset(const char *file, int line, void *mem, int val, size_t num);
314 * The digit following Dmsg and Emsg indicates the number of substitutions in
315 * the message string. We need to do this kludge because non-GNU compilers
316 * do not handle varargs #defines.
318 /** Debug Messages that are printed */
320 #define Dmsg0(lvl, msg) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg)
321 #define Dmsg1(lvl, msg, a1) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1)
322 #define Dmsg2(lvl, msg, a1, a2) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
323 #define Dmsg3(lvl, msg, a1, a2, a3) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
324 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
325 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
326 #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)
327 #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)
328 #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)
329 #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)
330 #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)
331 #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)
332 #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)
333 #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)
335 #define Dmsg0(lvl, msg)
336 #define Dmsg1(lvl, msg, a1)
337 #define Dmsg2(lvl, msg, a1, a2)
338 #define Dmsg3(lvl, msg, a1, a2, a3)
339 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
340 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
341 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
342 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
343 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
344 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
345 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
346 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
350 #define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg)
351 #define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1)
352 #define Tmsg2(lvl, msg, a1, a2) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
353 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
354 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
355 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
356 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
357 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
358 #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)
359 #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)
360 #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)
361 #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)
362 #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)
363 #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)
365 #define Tmsg0(lvl, msg)
366 #define Tmsg1(lvl, msg, a1)
367 #define Tmsg2(lvl, msg, a1, a2)
368 #define Tmsg3(lvl, msg, a1, a2, a3)
369 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
370 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
371 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
372 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
373 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
374 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
375 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
376 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
377 #endif /* TRACE_FILE */
381 /** Messages that are printed (uses d_msg) */
382 #define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg)
383 #define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1)
384 #define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
385 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
386 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
387 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
388 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
389 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
390 #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)
391 #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)
392 #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)
393 #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)
394 #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)
395 #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)
396 #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 /** Daemon Error Messages that are delivered according to the message resource */
400 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
401 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
402 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
403 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
404 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
405 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
406 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
408 /** Job Error Messages that are delivered according to the message resource */
409 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
410 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
411 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
412 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
413 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
414 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
415 #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)
417 /** Queued Job Error Messages that are delivered according to the message resource */
418 #define Qmsg0(jcr, typ, lvl, msg) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
419 #define Qmsg1(jcr, typ, lvl, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
420 #define Qmsg2(jcr, typ, lvl, msg, a1, a2) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
421 #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
422 #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
423 #define Qmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
424 #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 /** Memory Messages that are edited into a Pool Memory buffer */
428 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
429 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
430 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
431 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
432 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
433 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
434 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
435 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
436 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
437 #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)
438 #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 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
442 int Mmsg(POOLMEM **msgbuf, const char *fmt,...);
443 int Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
444 int Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
448 void d_msg(const char *file, int line, int level, const char *fmt,...);
449 void p_msg(const char *file, int line, int level, const char *fmt,...);
450 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
451 void j_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
452 void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const char *fmt,...);
453 int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
454 int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
457 /** Use our strdup with smartalloc */
458 #ifndef HAVE_WXCONSOLE
460 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
462 /* Groan, WxWidgets has its own way of doing NLS so cleanup */
467 #undef bindtextdomain
471 /** Use our fgets which handles interrupts */
473 #define fgets(x,y,z) bfgets((x), (y), (z))
475 /** Use our sscanf, which is safer and works with known sizes */
476 #define sscanf bsscanf
479 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
481 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
485 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
488 /** Macro to simplify free/reset pointers */
489 #define bfree_and_null(a) do{if(a){free(a); (a)=NULL;}} while(0)
492 * Replace codes needed in both file routines and non-file routines
493 * Job replace codes -- in "replace"
495 #define REPLACE_ALWAYS 'a'
496 #define REPLACE_IFNEWER 'w'
497 #define REPLACE_NEVER 'n'
498 #define REPLACE_IFOLDER 'o'
500 /** This probably should be done on a machine by machine basis, but it works */
501 /** This is critical for the smartalloc routines to properly align memory */
502 #define ALIGN_SIZE (sizeof(double))
503 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
506 /* =============================================================
507 * OS Dependent defines
508 * =============================================================
512 /* Bad news. This OS cannot handle 64 bit fseeks and ftells */
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' */
527 * On Solaris 2.5, threads are not timesliced by default, so we need to
528 * explictly increase the conncurrency level.
531 #define set_thread_concurrency(x) thr_setconcurrency(x)
532 extern int thr_setconcurrency(int);
538 /** Not needed on most systems */
539 #define set_thread_concurrency(x)
543 #ifdef HAVE_DARWIN_OS
544 /* Apparently someone forgot to wrap getdomainname as a C function */
547 #endif /* __cplusplus */
548 int getdomainname(char *name, int len);
551 #endif /* __cplusplus */
552 #endif /* HAVE_DARWIN_OS */
556 #if defined(HAVE_WIN32)
557 #define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula"
558 #define PathSeparator '\\'
560 inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; }
561 inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); }
562 inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); }
564 extern void pause_msg(const char *file, const char *func, int line, const char *msg);
565 #define pause(msg) if (debug_level) pause_msg(__FILE__, __func__, __LINE__, (msg))
568 #define PathSeparator '/'
569 /* Define Winsock functions if we aren't on Windows */
571 #define WSA_Init() 0 /* 0 = success */
572 #define WSACleanup() 0 /* 0 = success */
574 inline bool IsPathSeparator(int ch) { return ch == '/'; }
575 inline char *first_path_separator(char *path) { return strchr(path, '/'); }
576 inline const char *first_path_separator(const char *path) { return strchr(path, '/'); }
581 /** HP-UX 11 specific workarounds */
586 /** the {get,set}domainname() functions exist in HPUX's libc.
587 * the configure script detects that correctly.
588 * the problem is no system headers declares the prototypes for these functions
593 #endif /* __cplusplus */
594 int getdomainname(char *name, int namelen);
595 int setdomainname(char *name, int namelen);
598 #endif /* __cplusplus */
599 #endif /* HAVE_HPUX_OS */
605 #endif /* __cplusplus */
606 int fchdir(int filedes);
607 long gethostid(void);
608 int getdomainname(char *name, int len);
611 #endif /* __cplusplus */
612 #endif /* HAVE_OSF1_OS */
615 /** Disabled because it breaks internationalisation...
616 #undef HAVE_SETLOCALE
617 #ifdef HAVE_SETLOCALE
620 #define setlocale(x, y) ("ANSI_X3.4-1968")
622 #ifdef HAVE_NL_LANGINFO
623 #include <langinfo.h>
625 #define nl_langinfo(x) ("ANSI_X3.4-1968")
629 /** Determine endianes */
630 static inline bool bigendian() { return htonl(1) == 1L; }
632 #endif /* _BACONFIG_H */