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