]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/baconfig.h
11261ed7f70b4e72e494f85a465400cea4a05daa
[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, 2001, 2002 Kern Sibbald and John Walker
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 #define DEBUG 1                       /* turn on debug code */
34
35 #define TRUE  1
36 #define FALSE 0
37
38 #ifdef PROTOTYPES
39 # define __PROTO(p)     p
40 #else
41 # define __PROTO(p)     ()
42 #endif
43
44 /* #define ASSERT(x) if (!(x)) Emsg1(M_ABORT, 0, "Failed ASSERT: %s\n", __STRING(x)) */
45 #define ASSERT(x) if (!(x)) { \
46    char *jcr = NULL; \
47    Emsg1(M_ERROR, 0, "Failed ASSERT: %s\n", #x); \
48    jcr[0] = 0; }
49
50 /* Allow printing of NULL pointers */
51 #define NPRT(x) (x)?(x):"(NULL)" 
52
53 #ifdef ENABLE_NLS
54 #include <libintl.h>
55 #define _(s) gettext((s))
56 #define N_(s) (s)
57 #else
58 #define _(s) (s)
59 #define N_(s) (s)
60 #define textdomain(x)
61 #endif
62
63
64 /* This should go away! ****FIXME***** */
65 #define MAXSTRING 500
66
67 /* Maximum length to edit time/date */
68 #define MAX_TIME_LENGTH 30
69
70 /* Maximum Name length including EOS */
71 #define MAX_NAME_LENGTH 128
72
73 /* All tape operations MUST be a multiple of this */
74 #define TAPE_BSIZE 1024
75 #if !defined(DEV_BSIZE) && defined(BSIZE)
76 #define DEV_BSIZE BSIZE
77 #else 
78 #define DEV_BSIZE 512
79 #endif
80
81 /* Maximum number of bytes that you can push into a
82  * socket.
83  */
84 #define MAX_NETWORK_BUFFER_SIZE (32 * 1024)
85
86 /* Stream definitions.  Once defined these must NEVER
87  * change as they go on the storage media
88  */
89 #define STREAM_UNIX_ATTRIBUTES  1     /* Generic Unix attributes */
90 #define STREAM_FILE_DATA        2     /* Standard uncompressed data */
91 #define STREAM_MD5_SIGNATURE    3     /* MD5 signature for the file */
92 #define STREAM_GZIP_DATA        4     /* GZip compressed file data */
93
94
95 /* This is for dumb compilers like Solaris. Linux GCC
96  * does it correctly, so it might be worthwhile
97  * to remove the isascii(c) with ifdefs on such
98  * "smart" systems.
99  */
100 #undef  ISSPACE
101 #undef  ISALPHA
102 #undef  ISUPPER
103 #undef  ISDIGIT
104 #define ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
105 #define ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
106 #define ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
107 #define ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
108
109
110 typedef void (HANDLER)();
111 typedef int (INTHANDLER)();
112
113 #ifdef SETPGRP_VOID
114 # define SETPGRP_ARGS(x, y) /* No arguments */
115 #else
116 # define SETPGRP_ARGS(x, y) (x, y)
117 #endif
118
119 #ifndef S_ISLNK
120 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
121 #endif
122
123 #ifndef INADDR_NONE
124 #define INADDR_NONE ((unsigned long) -1)
125 #endif
126
127 #ifdef TIME_WITH_SYS_TIME
128 # include <sys/time.h>
129 # include <time.h>
130 #else
131 # ifdef HAVE_SYS_TIME_H
132 #  include <sys/time.h>
133 # else
134 #  include <time.h>
135 # endif
136 #endif
137
138 #ifndef O_BINARY
139 #define O_BINARY 0
140 #endif
141
142 #ifndef MODE_RW
143 #define MODE_RW 0666
144 #endif
145
146 #ifdef DEBUG_MUTEX
147 extern void _p(char *file, int line, pthread_mutex_t *m);
148 extern void _v(char *file, int line, pthread_mutex_t *m);
149
150 #define P(x) _p(__FILE__, __LINE__, &(x))
151 #define V(x) _v(__FILE__, __LINE__, &(x))
152
153 #else
154
155 /* These probably should be subroutines */
156 #define P(x) \
157    do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
158       e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
159            strerror(errstat)); \
160    } while(0)
161
162 #define V(x) \
163    do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
164          e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
165            strerror(errstat)); \
166    } while(0)
167
168 #endif /* DEBUG_MUTEX */
169
170 /*
171  * The digit following Dmsg and Emsg indicates the number of substitutions in
172  * the message string. We need to do this kludge because non-GNU compilers
173  * do not handle varargs #defines.
174  */
175 /* Debug Messages that are printed */
176 #ifdef DEBUG
177 #define Dmsg0(lvl, msg)             d_msg(__FILE__, __LINE__, lvl, msg)
178 #define Dmsg1(lvl, msg, a1)         d_msg(__FILE__, __LINE__, lvl, msg, a1)
179 #define Dmsg2(lvl, msg, a1, a2)     d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
180 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
181 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
182 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
183 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
184 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
185 #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)
186 #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)
187 #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)
188 #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)
189 #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)
190 #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)
191 #else
192 #define Dmsg0(lvl, msg)
193 #define Dmsg1(lvl, msg, a1)
194 #define Dmsg2(lvl, msg, a1, a2)
195 #define Dmsg3(lvl, msg, a1, a2, a3)
196 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
197 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
198 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
199 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
200 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
201 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
202 #define Dmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
203 #define Dmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
204 #endif /* DEBUG */
205        
206 /* Daemon Error Messages that are delivered according to the message resource */
207 #define Emsg0(typ, lvl, msg)             e_msg(__FILE__, __LINE__, typ, lvl, msg)
208 #define Emsg1(typ, lvl, msg, a1)         e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
209 #define Emsg2(typ, lvl, msg, a1, a2)     e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
210 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
211 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
212 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
213 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
214
215 /* Job Error Messages that are delivered according to the message resource */
216 #define Jmsg0(jcr, typ, lvl, msg)             j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
217 #define Jmsg1(jcr, typ, lvl, msg, a1)         j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
218 #define Jmsg2(jcr, typ, lvl, msg, a1, a2)     j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
219 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
220 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
221 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
222 #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)
223
224
225 /* Memory Messages that are edited into a Pool Memory buffer */
226 #define Mmsg0(buf, msg)             m_msg(__FILE__, __LINE__, buf, msg)
227 #define Mmsg1(buf, msg, a1)         m_msg(__FILE__, __LINE__, buf, msg, a1)
228 #define Mmsg2(buf, msg, a1, a2)     m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
229 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
230 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
231 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
232 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
233 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
234 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
235 #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)
236 #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)
237
238 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
239 int  Mmsg(char **msgbuf, char *fmt,...);
240
241
242 void d_msg(char *file, int line, int level, char *fmt,...);
243 void e_msg(char *file, int line, int type, int level, char *fmt,...);
244 void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
245 int  m_msg(char *file, int line, char **msgbuf, char *fmt,...);
246
247
248 /* Use our strdup with smartalloc */
249 #undef strdup
250 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
251
252 #ifdef DEBUG
253 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
254 #else
255 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
256 #endif
257
258 #ifdef DEBUG
259 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
260 #endif
261
262 #ifdef __alpha__
263 #define OSF 1
264 #endif
265
266 #ifdef HAVE_SUN_OS
267    /* 
268     * On Solaris 2.5, threads are not timesliced by default, so we need to
269     * explictly increase the conncurrency level.
270     */
271 #include <thread.h>
272 #define set_thread_concurrency(x)  thr_setconcurrency(x)
273 extern int thr_setconcurrency(int);
274 #define SunOS 1
275
276 #else
277
278 /* Not needed on most systems */
279 #define set_thread_concurrency(x)
280
281 #endif
282
283 #define ALIGN_SIZE (sizeof(double))
284 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
285
286 #endif /* _BACONFIG_H */