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