]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
37164ff39c20bc3183ba13644c1a426753d98d34
[bacula/bacula] / bacula / src / baconfig.h
1 /*
2  * General header file configurations that apply to
3  * all daemons.  System dependent stuff goes here.
4  *
5  *   Version $Id$
6  */
7 /*
8    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
9
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.
14
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.
19
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,
23    MA 02111-1307, USA.
24
25  */
26
27
28 #ifndef _BACONFIG_H
29 #define _BACONFIG_H 1
30
31 /* Bacula common configuration defines */
32
33 #define TRUE  1
34 #define FALSE 0
35
36 #ifdef PROTOTYPES
37 # define __PROTO(p)     p
38 #else
39 # define __PROTO(p)     ()
40 #endif
41
42 #ifdef DEBUG
43 #define ASSERT(x) if (!(x)) { \
44    char *jcr = NULL; \
45    Emsg1(M_ERROR, 0, "Failed ASSERT: %s\n", #x); \
46    jcr[0] = 0; }
47 #else
48 #define ASSERT(x)
49 #endif
50
51 /* Allow printing of NULL pointers */
52 #define NPRT(x) (x)?(x):"*None*" 
53
54 #ifdef ENABLE_NLS
55 #include <libintl.h>
56 #define _(s) gettext((s))
57 #define N_(s) (s)
58 #else
59 #define _(s) (s)
60 #define N_(s) (s)
61 #define textdomain(x)
62 #endif
63
64
65 /* This should go away! ****FIXME***** */
66 #define MAXSTRING 500
67
68 /* Maximum length to edit time/date */
69 #define MAX_TIME_LENGTH 30
70
71 /* Maximum Name length including EOS */
72 #define MAX_NAME_LENGTH 128
73
74 /* All tape operations MUST be a multiple of this */
75 #define TAPE_BSIZE 1024
76 #if !defined(DEV_BSIZE) && defined(BSIZE)
77 #define DEV_BSIZE BSIZE
78 #endif
79
80 #ifndef DEV_BSIZE
81 #define DEV_BSIZE 512
82 #endif
83
84 /* Maximum number of bytes that you can push into a
85  * socket.
86  */
87 #define MAX_NETWORK_BUFFER_SIZE (32 * 1024)
88
89 /* Stream definitions.  Once defined these must NEVER
90  * change as they go on the storage media
91  */
92 #define STREAM_UNIX_ATTRIBUTES  1     /* Generic Unix attributes */
93 #define STREAM_FILE_DATA        2     /* Standard uncompressed data */
94 #define STREAM_MD5_SIGNATURE    3     /* MD5 signature for the file */
95 #define STREAM_GZIP_DATA        4     /* GZip compressed file data */
96
97
98 /* This is for dumb compilers like Solaris. Linux GCC
99  * does it correctly, so it might be worthwhile
100  * to remove the isascii(c) with ifdefs on such
101  * "smart" systems.
102  */
103 #undef  ISSPACE
104 #undef  ISALPHA
105 #undef  ISUPPER
106 #undef  ISDIGIT
107 #define ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
108 #define ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
109 #define ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
110 #define ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
111
112
113 typedef void (HANDLER)();
114 typedef int (INTHANDLER)();
115
116 #ifdef SETPGRP_VOID
117 # define SETPGRP_ARGS(x, y) /* No arguments */
118 #else
119 # define SETPGRP_ARGS(x, y) (x, y)
120 #endif
121
122 #ifndef S_ISLNK
123 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
124 #endif
125
126 #ifndef INADDR_NONE
127 #define INADDR_NONE ((unsigned long) -1)
128 #endif
129
130 #ifdef TIME_WITH_SYS_TIME
131 # include <sys/time.h>
132 # include <time.h>
133 #else
134 # ifdef HAVE_SYS_TIME_H
135 #  include <sys/time.h>
136 # else
137 #  include <time.h>
138 # endif
139 #endif
140
141 #ifndef O_BINARY
142 #define O_BINARY 0
143 #endif
144
145 #ifndef MODE_RW
146 #define MODE_RW 0666
147 #endif
148
149 #ifdef DEBUG_MUTEX
150 extern void _p(char *file, int line, pthread_mutex_t *m);
151 extern void _v(char *file, int line, pthread_mutex_t *m);
152
153 #define P(x) _p(__FILE__, __LINE__, &(x))
154 #define V(x) _v(__FILE__, __LINE__, &(x))
155
156 #else
157
158 /* These probably should be subroutines */
159 #define P(x) \
160    do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
161       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
162            strerror(errstat)); \
163    } while(0)
164
165 #define V(x) \
166    do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
167          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
168            strerror(errstat)); \
169    } while(0)
170
171 #endif /* DEBUG_MUTEX */
172
173 /* These probably should be subroutines */
174 #define Pw(x) \
175    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
176       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
177            strerror(errstat)); \
178    } while(0)
179
180 #define Vw(x) \
181    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
182          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
183            strerror(errstat)); \
184    } while(0)
185
186
187 /*
188  * The digit following Dmsg and Emsg indicates the number of substitutions in
189  * the message string. We need to do this kludge because non-GNU compilers
190  * do not handle varargs #defines.
191  */
192 /* Debug Messages that are printed */
193 #ifdef DEBUG
194 #define Dmsg0(lvl, msg)             d_msg(__FILE__, __LINE__, lvl, msg)
195 #define Dmsg1(lvl, msg, a1)         d_msg(__FILE__, __LINE__, lvl, msg, a1)
196 #define Dmsg2(lvl, msg, a1, a2)     d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
197 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
198 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
199 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
200 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
201 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
202 #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)
203 #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)
204 #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)
205 #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)
206 #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)
207 #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)
208 #else
209 #define Dmsg0(lvl, msg)
210 #define Dmsg1(lvl, msg, a1)
211 #define Dmsg2(lvl, msg, a1, a2)
212 #define Dmsg3(lvl, msg, a1, a2, a3)
213 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
214 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
215 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
216 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
217 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
218 #define Dmsg11(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)
220 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
221 #endif /* DEBUG */
222
223
224 /* Messages that are printed (uses d_msg) */
225 #define Pmsg0(lvl, msg)             d_msg(__FILE__, __LINE__, lvl, msg)
226 #define Pmsg1(lvl, msg, a1)         d_msg(__FILE__, __LINE__, lvl, msg, a1)
227 #define Pmsg2(lvl, msg, a1, a2)     d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
228 #define Pmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
229 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
230 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
231 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
232 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
233 #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)
234 #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)
235 #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)
236 #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)
237 #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)
238 #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)
239
240        
241 /* Daemon Error Messages that are delivered according to the message resource */
242 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
243 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
244 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
245 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
246 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
247 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
248 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
249
250 /* Job Error Messages that are delivered according to the message resource */
251 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
252 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
253 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
254 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
255 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
256 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
257 #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)
258
259
260 /* Memory Messages that are edited into a Pool Memory buffer */
261 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
262 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
263 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
264 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
265 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
266 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
267 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
268 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
269 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
270 #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)
271 #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)
272
273 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
274 int  Mmsg(char **msgbuf, char *fmt,...);
275
276
277 void d_msg(char *file, int line, int level, char *fmt,...);
278 void e_msg(char *file, int line, int type, int level, char *fmt,...);
279 void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
280 int  m_msg(char *file, int line, char **msgbuf, char *fmt,...);
281
282
283 /* Use our strdup with smartalloc */
284 #undef strdup
285 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
286
287 #ifdef DEBUG
288 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
289 #else
290 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
291 #endif
292
293 #ifdef DEBUG
294 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
295 #endif
296
297 #ifdef __alpha__
298 #define OSF 1
299 #endif
300
301 #ifdef HAVE_SUN_OS
302    /* 
303     * On Solaris 2.5, threads are not timesliced by default, so we need to
304     * explictly increase the conncurrency level.
305     */
306 #include <thread.h>
307 #define set_thread_concurrency(x)  thr_setconcurrency(x)
308 extern int thr_setconcurrency(int);
309 #define SunOS 1
310
311 #else
312
313 /* Not needed on most systems */
314 #define set_thread_concurrency(x)
315
316 #endif
317
318 #ifdef HAVE_IRIX_OS
319 #define socklen_t int
320 #endif
321
322 #define ALIGN_SIZE (sizeof(double))
323 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
324
325 #endif /* _BACONFIG_H */