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