2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
21 Define integer types for Bacula -- Kern Sibbald
23 Integer types. These types should be be used in all
24 contexts in which the length of an integer stored on
25 removable media must be known regardless of the
26 architecture of the platform.
30 int8_t, int16_t, int32_t, int64_t
31 uint8_t, uint16_t, uint32_t, uint64_t
33 Also, we define types such as file address lengths.
38 #ifndef __bc_types_INCLUDED
39 #define __bc_types_INCLUDED
42 * These are the sizes of the current definitions of database
43 * Ids. In general, FileId_t can be set to uint64_t and it
44 * *should* work. Users have reported back that it does work
45 * for PostgreSQL. For the other types, all places in Bacula
46 * have been converted, but no one has actually tested it.
47 * In principle, the only field that really should need to be
48 * 64 bits is the FileId_t
50 typedef uint64_t FileId_t;
51 typedef uint32_t DBId_t; /* general DB id type */
52 typedef uint32_t JobId_t;
60 /* If sys/types.h does not supply intXX_t, supply them ourselves */
64 typedef unsigned int u_int;
68 # if (SIZEOF_CHAR == 1)
69 typedef signed char int8_t;
71 # error "8 bit int type not found."
73 # if (SIZEOF_SHORT_INT == 2)
74 typedef short int int16_t;
76 # error "16 bit int type not found."
78 # if (SIZEOF_INT == 4)
81 # error "32 bit int type not found."
85 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
86 #ifndef HAVE_U_INTXX_T
88 typedef uint8_t u_int8_t;
89 typedef uint16_t u_int16_t;
90 typedef uint32_t u_int32_t;
91 # define HAVE_U_INTXX_T 1
93 # if (SIZEOF_CHAR == 1)
94 typedef unsigned char u_int8_t;
96 # error "8 bit int type not found. Required!"
98 # if (SIZEOF_SHORT_INT == 2)
99 typedef unsigned short int u_int16_t;
101 # error "16 bit int type not found. Required!"
103 # if (SIZEOF_INT == 4)
104 typedef unsigned int u_int32_t;
106 # error "32 bit int type not found. Required!"
113 # if (SIZEOF_LONG_LONG_INT == 8)
114 typedef long long int int64_t;
115 # define HAVE_INT64_T 1
117 # if (SIZEOF_LONG_INT == 8)
118 typedef long int int64_t;
119 # define HAVE_INT64_T 1
124 #ifndef HAVE_INTMAX_T
126 typedef int64_t intmax_t;
128 # error "64 bit type not found. Required!"
132 #ifndef HAVE_U_INT64_T
133 # if (SIZEOF_LONG_LONG_INT == 8)
134 typedef unsigned long long int u_int64_t;
135 # define HAVE_U_INT64_T 1
137 # if (SIZEOF_LONG_INT == 8)
138 typedef unsigned long int u_int64_t;
139 # define HAVE_U_INT64_T 1
141 # error "64 bit type not found. Required!"
146 #ifndef HAVE_U_INTMAX_T
147 # ifdef HAVE_U_INT64_T
148 typedef u_int64_t u_intmax_t;
150 # error "64 bit type not found. Required!"
154 #ifndef HAVE_INTPTR_T
155 #define HAVE_INTPTR_T 1
156 # if (SIZEOF_INT_P == 4)
157 typedef int32_t intptr_t;
159 # if (SIZEOF_INT_P == 8)
160 typedef int64_t intptr_t;
162 # error "Can't find sizeof pointer. Required!"
167 #ifndef HAVE_UINTPTR_T
168 #define HAVE_UINTPTR_T 1
169 # if (SIZEOF_INT_P == 4)
170 typedef uint32_t uintptr_t;
172 # if (SIZEOF_INT_P == 8)
173 typedef uint64_t uintptr_t;
175 # error "Can't find sizeof pointer. Required!"
180 /* Limits for the above types. */
191 #define INT8_MIN (-127-1)
192 #define INT8_MAX (127)
193 #define UINT8_MAX (255u)
194 #define INT16_MIN (-32767-1)
195 #define INT16_MAX (32767)
196 #define UINT16_MAX (65535u)
197 #define INT32_MIN (-2147483647-1)
198 #define INT32_MAX (2147483647)
199 #define UINT32_MAX (4294967295u)
201 typedef double float64_t;
202 typedef float float32_t;
205 /* Define the uint versions actually used in Bacula */
207 #define uint8_t u_int8_t
208 #define uint16_t u_int16_t
209 #define uint32_t u_int32_t
210 #define uint64_t u_int64_t
211 #define uintmax_t u_intmax_t
214 /* Bacula time -- Unix time with microseconds */
215 #define btime_t int64_t
216 /* Unix time (time_t) widened to 64 bits */
217 #define utime_t int64_t
219 #ifndef HAVE_SOCKLEN_T
220 #define socklen_t int
225 #define SOCKET_ERROR (-1)
229 #ifdef HAVE_OLD_SOCKOPT
230 #define sockopt_val_t char *
232 #define sockopt_val_t void *
236 * Status codes returned by create_file()
237 * Used in findlib, filed, and plugins
240 CF_SKIP = 1, /* skip file (not newer or something) */
241 CF_ERROR, /* error creating file */
242 CF_EXTRACT, /* file created, data to extract */
243 CF_CREATED, /* file created, no data to extract */
244 CF_CORE /* let bacula core handle the file creation */
248 #define MAX(a, b) ((a) > (b) ? (a) : (b))
251 #define MIN(a, b) ((a) < (b) ? (a) : (b))
254 #endif /* __bc_types_INCLUDED */