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