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 */
102 /* This is for dumb compilers like Solaris. Linux GCC
103 * does it correctly, so it might be worthwhile
104 * to remove the isascii(c) with ifdefs on such
111 #define ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
112 #define ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
113 #define ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
114 #define ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
117 typedef void (HANDLER)();
118 typedef int (INTHANDLER)();
121 # define SETPGRP_ARGS(x, y) /* No arguments */
123 # define SETPGRP_ARGS(x, y) (x, y)
127 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
131 #define INADDR_NONE ((unsigned long) -1)
134 #ifdef TIME_WITH_SYS_TIME
135 # include <sys/time.h>
138 # ifdef HAVE_SYS_TIME_H
139 # include <sys/time.h>
154 extern void _p(char *file, int line, pthread_mutex_t *m);
155 extern void _v(char *file, int line, pthread_mutex_t *m);
157 #define P(x) _p(__FILE__, __LINE__, &(x))
158 #define V(x) _v(__FILE__, __LINE__, &(x))
162 /* These probably should be subroutines */
164 do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
165 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
166 strerror(errstat)); \
170 do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
171 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
172 strerror(errstat)); \
175 #endif /* DEBUG_MUTEX */
177 /* These probably should be subroutines */
179 do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
180 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
181 strerror(errstat)); \
185 do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
186 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
187 strerror(errstat)); \
192 * The digit following Dmsg and Emsg indicates the number of substitutions in
193 * the message string. We need to do this kludge because non-GNU compilers
194 * do not handle varargs #defines.
196 /* Debug Messages that are printed */
198 #define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg)
199 #define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1)
200 #define Dmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
201 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
202 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
203 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
204 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
205 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
206 #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)
207 #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)
208 #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)
209 #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)
210 #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)
211 #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)
213 #define Dmsg0(lvl, msg)
214 #define Dmsg1(lvl, msg, a1)
215 #define Dmsg2(lvl, msg, a1, a2)
216 #define Dmsg3(lvl, msg, a1, a2, a3)
217 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
218 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
219 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
220 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
221 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
222 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
223 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
224 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
228 /* Messages that are printed (uses d_msg) */
229 #define Pmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg)
230 #define Pmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1)
231 #define Pmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
232 #define Pmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
233 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
234 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
235 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
236 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
237 #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)
238 #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)
239 #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)
240 #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)
241 #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)
242 #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)
245 /* Daemon Error Messages that are delivered according to the message resource */
246 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
247 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
248 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
249 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
250 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
251 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
252 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
254 /* Job Error Messages that are delivered according to the message resource */
255 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
256 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
257 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
258 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
259 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
260 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
261 #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)
264 /* Memory Messages that are edited into a Pool Memory buffer */
265 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
266 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
267 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
268 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
269 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
270 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
271 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
272 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
273 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
274 #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)
275 #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)
277 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
278 int Mmsg(char **msgbuf, char *fmt,...);
281 void d_msg(char *file, int line, int level, char *fmt,...);
282 void e_msg(char *file, int line, int type, int level, char *fmt,...);
283 void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
284 int m_msg(char *file, int line, char **msgbuf, char *fmt,...);
287 /* Use our strdup with smartalloc */
289 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
292 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
294 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
298 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
307 * On Solaris 2.5, threads are not timesliced by default, so we need to
308 * explictly increase the conncurrency level.
311 #define set_thread_concurrency(x) thr_setconcurrency(x)
312 extern int thr_setconcurrency(int);
317 /* Not needed on most systems */
318 #define set_thread_concurrency(x)
323 #define socklen_t int
326 #define ALIGN_SIZE (sizeof(double))
327 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
329 #endif /* _BACONFIG_H */