2 * General header file configurations that apply to
3 * all daemons. System dependent stuff goes here.
8 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of
13 the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public
21 License along with this program; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
31 /* Bacula common configuration defines */
37 #define ETIME ETIMEDOUT
43 # define __PROTO(p) ()
47 #define ASSERT(x) if (!(x)) { \
49 Emsg1(M_ERROR, 0, "Failed ASSERT: %s\n", #x); \
55 /* Allow printing of NULL pointers */
56 #define NPRT(x) (x)?(x):"*None*"
60 #define _(s) gettext((s))
69 /* This should go away! ****FIXME***** */
72 /* Maximum length to edit time/date */
73 #define MAX_TIME_LENGTH 30
75 /* Maximum Name length including EOS */
76 #define MAX_NAME_LENGTH 128
78 /* Maximume number of user entered command args */
79 #define MAX_CMD_ARGS 30
81 /* All tape operations MUST be a multiple of this */
82 #define TAPE_BSIZE 1024
83 #if !defined(DEV_BSIZE) && defined(BSIZE)
84 #define DEV_BSIZE BSIZE
91 /* Maximum number of bytes that you can push into a
94 #define MAX_NETWORK_BUFFER_SIZE (32 * 1024)
96 /* Stream definitions. Once defined these must NEVER
97 * change as they go on the storage media.
99 #define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */
100 #define STREAM_FILE_DATA 2 /* Standard uncompressed data */
101 #define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */
102 #define STREAM_GZIP_DATA 4 /* GZip compressed file data */
103 #define STREAM_WIN32_ATTRIBUTES 5 /* Windows attributes (superset of Unix) */
104 #define STREAM_SPARSE_DATA 6 /* Sparse data stream */
105 #define STREAM_SPARSE_GZIP_DATA 7
106 #define STREAM_PROGRAM_NAMES 8 /* program names for program data */
107 #define STREAM_PROGRAM_DATA 9 /* Data needing program */
108 #define STREAM_SHA1_SIGNATURE 10 /* SHA1 signature for the file */
109 #define STREAM_WIN32_DATA 11 /* Win32 BackupRead data */
110 #define STREAM_WIN32_GZIP_DATA 12 /* Gzipped Win32 BackupRead data */
113 * Internal code for Signature types
119 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
120 #define SPARSE_FADDR_SIZE (sizeof(uint64_t))
123 /* This is for dumb compilers/libraries like Solaris. Linux GCC
124 * does it correctly, so it might be worthwhile
125 * to remove the isascii(c) with ifdefs on such
128 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
129 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
130 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
131 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
134 typedef void (HANDLER)();
135 typedef int (INTHANDLER)();
138 # define SETPGRP_ARGS(x, y) /* No arguments */
140 # define SETPGRP_ARGS(x, y) (x, y)
144 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
147 /* Added by KES to deal with Win32 systems */
149 #define S_ISWIN32 020000
153 #define INADDR_NONE ((unsigned long) -1)
156 #ifdef TIME_WITH_SYS_TIME
157 # include <sys/time.h>
160 # ifdef HAVE_SYS_TIME_H
161 # include <sys/time.h>
180 extern void _p(char *file, int line, pthread_mutex_t *m);
181 extern void _v(char *file, int line, pthread_mutex_t *m);
183 #define P(x) _p(__FILE__, __LINE__, &(x))
184 #define V(x) _v(__FILE__, __LINE__, &(x))
188 /* These probably should be subroutines */
190 do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
191 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
192 strerror(errstat)); \
196 do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
197 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
198 strerror(errstat)); \
201 #endif /* DEBUG_MUTEX */
203 /* These probably should be subroutines */
205 do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
206 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
207 strerror(errstat)); \
211 do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
212 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
213 strerror(errstat)); \
218 * The digit following Dmsg and Emsg indicates the number of substitutions in
219 * the message string. We need to do this kludge because non-GNU compilers
220 * do not handle varargs #defines.
222 /* Debug Messages that are printed */
224 #define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg)
225 #define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1)
226 #define Dmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
227 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
228 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
229 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
230 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
231 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
232 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
233 #define Dmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
234 #define Dmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
235 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
236 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
237 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
239 #define Dmsg0(lvl, msg)
240 #define Dmsg1(lvl, msg, a1)
241 #define Dmsg2(lvl, msg, a1, a2)
242 #define Dmsg3(lvl, msg, a1, a2, a3)
243 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
244 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
245 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
246 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
247 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
248 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
249 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
250 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
254 #define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg)
255 #define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1)
256 #define Tmsg2(lvl, msg, a1, a2) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
257 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
258 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
259 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
260 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
261 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
262 #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)
263 #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)
264 #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)
265 #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)
266 #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)
267 #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)
269 #define Tmsg0(lvl, msg)
270 #define Tmsg1(lvl, msg, a1)
271 #define Tmsg2(lvl, msg, a1, a2)
272 #define Tmsg3(lvl, msg, a1, a2, a3)
273 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
274 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
275 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
276 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
277 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
278 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
279 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
280 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
281 #endif /* TRACE_FILE */
285 /* Messages that are printed (uses d_msg) */
286 #define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg)
287 #define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1)
288 #define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
289 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
290 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
291 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
292 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
293 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
294 #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)
295 #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)
296 #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)
297 #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)
298 #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)
299 #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)
300 #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)
303 /* Daemon Error Messages that are delivered according to the message resource */
304 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
305 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
306 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
307 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
308 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
309 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
310 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
312 /* Job Error Messages that are delivered according to the message resource */
313 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
314 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
315 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
316 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
317 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
318 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
319 #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)
322 /* Memory Messages that are edited into a Pool Memory buffer */
323 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
324 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
325 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
326 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
327 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
328 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
329 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
330 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
331 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
332 #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)
333 #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)
335 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
336 int Mmsg(char **msgbuf, char *fmt,...);
340 void d_msg(char *file, int line, int level, char *fmt,...);
341 void p_msg(char *file, int line, int level, char *fmt,...);
342 void e_msg(char *file, int line, int type, int level, char *fmt,...);
343 void j_msg(char *file, int line, JCR *jcr, int type, int level, char *fmt,...);
344 int m_msg(char *file, int line, char **msgbuf, char *fmt,...);
347 /* Use our strdup with smartalloc */
349 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
352 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
354 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
358 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
367 * On Solaris 2.5, threads are not timesliced by default, so we need to
368 * explictly increase the conncurrency level.
371 #define set_thread_concurrency(x) thr_setconcurrency(x)
372 extern int thr_setconcurrency(int);
378 /* Not needed on most systems */
379 #define set_thread_concurrency(x)
383 #ifdef HAVE_DARWIN_OS
384 /* Apparently someone forgot to wrap getdomainname as a C function */
385 extern "C" int getdomainname(char *name, size_t len);
387 /* Darwin lib fnmatch() doesn't work, so use our own */
392 /* They don't really have it */
393 #undef HAVE_GETDOMAINNAME
399 /* This probably should be done on a machine by machine basic, but it works */
400 #define ALIGN_SIZE (sizeof(double))
401 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
404 /* Added by KES to deal with Win32 systems */
406 #define S_ISWIN32 020000
410 * Replace codes needed in both file routines and non-file routines
411 * Job replace codes -- in "replace"
413 #define REPLACE_ALWAYS 'a'
414 #define REPLACE_IFNEWER 'w'
415 #define REPLACE_NEVER 'n'
416 #define REPLACE_IFOLDER 'o'
418 #endif /* _BACONFIG_H */