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 /* All tape operations MUST be a multiple of this */
79 #define TAPE_BSIZE 1024
80 #if !defined(DEV_BSIZE) && defined(BSIZE)
81 #define DEV_BSIZE BSIZE
88 /* Maximum number of bytes that you can push into a
91 #define MAX_NETWORK_BUFFER_SIZE (32 * 1024)
93 /* Stream definitions. Once defined these must NEVER
94 * change as they go on the storage media.
96 #define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */
97 #define STREAM_FILE_DATA 2 /* Standard uncompressed data */
98 #define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */
99 #define STREAM_GZIP_DATA 4 /* GZip compressed file data */
100 #define STREAM_WIN32_ATTRIBUTES 5 /* Windows attributes (superset of Unix) */
101 #define STREAM_SPARSE_DATA 6 /* Sparse data stream */
102 #define STREAM_SPARSE_GZIP_DATA 7
103 #define STREAM_PROGRAM_NAMES 8 /* program names for program data */
104 #define STREAM_PROGRAM_DATA 9 /* Data needing program */
106 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
107 #define SPARSE_FADDR_SIZE (sizeof(uint64_t))
110 /* This is for dumb compilers/libraries like Solaris. Linux GCC
111 * does it correctly, so it might be worthwhile
112 * to remove the isascii(c) with ifdefs on such
115 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
116 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
117 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
118 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
121 typedef void (HANDLER)();
122 typedef int (INTHANDLER)();
125 # define SETPGRP_ARGS(x, y) /* No arguments */
127 # define SETPGRP_ARGS(x, y) (x, y)
131 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
134 /* Added by KES to deal with Win32 systems */
136 #define S_ISWIN32 020000
140 #define INADDR_NONE ((unsigned long) -1)
143 #ifdef TIME_WITH_SYS_TIME
144 # include <sys/time.h>
147 # ifdef HAVE_SYS_TIME_H
148 # include <sys/time.h>
163 extern void _p(char *file, int line, pthread_mutex_t *m);
164 extern void _v(char *file, int line, pthread_mutex_t *m);
166 #define P(x) _p(__FILE__, __LINE__, &(x))
167 #define V(x) _v(__FILE__, __LINE__, &(x))
171 /* These probably should be subroutines */
173 do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
174 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
175 strerror(errstat)); \
179 do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
180 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
181 strerror(errstat)); \
184 #endif /* DEBUG_MUTEX */
186 /* These probably should be subroutines */
188 do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
189 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
190 strerror(errstat)); \
194 do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
195 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
196 strerror(errstat)); \
201 * The digit following Dmsg and Emsg indicates the number of substitutions in
202 * the message string. We need to do this kludge because non-GNU compilers
203 * do not handle varargs #defines.
205 /* Debug Messages that are printed */
207 #define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg)
208 #define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1)
209 #define Dmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
210 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
211 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
212 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
213 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
214 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
215 #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)
216 #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)
217 #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)
218 #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)
219 #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)
220 #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)
222 #define Dmsg0(lvl, msg)
223 #define Dmsg1(lvl, msg, a1)
224 #define Dmsg2(lvl, msg, a1, a2)
225 #define Dmsg3(lvl, msg, a1, a2, a3)
226 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
227 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
228 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
229 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
230 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
231 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
232 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
233 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
237 /* Messages that are printed (uses d_msg) */
238 #define Pmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg)
239 #define Pmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1)
240 #define Pmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
241 #define Pmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
242 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
243 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
244 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
245 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
246 #define Pmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
247 #define Pmsg9(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)
248 #define Pmsg10(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)
249 #define Pmsg11(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)
250 #define Pmsg12(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)
251 #define Pmsg13(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)
252 #define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
255 /* Daemon Error Messages that are delivered according to the message resource */
256 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
257 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
258 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
259 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
260 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
261 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
262 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
264 /* Job Error Messages that are delivered according to the message resource */
265 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
266 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
267 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
268 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
269 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
270 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
271 #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)
274 /* Memory Messages that are edited into a Pool Memory buffer */
275 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
276 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
277 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
278 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
279 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
280 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
281 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
282 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
283 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
284 #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)
285 #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)
287 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
288 int Mmsg(char **msgbuf, char *fmt,...);
291 void d_msg(char *file, int line, int level, char *fmt,...);
292 void e_msg(char *file, int line, int type, int level, char *fmt,...);
293 void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
294 int m_msg(char *file, int line, char **msgbuf, char *fmt,...);
297 /* Use our strdup with smartalloc */
299 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
302 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
304 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
308 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
317 * On Solaris 2.5, threads are not timesliced by default, so we need to
318 * explictly increase the conncurrency level.
321 #define set_thread_concurrency(x) thr_setconcurrency(x)
322 extern int thr_setconcurrency(int);
327 /* Not needed on most systems */
328 #define set_thread_concurrency(x)
333 #define socklen_t int
337 /* They don't really have it */
338 #undef HAVE_GETDOMAINNAME
342 #define ALIGN_SIZE (sizeof(double))
343 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
346 /* Added by KES to deal with Win32 systems */
348 #define S_ISWIN32 020000
351 /* Replace codes needed in both file routines and non-file routines */
352 /* Job replace codes -- in "replace" */
353 #define REPLACE_ALWAYS 'a'
354 #define REPLACE_IFNEWER 'w'
355 #define REPLACE_NEVER 'n'
356 #define REPLACE_IFOLDER 'o'
360 #endif /* _BACONFIG_H */