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