]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/bc_types.h
Fix plugin bug with multiple simultaneous jobs
[bacula/bacula] / bacula / src / bc_types.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29     Define integer types for Bacula -- Kern Sibbald
30
31     Integer types.  These types should be be used in all
32     contexts in which the length of an integer stored on
33     removable media must be known regardless of the
34     architecture of the platform.
35
36     Bacula types are:
37
38     int8_t,  int16_t,  int32_t,  int64_t
39     uint8_t, uint16_t, uint32_t, uint64_t
40
41     Also, we define types such as file address lengths.
42
43     Version $Id$
44
45  */
46
47
48 #ifndef __bc_types_INCLUDED
49 #define __bc_types_INCLUDED
50
51 /*
52  * These are the sizes of the current definitions of database
53  *  Ids.  In general, FileId_t can be set to uint64_t and it
54  *  *should* work.  Users have reported back that it does work
55  *  for PostgreSQL.  For the other types, all places in Bacula
56  *  have been converted, but no one has actually tested it.
57  * In principle, the only field that really should need to be
58  *  64 bits is the FileId_t
59  */
60 typedef uint64_t FileId_t;
61 typedef uint32_t DBId_t;              /* general DB id type */
62 typedef uint32_t JobId_t;
63
64
65 typedef char POOLMEM;
66
67
68 /* Types */
69
70 /* If sys/types.h does not supply intXX_t, supply them ourselves */
71 /* (or die trying) */
72
73 #ifndef HAVE_U_INT
74 typedef unsigned int u_int;
75 #endif
76
77 #ifndef HAVE_INTXX_T
78 # if (SIZEOF_CHAR == 1)
79 typedef signed char int8_t;
80 # else
81 #  error "8 bit int type not found."
82 # endif
83 # if (SIZEOF_SHORT_INT == 2)
84 typedef short int int16_t;
85 # else
86 #  error "16 bit int type not found."
87 # endif
88 # if (SIZEOF_INT == 4)
89 typedef int int32_t;
90 # else
91 #  error "32 bit int type not found."
92 # endif
93 #endif
94
95 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
96 #ifndef HAVE_U_INTXX_T
97 # ifdef HAVE_UINTXX_T
98 typedef uint8_t u_int8_t;
99 typedef uint16_t u_int16_t;
100 typedef uint32_t u_int32_t;
101 # define HAVE_U_INTXX_T 1
102 # else
103 #  if (SIZEOF_CHAR == 1)
104 typedef unsigned char u_int8_t;
105 #  else
106 #   error "8 bit int type not found. Required!"
107 #  endif
108 #  if (SIZEOF_SHORT_INT == 2)
109 typedef unsigned short int u_int16_t;
110 #  else
111 #   error "16 bit int type not found. Required!"
112 #  endif
113 #  if (SIZEOF_INT == 4)
114 typedef unsigned int u_int32_t;
115 #  else
116 #   error "32 bit int type not found. Required!"
117 #  endif
118 # endif
119 #endif
120
121 /* 64-bit types */
122 #ifndef HAVE_INT64_T
123 # if (SIZEOF_LONG_LONG_INT == 8)
124 typedef long long int int64_t;
125 #   define HAVE_INT64_T 1
126 # else
127 #  if (SIZEOF_LONG_INT == 8)
128 typedef long int int64_t;
129 #   define HAVE_INT64_T 1
130 #  endif
131 # endif
132 #endif
133
134 #ifndef HAVE_INTMAX_T
135 # ifdef HAVE_INT64_T
136 typedef int64_t intmax_t;
137 # else
138 #   error "64 bit type not found. Required!"
139 # endif
140 #endif
141
142 #ifndef HAVE_U_INT64_T
143 # if (SIZEOF_LONG_LONG_INT == 8)
144 typedef unsigned long long int u_int64_t;
145 #   define HAVE_U_INT64_T 1
146 # else
147 #  if (SIZEOF_LONG_INT == 8)
148 typedef unsigned long int u_int64_t;
149 #   define HAVE_U_INT64_T 1
150 #  else
151 #   error "64 bit type not found. Required!"
152 #  endif
153 # endif
154 #endif
155
156 #ifndef HAVE_U_INTMAX_T
157 # ifdef HAVE_U_INT64_T
158 typedef u_int64_t u_intmax_t;
159 # else
160 #   error "64 bit type not found. Required!"
161 # endif
162 #endif
163
164 #ifndef HAVE_INTPTR_T
165 #define HAVE_INTPTR_T 1
166 # if (SIZEOF_INT_P == 4)
167 typedef int32_t intptr_t;
168 # else
169 #  if (SIZEOF_INT_P == 8)
170 typedef int64_t intptr_t;
171 #  else
172 #   error "Can't find sizeof pointer. Required!"
173 #  endif
174 # endif
175 #endif
176
177 #ifndef HAVE_UINTPTR_T
178 #define HAVE_UINTPTR_T 1
179 # if (SIZEOF_INT_P == 4)
180 typedef uint32_t uintptr_t;
181 # else
182 #  if (SIZEOF_INT_P == 8)
183 typedef uint64_t uintptr_t;
184 #  else
185 #   error "Can't find sizeof pointer. Required!"
186 #  endif
187 # endif
188 #endif
189
190 /* Limits for the above types. */
191 #undef INT8_MIN
192 #undef INT8_MAX
193 #undef UINT8_MAX
194 #undef INT16_MIN
195 #undef INT16_MAX
196 #undef UINT16_MAX
197 #undef INT32_MIN
198 #undef INT32_MAX
199 #undef UINT32_MAX
200
201 #define INT8_MIN        (-127-1)
202 #define INT8_MAX        (127)
203 #define UINT8_MAX       (255u)
204 #define INT16_MIN       (-32767-1)
205 #define INT16_MAX       (32767)
206 #define UINT16_MAX      (65535u)
207 #define INT32_MIN       (-2147483647-1)
208 #define INT32_MAX       (2147483647)
209 #define UINT32_MAX      (4294967295u)
210
211 typedef double            float64_t;
212 typedef float             float32_t;
213
214
215 /* Define the uint versions actually used in Bacula */
216 #ifndef uint8_t
217 #define uint8_t u_int8_t
218 #define uint16_t u_int16_t
219 #define uint32_t u_int32_t
220 #define uint64_t u_int64_t
221 #define uintmax_t u_intmax_t
222 #endif
223
224 /* Bacula time -- Unix time with microseconds */
225 #define btime_t int64_t
226 /* Unix time (time_t) widened to 64 bits */
227 #define utime_t int64_t
228
229 #ifndef HAVE_SOCKLEN_T
230 #define socklen_t int
231 #endif
232
233 #ifdef HAVE_OLD_SOCKOPT
234 #define sockopt_val_t char *
235 #else
236 #define sockopt_val_t void *
237 #endif
238
239 /*
240  * Status codes returned by create_file()
241  *   Used in findlib, filed, and plugins
242  */
243 enum {
244    CF_SKIP = 1,                   /* skip file (not newer or something) */
245    CF_ERROR,                      /* error creating file */
246    CF_EXTRACT,                    /* file created, data to extract */
247    CF_CREATED,                    /* file created, no data to extract */
248    CF_CORE                        /* let bacula core handle the file creation */
249 };
250
251 #ifndef MAX
252 #define MAX(a, b) ((a) > (b) ? (a) : (b))
253 #endif
254 #ifndef MIN
255 #define MIN(a, b) ((a) < (b) ? (a) : (b))
256 #endif
257
258 #endif /* __bc_types_INCLUDED */