]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
fe8f4395cefad44ef5a6f7ff8bd8d9b035849171
[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 /*
174  * The digit following Dmsg and Emsg indicates the number of substitutions in
175  * the message string. We need to do this kludge because non-GNU compilers
176  * do not handle varargs #defines.
177  */
178 /* Debug Messages that are printed */
179 #ifdef DEBUG
180 #define Dmsg0(lvl, msg)             d_msg(__FILE__, __LINE__, lvl, msg)
181 #define Dmsg1(lvl, msg, a1)         d_msg(__FILE__, __LINE__, lvl, msg, a1)
182 #define Dmsg2(lvl, msg, a1, a2)     d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
183 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
184 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
185 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
186 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
187 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
188 #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)
189 #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)
190 #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)
191 #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)
192 #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)
193 #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)
194 #else
195 #define Dmsg0(lvl, msg)
196 #define Dmsg1(lvl, msg, a1)
197 #define Dmsg2(lvl, msg, a1, a2)
198 #define Dmsg3(lvl, msg, a1, a2, a3)
199 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
200 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
201 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
202 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
203 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
204 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
205 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
206 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
207 #endif /* DEBUG */
208
209
210 /* Messages that are printed (uses d_msg) */
211 #define Pmsg0(lvl, msg)             d_msg(__FILE__, __LINE__, lvl, msg)
212 #define Pmsg1(lvl, msg, a1)         d_msg(__FILE__, __LINE__, lvl, msg, a1)
213 #define Pmsg2(lvl, msg, a1, a2)     d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
214 #define Pmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
215 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
216 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
217 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
218 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
219 #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)
220 #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)
221 #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)
222 #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)
223 #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)
224 #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)
225
226        
227 /* Daemon Error Messages that are delivered according to the message resource */
228 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
229 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
230 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
231 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
232 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
233 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
234 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
235
236 /* Job Error Messages that are delivered according to the message resource */
237 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
238 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
239 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
240 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
241 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
242 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
243 #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)
244
245
246 /* Memory Messages that are edited into a Pool Memory buffer */
247 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
248 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
249 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
250 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
251 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
252 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
253 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
254 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
255 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
256 #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)
257 #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)
258
259 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
260 int  Mmsg(char **msgbuf, char *fmt,...);
261
262
263 void d_msg(char *file, int line, int level, char *fmt,...);
264 void e_msg(char *file, int line, int type, int level, char *fmt,...);
265 void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
266 int  m_msg(char *file, int line, char **msgbuf, char *fmt,...);
267
268
269 /* Use our strdup with smartalloc */
270 #undef strdup
271 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
272
273 #ifdef DEBUG
274 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
275 #else
276 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
277 #endif
278
279 #ifdef DEBUG
280 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
281 #endif
282
283 #ifdef __alpha__
284 #define OSF 1
285 #endif
286
287 #ifdef HAVE_SUN_OS
288    /* 
289     * On Solaris 2.5, threads are not timesliced by default, so we need to
290     * explictly increase the conncurrency level.
291     */
292 #include <thread.h>
293 #define set_thread_concurrency(x)  thr_setconcurrency(x)
294 extern int thr_setconcurrency(int);
295 #define SunOS 1
296
297 #else
298
299 /* Not needed on most systems */
300 #define set_thread_concurrency(x)
301
302 #endif
303
304 #ifdef HAVE_IRIX_OS
305 #define socklen_t int
306 #endif
307
308 #define ALIGN_SIZE (sizeof(double))
309 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
310
311 #endif /* _BACONFIG_H */