]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
17Mar06
[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-2006 Kern Sibbald
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
12    version 2 as amended with additional clauses defined in the
13    file LICENSE in the main source directory.
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 
18    the file LICENSE for additional details.
19
20  */
21
22
23 #ifndef _BACONFIG_H
24 #define _BACONFIG_H 1
25
26 /* Bacula common configuration defines */
27
28 #undef  TRUE
29 #undef  FALSE
30 #define TRUE  1
31 #define FALSE 0
32
33 #ifndef MAX
34 #define MAX(a, b) ((a) > (b) ? (a) : (b))
35 #endif
36 #ifndef MIN
37 #define MIN(a, b) ((a) < (b) ? (a) : (b))
38 #endif
39
40 #ifdef HAVE_TLS
41 #define have_tls 1
42 #else
43 #define have_tls 0
44 #endif
45
46 #ifndef ETIME
47 #define ETIME ETIMEDOUT
48 #endif
49
50 #ifdef PROTOTYPES
51 # define __PROTO(p)     p
52 #else
53 # define __PROTO(p)     ()
54 #endif
55
56 #ifdef DEBUG
57 #define ASSERT(x) if (!(x)) { \
58    char *jcr = NULL; \
59    Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
60    jcr[0] = 0; }
61 #else
62 #define ASSERT(x)
63 #endif
64
65 /* Allow printing of NULL pointers */
66 #define NPRT(x) (x)?(x):_("*None*")
67  
68 #ifdef WIN32
69 #undef ENABLE_NLS
70 #endif
71
72 #ifdef ENABLE_NLS
73    #include <libintl.h>
74    #include <locale.h>
75    #ifndef _
76       #define _(s) gettext((s))
77    #endif /* _ */
78    #ifndef N_
79       #define N_(s) (s)
80    #endif /* N_ */
81 #else /* !ENABLE_NLS */
82    #ifndef _
83       #define _(s) (s)
84    #endif
85    #ifndef N_
86       #define N_(s) (s)
87    #endif
88    #ifndef textdomain
89       #define textdomain(d)
90    #endif
91    #ifndef bindtextdomain
92       #define bindtextdomain(p, d)
93    #endif
94    #ifndef setlocale
95       #define setlocale(p, d)
96    #endif
97 #endif /* ENABLE_NLS */
98
99 /* This should go away! ****FIXME***** */
100 #define MAXSTRING 500
101
102 /* Maximum length to edit time/date */
103 #define MAX_TIME_LENGTH 50
104
105 /* Maximum Name length including EOS */
106 #define MAX_NAME_LENGTH 128
107
108 /* Maximume number of user entered command args */
109 #define MAX_CMD_ARGS 30
110
111 /* All tape operations MUST be a multiple of this */
112 #define TAPE_BSIZE 1024
113
114 #ifdef DEV_BSIZE 
115 #define B_DEV_BSIZE DEV_BSIZE
116 #endif
117
118 #if !defined(B_DEV_BSIZE) & defined(BSIZE)
119 #define B_DEV_BSIZE BSIZE
120 #endif
121
122 #ifndef B_DEV_BSIZE
123 #define B_DEV_BSIZE 512
124 #endif
125
126 /*
127  * Set to time limit for other end to respond to
128  *  authentication.  Normally 10 minutes is *way*
129  *  more than enough. The idea is to keep the Director
130  *  from hanging because there is a dead connection on
131  *  the other end.
132  */
133 #define AUTH_TIMEOUT 60 * 10
134
135 /*
136  * Default network buffer size
137  */
138 #define DEFAULT_NETWORK_BUFFER_SIZE (64 * 1024)
139
140 /*
141  * Stream definitions.  Once defined these must NEVER
142  *   change as they go on the storage media.
143  * Note, the following streams are passed from the SD to the DIR
144  *   so that they may be put into the catalog (actually only the
145  *   stat packet part of the attr record is put in the catalog.
146  *
147  *   STREAM_UNIX_ATTRIBUTES
148  *   STREAM_UNIX_ATTRIBUTES_EX
149  *   STREAM_MD5_DIGEST
150  *   STREAM_SHA1_DIGEST
151  *   STREAM_SHA256_DIGEST
152  *   STREAM_SHA512_DIGEST
153  */
154 #define STREAM_NONE               0    /* Reserved Non-Stream */
155 #define STREAM_UNIX_ATTRIBUTES    1    /* Generic Unix attributes */
156 #define STREAM_FILE_DATA          2    /* Standard uncompressed data */
157 #define STREAM_MD5_SIGNATURE      3    /* deprecated */
158 #define STREAM_MD5_DIGEST         3    /* MD5 digest for the file */
159 #define STREAM_GZIP_DATA          4    /* GZip compressed file data */
160 /* Extended Unix attributes with Win32 Extended data.  Deprecated. */
161 #define STREAM_UNIX_ATTRIBUTES_EX 5    /* Extended Unix attr for Win32 EX */
162 #define STREAM_SPARSE_DATA        6    /* Sparse data stream */
163 #define STREAM_SPARSE_GZIP_DATA   7
164 #define STREAM_PROGRAM_NAMES      8    /* program names for program data */
165 #define STREAM_PROGRAM_DATA       9    /* Data needing program */
166 #define STREAM_SHA1_SIGNATURE    10    /* deprecated */
167 #define STREAM_SHA1_DIGEST       10    /* SHA1 digest for the file */
168 #define STREAM_WIN32_DATA        11    /* Win32 BackupRead data */
169 #define STREAM_WIN32_GZIP_DATA   12    /* Gzipped Win32 BackupRead data */
170 #define STREAM_MACOS_FORK_DATA   13    /* Mac resource fork */
171 #define STREAM_HFSPLUS_ATTRIBUTES 14   /* Mac OS extra attributes */
172 /*** FIXME ***/
173 #define STREAM_UNIX_ATTRIBUTES_ACCESS_ACL 15 /* Standard ACL attributes on UNIX */
174 #define STREAM_UNIX_ATTRIBUTES_DEFAULT_ACL 16 /* Default ACL attributes on UNIX */
175 /*** FIXME ***/
176 #define STREAM_SHA256_DIGEST              17   /* SHA-256 digest for the file */
177 #define STREAM_SHA512_DIGEST              18   /* SHA-512 digest for the file */
178 #define STREAM_SIGNED_DIGEST              19   /* Signed File Digest, ASN.1, DER Encoded */
179 #define STREAM_ENCRYPTED_FILE_DATA        20   /* Encrypted, uncompressed data */
180 #define STREAM_ENCRYPTED_WIN32_DATA       21   /* Encrypted, uncompressed Win32 BackupRead data */
181 #define STREAM_ENCRYPTED_SESSION_DATA     22   /* Encrypted Session Data, ASN.1, DER Encoded */
182 #define STREAM_ENCRYPTED_FILE_GZIP_DATA   23   /* Encrypted, compressed data */
183 #define STREAM_ENCRYPTED_WIN32_GZIP_DATA  24   /* Encrypted, compressed Win32 BackupRead data */
184 #define STREAM_ENCRYPTED_MACOS_FORK_DATA  25   /* Encrypted, uncompressed Mac resource fork */
185
186
187 /*
188  *  File type (Bacula defined).
189  *  NOTE!!! These are saved in the Attributes record on the tape, so
190  *          do not change them. If need be, add to them.
191  *
192  *  This is stored as 32 bits on tape, but only FT_MASK bits are
193  *    used for the file type. The upper bits are used to indicate
194  *    additional optional fields in the attribute record.
195  */
196 #define FT_MASK       0xFFFF          /* Bits used by FT (type) */
197 #define FT_LNKSAVED   1               /* hard link to file already saved */
198 #define FT_REGE       2               /* Regular file but empty */
199 #define FT_REG        3               /* Regular file */
200 #define FT_LNK        4               /* Soft Link */
201 #define FT_DIREND     5               /* Directory at end (saved) */
202 #define FT_SPEC       6               /* Special file -- chr, blk, fifo, sock */
203 #define FT_NOACCESS   7               /* Not able to access */
204 #define FT_NOFOLLOW   8               /* Could not follow link */
205 #define FT_NOSTAT     9               /* Could not stat file */
206 #define FT_NOCHG     10               /* Incremental option, file not changed */
207 #define FT_DIRNOCHG  11               /* Incremental option, directory not changed */
208 #define FT_ISARCH    12               /* Trying to save archive file */
209 #define FT_NORECURSE 13               /* No recursion into directory */
210 #define FT_NOFSCHG   14               /* Different file system, prohibited */
211 #define FT_NOOPEN    15               /* Could not open directory */
212 #define FT_RAW       16               /* Raw block device */
213 #define FT_FIFO      17               /* Raw fifo device */
214 /* This directory packet is sent to the FD file processing routine so
215  * that it can filter packets, but otherwise, it is not used
216  * or saved */
217 #define FT_DIRBEGIN  18               /* Directory at beginning (not saved) */
218 #define FT_INVALIDFS 19               /* File system not allowed for */
219
220 /* Definitions for upper part of type word (see above). */
221 #define AR_DATA_STREAM (1<<16)        /* Data stream id present */
222
223 /*
224  * Tape label types -- stored in catalog
225  */
226 #define B_BACULA_LABEL 0
227 #define B_ANSI_LABEL   1
228 #define B_IBM_LABEL    2
229
230 /* Size of File Address stored in STREAM_SPARSE_DATA. Do NOT change! */
231 #define SPARSE_FADDR_SIZE (sizeof(uint64_t))
232
233
234 /* This is for dumb compilers/libraries like Solaris. Linux GCC
235  * does it correctly, so it might be worthwhile
236  * to remove the isascii(c) with ifdefs on such
237  * "smart" systems.
238  */
239 #define B_ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
240 #define B_ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
241 #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
242 #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
243
244 /* For multiplying by 10 with shift and addition */
245 #define B_TIMES10(d) ((d<<3)+(d<<1))
246
247
248 typedef void (HANDLER)();
249 typedef int (INTHANDLER)();
250
251 #ifdef SETPGRP_VOID
252 # define SETPGRP_ARGS(x, y) /* No arguments */
253 #else
254 # define SETPGRP_ARGS(x, y) (x, y)
255 #endif
256
257 #ifndef S_ISLNK
258 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
259 #endif
260
261 /* Added by KES to deal with Win32 systems */
262 #ifndef S_ISWIN32
263 #define S_ISWIN32 020000
264 #endif
265
266 #ifndef INADDR_NONE
267 #define INADDR_NONE ((unsigned long) -1)
268 #endif
269
270 #ifdef TIME_WITH_SYS_TIME
271 # include <sys/time.h>
272 # include <time.h>
273 #else
274 # ifdef HAVE_SYS_TIME_H
275 #  include <sys/time.h>
276 # else
277 #  include <time.h>
278 # endif
279 #endif
280
281 #ifndef O_BINARY
282 #define O_BINARY 0
283 #endif
284
285 #ifndef O_NOFOLLOW
286 #define O_NOFOLLOW 0
287 #endif
288
289 #ifndef MODE_RW
290 #define MODE_RW 0666
291 #endif
292
293 #ifdef DEBUG_MUTEX
294 extern void _p(char *file, int line, pthread_mutex_t *m);
295 extern void _v(char *file, int line, pthread_mutex_t *m);
296
297 #define P(x) _p(__FILE__, __LINE__, &(x))
298 #define V(x) _v(__FILE__, __LINE__, &(x))
299
300 #else
301 extern void _p(pthread_mutex_t *m);
302 extern void _v(pthread_mutex_t *m);
303
304 #define P(x) _p(&(x))
305 #define V(x) _v(&(x))
306
307 #endif /* DEBUG_MUTEX */
308
309 /* These probably should be subroutines */
310 #define Pw(x) \
311    do { int errstat; if ((errstat=rwl_writelock(&(x)))) \
312       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\
313            strerror(errstat)); \
314    } while(0)
315
316 #define Vw(x) \
317    do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \
318          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\
319            strerror(errstat)); \
320    } while(0)
321
322 #define LockRes()   b_LockRes(__FILE__, __LINE__)
323 #define UnlockRes() b_UnlockRes(__FILE__, __LINE__)
324
325 #ifdef DEBUG_MEMSET
326 #define memset(a, v, n) b_memset(__FILE__, __LINE__, a, v, n)
327 void b_memset(const char *file, int line, void *mem, int val, size_t num);
328 #endif
329
330
331 /*
332  * The digit following Dmsg and Emsg indicates the number of substitutions in
333  * the message string. We need to do this kludge because non-GNU compilers
334  * do not handle varargs #defines.
335  */
336 /* Debug Messages that are printed */
337 #ifdef DEBUG
338 #define Dmsg0(lvl, msg)             if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg)
339 #define Dmsg1(lvl, msg, a1)         if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1)
340 #define Dmsg2(lvl, msg, a1, a2)     if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
341 #define Dmsg3(lvl, msg, a1, a2, a3) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
342 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
343 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
344 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
345 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
346 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) if ((lvl)<=debug_level) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
347 #define Dmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
348 #define Dmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
349 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
350 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
351 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) if ((lvl)<=debug_level) d_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
352 #else
353 #define Dmsg0(lvl, msg)
354 #define Dmsg1(lvl, msg, a1)
355 #define Dmsg2(lvl, msg, a1, a2)
356 #define Dmsg3(lvl, msg, a1, a2, a3)
357 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
358 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
359 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
360 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
361 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
362 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
363 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
364 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
365 #endif /* DEBUG */
366
367 #ifdef TRACE_FILE
368 #define Tmsg0(lvl, msg)             t_msg(__FILE__, __LINE__, lvl, msg)
369 #define Tmsg1(lvl, msg, a1)         t_msg(__FILE__, __LINE__, lvl, msg, a1)
370 #define Tmsg2(lvl, msg, a1, a2)     t_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
371 #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
372 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
373 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
374 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
375 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
376 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
377 #define Tmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
378 #define Tmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
379 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
380 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
381 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) t_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
382 #else
383 #define Tmsg0(lvl, msg)
384 #define Tmsg1(lvl, msg, a1)
385 #define Tmsg2(lvl, msg, a1, a2)
386 #define Tmsg3(lvl, msg, a1, a2, a3)
387 #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4)
388 #define Tmsg5(lvl, msg, a1, a2, a3, a4, a5)
389 #define Tmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
390 #define Tmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
391 #define Tmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
392 #define Tmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
393 #define Tmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
394 #define Tmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
395 #endif /* TRACE_FILE */
396
397
398
399 /* Messages that are printed (uses d_msg) */
400 #define Pmsg0(lvl, msg)             p_msg(__FILE__, __LINE__, lvl, msg)
401 #define Pmsg1(lvl, msg, a1)         p_msg(__FILE__, __LINE__, lvl, msg, a1)
402 #define Pmsg2(lvl, msg, a1, a2)     p_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
403 #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
404 #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
405 #define Pmsg5(lvl, msg, a1, a2, a3, a4, a5) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
406 #define Pmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
407 #define Pmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
408 #define Pmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
409 #define Pmsg9(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9)
410 #define Pmsg10(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
411 #define Pmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
412 #define Pmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
413 #define Pmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
414 #define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
415
416
417 /* Daemon Error Messages that are delivered according to the message resource */
418 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
419 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
420 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
421 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
422 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
423 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
424 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
425
426 /* Job Error Messages that are delivered according to the message resource */
427 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
428 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
429 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
430 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
431 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
432 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
433 #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)
434
435 /* Queued Job Error Messages that are delivered according to the message resource */
436 #define Qmsg0(jcr, typ, lvl, msg)             q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
437 #define Qmsg1(jcr, typ, lvl, msg, a1)         q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
438 #define Qmsg2(jcr, typ, lvl, msg, a1, a2)     q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
439 #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
440 #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
441 #define Qmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
442 #define Qmsg6(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
443
444
445 /* Memory Messages that are edited into a Pool Memory buffer */
446 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
447 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
448 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
449 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
450 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
451 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
452 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
453 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
454 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
455 #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)
456 #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)
457
458 class POOL_MEM;
459 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
460 int  Mmsg(POOLMEM **msgbuf, const char *fmt,...);
461 int  Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
462 int  Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
463
464
465 class JCR;
466 void d_msg(const char *file, int line, int level, const char *fmt,...);
467 void p_msg(const char *file, int line, int level, const char *fmt,...);
468 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
469 void j_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
470 void q_msg(const char *file, int line, JCR *jcr, int type, time_t mtime, const char *fmt,...);
471 int  m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...);
472 int  m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...);
473
474
475 /* Use our strdup with smartalloc */
476 #ifndef __WXGTK__
477 #undef strdup
478 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
479 #endif
480
481 /* Use our fgets which handles interrupts */
482 #undef fgets
483 #define fgets(x,y,z) bfgets((x), (y), (z))
484
485 /* Use our sscanf, which is safer and works with known sizes */
486 #define sscanf bsscanf
487
488 #ifdef DEBUG
489 #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
490 #else
491 #define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str))
492 #endif
493
494 #ifdef DEBUG
495 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
496 #endif
497
498 /*
499  * Replace codes needed in both file routines and non-file routines
500  * Job replace codes -- in "replace"
501  */
502 #define REPLACE_ALWAYS   'a'
503 #define REPLACE_IFNEWER  'w'
504 #define REPLACE_NEVER    'n'
505 #define REPLACE_IFOLDER  'o'
506
507 /* This probably should be done on a machine by machine basic, but it works */
508 /* This is critical for the smartalloc routines to properly align memory */
509 #define ALIGN_SIZE (sizeof(double))
510 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
511
512
513 /* =============================================================
514  *               OS Dependent defines
515  * ============================================================= 
516  */
517
518 #ifndef HAVE_FSEEKO
519 /* Bad news. This OS cannot handle 64 bit fseeks and ftells */
520 #define fseeko fseek
521 #define ftello ftell
522 #endif
523
524 #if defined (__digital__) && defined (__unix__)
525 /* Tru64 - it does have fseeko and ftello , but since ftell/fseek are also 64 bit */
526 /* take this 'shortcut' */
527 #define fseeko fseek
528 #define ftello ftell
529 #endif
530
531
532 #ifdef __alpha__
533 #define OSF 1
534 #endif
535
536 #ifdef HAVE_SUN_OS
537    /*
538     * On Solaris 2.5, threads are not timesliced by default, so we need to
539     * explictly increase the conncurrency level.
540     */
541 #include <thread.h>
542 #define set_thread_concurrency(x)  thr_setconcurrency(x)
543 extern int thr_setconcurrency(int);
544 #define SunOS 1
545
546 #else
547
548
549 /* Not needed on most systems */
550 #define set_thread_concurrency(x)
551
552 #endif
553
554 #if defined(HAVE_DARWIN_OS) || defined(HAVE_OSF1_OS)
555 /* Apparently someone forgot to wrap getdomainname as a C function */
556 extern "C" int getdomainname(char *name, int len);
557 #endif
558
559 #ifdef HAVE_OSF1_OS
560 extern "C" int mknod ( const char *path, int mode, dev_t device );
561 #endif
562
563 #ifdef HAVE_CYGWIN
564 /* They don't really have it */
565 #undef HAVE_GETDOMAINNAME
566 #endif
567
568 /* Define Winsock functions if we aren't on Windows */
569 #if (!defined HAVE_WIN32) || (defined HAVE_CYGWIN)
570 #define WSA_Init() 0 /* 0 = success */
571 #define WSACleanup() 0 /* 0 = success */
572 #endif
573
574 #ifdef HAVE_AIX_OS
575 #endif
576
577 /* HP-UX 11 specific workarounds */
578
579 #ifdef HAVE_HPUX_OS
580 # undef h_errno
581 extern int h_errno;
582 /* the {get,set}domainname() functions exist in HPUX's libc.
583  * the configure script detects that correctly.
584  * the problem is no system headers declares the prototypes for these functions
585  * this is done below
586  */
587 extern "C" int getdomainname(char *name, int namelen);
588 extern "C" int setdomainname(char *name, int namelen);
589 #define uLong unsigned long
590 #endif /* HAVE_HPUX_OS */
591
592
593 #ifdef HAVE_OSF1_OS
594 #undef HAVE_CHFLAGS  /* chflags is incorrectly detected */
595 extern "C" int fchdir(int filedes);
596 extern "C" long gethostid(void);
597 #endif
598
599
600 /* Added by KES to deal with Win32 systems */
601 #ifndef S_ISWIN32
602 #define S_ISWIN32 020000
603 #endif
604
605
606 /* Disabled because it breaks internationalisation...
607 #undef HAVE_SETLOCALE
608 #ifdef HAVE_SETLOCALE
609 #include <locale.h>
610 #else
611 #define setlocale(x, y) ("ANSI_X3.4-1968")
612 #endif
613 #ifdef HAVE_NL_LANGINFO
614 #include <langinfo.h>
615 #else
616 #define nl_langinfo(x) ("ANSI_X3.4-1968")
617 #endif
618 */
619
620 /* Fake entry points if regex does not exist */
621 #ifndef HAVE_REGEX_H
622 #define regcomp(x, y, z) 1
623 #define regfree(x)
624 #define regerror(rc, preg, prbuf, len) bstrncpy(prbuf, "REGEX not available on this system.", len)
625 #define regex_t int
626 #define regmatch_t char
627 #endif
628
629 #endif /* _BACONFIG_H */