2 * General header file configurations that apply to
3 * all daemons. System dependent stuff goes here.
8 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
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.
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.
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,
31 /* Bacula common configuration defines */
33 #define DEBUG 1 /* turn on debug code */
41 # define __PROTO(p) ()
44 /* #define ASSERT(x) if (!(x)) Emsg1(M_ABORT, 0, "Failed ASSERT: %s\n", __STRING(x)) */
45 #define ASSERT(x) if (!(x)) { \
47 Emsg1(M_ERROR, 0, "Failed ASSERT: %s\n", #x); \
54 #define _(s) gettext((s))
63 /* This should go away! ****FIXME***** */
66 /* Maximum length to edit time/date */
67 #define MAX_TIME_LENGTH 30
69 /* Maximum Name length including EOS */
70 #define MAX_NAME_LENGTH 128
72 /* All tape operations MUST be a multiple of this */
73 #define TAPE_BSIZE 1024
74 #if !defined(DEV_BSIZE) && defined(BSIZE)
75 #define DEV_BSIZE BSIZE
80 /* Maximum number of bytes that you can push into a
83 #define MAX_NETWORK_BUFFER_SIZE (32 * 1024)
85 /* Stream definitions. Once defined these must NEVER
86 * change as they go on the storage media
88 #define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */
89 #define STREAM_FILE_DATA 2 /* Standard uncompressed data */
90 #define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */
91 #define STREAM_GZIP_DATA 4 /* GZip compressed file data */
94 /* This is for dumb compilers like Solaris. Linux GCC
95 * does it correctly, so it might be worthwhile
96 * to remove the isascii(c) with ifdefs on such
103 #define ISSPACE(c) (isascii((int)(c)) && isspace((int)(c)))
104 #define ISALPHA(c) (isascii((int)(c)) && isalpha((int)(c)))
105 #define ISUPPER(c) (isascii((int)(c)) && isupper((int)(c)))
106 #define ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c)))
109 typedef void (HANDLER)();
110 typedef int (INTHANDLER)();
113 # define SETPGRP_ARGS(x, y) /* No arguments */
115 # define SETPGRP_ARGS(x, y) (x, y)
119 #define S_ISLNK(m) (((m) & S_IFM) == S_IFLNK)
123 #define INADDR_NONE ((unsigned long) -1)
126 #ifdef TIME_WITH_SYS_TIME
127 # include <sys/time.h>
130 # ifdef HAVE_SYS_TIME_H
131 # include <sys/time.h>
146 extern void _p(char *file, int line, pthread_mutex_t *m);
147 extern void _v(char *file, int line, pthread_mutex_t *m);
149 #define P(x) _p(__FILE__, __LINE__, &(x))
150 #define V(x) _v(__FILE__, __LINE__, &(x))
154 /* These probably should be subroutines */
156 do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \
157 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\
158 strerror(errstat)); \
162 do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \
163 e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\
164 strerror(errstat)); \
167 #endif /* DEBUG_MUTEX */
170 * The digit following Dmsg and Emsg indicates the number of substitutions in
171 * the message string. We need to do this kludge because non-GNU compilers
172 * do not handle varargs #defines.
174 /* Debug Messages that are printed */
176 #define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg)
177 #define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1)
178 #define Dmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2)
179 #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3)
180 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4)
181 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5)
182 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6)
183 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3, a4, a5, a6, a7)
184 #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)
185 #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)
187 #define Dmsg0(lvl, msg)
188 #define Dmsg1(lvl, msg, a1)
189 #define Dmsg2(lvl, msg, a1, a2)
190 #define Dmsg3(lvl, msg, a1, a2, a3)
191 #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4)
192 #define Dmsg5(lvl, msg, a1, a2, a3, a4, a5)
193 #define Dmsg6(lvl, msg, a1, a2, a3, a4, a5, a6)
194 #define Dmsg7(lvl, msg, a1, a2, a3, a4, a5, a6, a7)
195 #define Dmsg8(lvl, msg, a1, a2, a3, a4, a5, a6, a7, a8)
196 #define Dmsg11(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
199 /* Daemon Error Messages that are delivered according to the message resource */
200 #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg)
201 #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1)
202 #define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2)
203 #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3)
204 #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4)
205 #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5)
206 #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6)
208 /* Job Error Messages that are delivered according to the message resource */
209 #define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg)
210 #define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1)
211 #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2)
212 #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3)
213 #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4)
214 #define Jmsg5(jcr, typ, lvl, msg, a1, a2, a3, a4, a5) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5)
215 #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)
218 /* Memory Messages that are edited into a Pool Memory buffer */
219 #define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg)
220 #define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1)
221 #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2)
222 #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3)
223 #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4)
224 #define Mmsg5(buf, msg, a1, a2, a3, a4, a5) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5)
225 #define Mmsg6(buf, msg, a1, a2, a3, a4, a5, a6) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
226 #define Mmsg7(buf, msg, a1, a2, a3, a4, a5, a6, a7) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4, a5, a6)
227 #define Mmsg8(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6)
228 #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)
229 #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)
231 /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */
232 int Mmsg(char **msgbuf, char *fmt,...);
235 void d_msg(char *file, int line, int level, char *fmt,...);
236 void e_msg(char *file, int line, int type, int level, char *fmt,...);
237 void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
238 int m_msg(char *file, int line, char **msgbuf, char *fmt,...);
241 /* Use our strdup with smartalloc */
243 #define strdup(buf) bad_call_on_strdup_use_bstrdup(buf)
246 #define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
248 #define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str))
252 #define bmalloc(size) b_malloc(__FILE__, __LINE__, (size))
261 * On Solaris 2.5, threads are not timesliced by default, so we need to
262 * explictly increase the conncurrency level.
265 #define set_thread_concurrency(x) thr_setconcurrency(x)
266 extern int thr_setconcurrency(int);
271 /* Not needed on most systems */
272 #define set_thread_concurrency(x)
276 #define ALIGN_SIZE (sizeof(double))
277 #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1))
279 #endif /* _BACONFIG_H */