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