2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 Define integer types for Bacula -- Kern Sibbald
22 Integer types. These types should be be used in all
23 contexts in which the length of an integer stored on
24 removable media must be known regardless of the
25 architecture of the platform.
29 int8_t, int16_t, int32_t, int64_t
30 uint8_t, uint16_t, uint32_t, uint64_t
32 Also, we define types such as file address lengths.
36 #ifndef __bc_types_INCLUDED
37 #define __bc_types_INCLUDED
40 * These are the sizes of the current definitions of database
41 * Ids. In general, FileId_t can be set to uint64_t and it
42 * *should* work. Users have reported back that it does work
43 * for PostgreSQL. For the other types, all places in Bacula
44 * have been converted, but no one has actually tested it.
45 * In principle, the only field that really should need to be
46 * 64 bits is the FileId_t
48 typedef uint64_t FileId_t;
49 typedef uint32_t DBId_t; /* general DB id type */
50 typedef uint32_t JobId_t;
58 /* If sys/types.h does not supply intXX_t, supply them ourselves */
62 typedef unsigned int u_int;
66 # if (SIZEOF_CHAR == 1)
67 typedef signed char int8_t;
69 # error "8 bit int type not found."
71 # if (SIZEOF_SHORT_INT == 2)
72 typedef short int int16_t;
74 # error "16 bit int type not found."
76 # if (SIZEOF_INT == 4)
79 # error "32 bit int type not found."
83 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
84 #ifndef HAVE_U_INTXX_T
86 typedef uint8_t u_int8_t;
87 typedef uint16_t u_int16_t;
88 typedef uint32_t u_int32_t;
89 # define HAVE_U_INTXX_T 1
91 # if (SIZEOF_CHAR == 1)
92 typedef unsigned char u_int8_t;
94 # error "8 bit int type not found. Required!"
96 # if (SIZEOF_SHORT_INT == 2)
97 typedef unsigned short int u_int16_t;
99 # error "16 bit int type not found. Required!"
101 # if (SIZEOF_INT == 4)
102 typedef unsigned int u_int32_t;
104 # error "32 bit int type not found. Required!"
111 # if (SIZEOF_LONG_LONG_INT == 8)
112 typedef long long int int64_t;
113 # define HAVE_INT64_T 1
115 # if (SIZEOF_LONG_INT == 8)
116 typedef long int int64_t;
117 # define HAVE_INT64_T 1
122 #ifndef HAVE_INTMAX_T
124 typedef int64_t intmax_t;
126 # error "64 bit type not found. Required!"
130 #ifndef HAVE_U_INT64_T
131 # if (SIZEOF_LONG_LONG_INT == 8)
132 typedef unsigned long long int u_int64_t;
133 # define HAVE_U_INT64_T 1
135 # if (SIZEOF_LONG_INT == 8)
136 typedef unsigned long int u_int64_t;
137 # define HAVE_U_INT64_T 1
139 # error "64 bit type not found. Required!"
144 #ifndef HAVE_U_INTMAX_T
145 # ifdef HAVE_U_INT64_T
146 typedef u_int64_t u_intmax_t;
148 # error "64 bit type not found. Required!"
152 #ifndef HAVE_INTPTR_T
153 #define HAVE_INTPTR_T 1
154 # if (SIZEOF_INT_P == 4)
155 typedef int32_t intptr_t;
157 # if (SIZEOF_INT_P == 8)
158 typedef int64_t intptr_t;
160 # error "Can't find sizeof pointer. Required!"
165 #ifndef HAVE_UINTPTR_T
166 #define HAVE_UINTPTR_T 1
167 # if (SIZEOF_INT_P == 4)
168 typedef uint32_t uintptr_t;
170 # if (SIZEOF_INT_P == 8)
171 typedef uint64_t uintptr_t;
173 # error "Can't find sizeof pointer. Required!"
178 /* Limits for the above types. */
189 #define INT8_MIN (-127-1)
190 #define INT8_MAX (127)
191 #define UINT8_MAX (255u)
192 #define INT16_MIN (-32767-1)
193 #define INT16_MAX (32767)
194 #define UINT16_MAX (65535u)
195 #define INT32_MIN (-2147483647-1)
196 #define INT32_MAX (2147483647)
197 #define UINT32_MAX (4294967295u)
199 typedef double float64_t;
200 typedef float float32_t;
203 /* Define the uint versions actually used in Bacula */
205 #define uint8_t u_int8_t
206 #define uint16_t u_int16_t
207 #define uint32_t u_int32_t
208 #define uint64_t u_int64_t
209 #define uintmax_t u_intmax_t
212 /* Bacula time -- Unix time with microseconds */
213 #define btime_t int64_t
214 /* Unix time (time_t) widened to 64 bits */
215 #define utime_t int64_t
217 #ifndef HAVE_SOCKLEN_T
218 #define socklen_t int
223 #define SOCKET_ERROR (-1)
227 #ifdef HAVE_OLD_SOCKOPT
228 #define sockopt_val_t char *
230 #define sockopt_val_t void *
234 * Status codes returned by create_file()
235 * Used in findlib, filed, and plugins
238 CF_SKIP = 1, /* skip file (not newer or something) */
239 CF_ERROR, /* error creating file */
240 CF_EXTRACT, /* file created, data to extract */
241 CF_CREATED, /* file created, no data to extract */
242 CF_CORE /* let bacula core handle the file creation */
246 #define MAX(a, b) ((a) > (b) ? (a) : (b))
249 #define MIN(a, b) ((a) < (b) ? (a) : (b))
252 #endif /* __bc_types_INCLUDED */