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