]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
Autochanger for read + 64 bit addrs + Session key, see kes14Sep02
[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 #ifndef ETIME
37 #define ETIME ETIMEDOUT
38 #endif
39
40 #ifdef PROTOTYPES
41 # define __PROTO(p)     p
42 #else
43 # define __PROTO(p)     ()
44 #endif
45
46 #ifdef DEBUG
47 #define ASSERT(x) if (!(x)) { \
48    char *jcr = NULL; \
49    Emsg1(M_ERROR, 0, "Failed ASSERT: %s\n", #x); \
50    jcr[0] = 0; }
51 #else
52 #define ASSERT(x)
53 #endif
54
55 /* Allow printing of NULL pointers */
56 #define NPRT(x) (x)?(x):"*None*" 
57
58 #ifdef ENABLE_NLS
59 #include <libintl.h>
60 #define _(s) gettext((s))
61 #define N_(s) (s)
62 #else
63 #define _(s) (s)
64 #define N_(s) (s)
65 #define textdomain(x)
66 #endif
67
68
69 /* This should go away! ****FIXME***** */
70 #define MAXSTRING 500
71
72 /* Maximum length to edit time/date */
73 #define MAX_TIME_LENGTH 30
74
75 /* Maximum Name length including EOS */
76 #define MAX_NAME_LENGTH 128
77
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
82 #endif
83
84 #ifndef DEV_BSIZE
85 #define DEV_BSIZE 512
86 #endif
87
88 /* Maximum number of bytes that you can push into a
89  * socket.
90  */
91 #define MAX_NETWORK_BUFFER_SIZE (32 * 1024)
92
93 /* Stream definitions.  Once defined these must NEVER
94  * change as they go on the storage media
95  */
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
101
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
105  * "smart" systems.
106  */
107 #undef  ISSPACE
108 #undef  ISALPHA
109 #undef  ISUPPER
110 #undef  ISDIGIT
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)))
115
116
117 typedef void (HANDLER)();
118 typedef int (INTHANDLER)();
119
120 #ifdef SETPGRP_VOID
121 # define SETPGRP_ARGS(x, y) /* No arguments */
122 #else
123 # define SETPGRP_ARGS(x, y) (x, y)
124 #endif
125
126 #ifndef S_ISLNK
127 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
128 #endif
129
130 #ifndef INADDR_NONE
131 #define INADDR_NONE ((unsigned long) -1)
132 #endif
133
134 #ifdef TIME_WITH_SYS_TIME
135 # include <sys/time.h>
136 # include <time.h>
137 #else
138 # ifdef HAVE_SYS_TIME_H
139 #  include <sys/time.h>
140 # else
141 #  include <time.h>
142 # endif
143 #endif
144
145 #ifndef O_BINARY
146 #define O_BINARY 0
147 #endif
148
149 #ifndef MODE_RW
150 #define MODE_RW 0666
151 #endif
152
153 #ifdef DEBUG_MUTEX
154 extern void _p(char *file, int line, pthread_mutex_t *m);
155 extern void _v(char *file, int line, pthread_mutex_t *m);
156
157 #define P(x) _p(__FILE__, __LINE__, &(x))
158 #define V(x) _v(__FILE__, __LINE__, &(x))
159
160 #else
161
162 /* These probably should be subroutines */
163 #define P(x) \
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)); \
167    } while(0)
168
169 #define V(x) \
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)); \
173    } while(0)
174
175 #endif /* DEBUG_MUTEX */
176
177 /* These probably should be subroutines */
178 #define Pw(x) \
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)); \
182    } while(0)
183
184 #define Vw(x) \
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)); \
188    } while(0)
189
190
191 /*
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.
195  */
196 /* Debug Messages that are printed */
197 #ifdef DEBUG
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)
212 #else
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)
225 #endif /* DEBUG */
226
227
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)
243
244        
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)
253
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)
262
263
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)
276
277 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
278 int  Mmsg(char **msgbuf, char *fmt,...);
279
280
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,...);
285
286
287 /* Use our strdup with smartalloc */
288 #undef strdup
289 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
290
291 #ifdef DEBUG
292 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
293 #else
294 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
295 #endif
296
297 #ifdef DEBUG
298 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
299 #endif
300
301 #ifdef __alpha__
302 #define OSF 1
303 #endif
304
305 #ifdef HAVE_SUN_OS
306    /* 
307     * On Solaris 2.5, threads are not timesliced by default, so we need to
308     * explictly increase the conncurrency level.
309     */
310 #include <thread.h>
311 #define set_thread_concurrency(x)  thr_setconcurrency(x)
312 extern int thr_setconcurrency(int);
313 #define SunOS 1
314
315 #else
316
317 /* Not needed on most systems */
318 #define set_thread_concurrency(x)
319
320 #endif
321
322 #ifdef HAVE_IRIX_OS
323 #define socklen_t int
324 #endif
325
326 #ifdef HAVE_CYGWIN
327 /* They don't really have it */
328 #undef HAVE_GETDOMAINNAME
329 #endif
330  
331
332 #define ALIGN_SIZE (sizeof(double))
333 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
334
335 #endif /* _BACONFIG_H */