2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
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 two of the GNU General Public
10 License as published by the Free Software Foundation and included
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.
18 You should have received a copy of the GNU 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
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.
29 Define integer types for Bacula -- Kern Sibbald
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.
38 int8_t, int16_t, int32_t, int64_t
39 uint8_t, uint16_t, uint32_t, uint64_t
41 Also, we define types such as file address lengths.
48 #ifndef __bc_types_INCLUDED
49 #define __bc_types_INCLUDED
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
60 typedef uint64_t FileId_t;
61 typedef uint32_t DBId_t; /* general DB id type */
62 typedef uint32_t JobId_t;
70 /* If sys/types.h does not supply intXX_t, supply them ourselves */
74 typedef unsigned int u_int;
78 # if (SIZEOF_CHAR == 1)
79 typedef signed char int8_t;
81 # error "8 bit int type not found."
83 # if (SIZEOF_SHORT_INT == 2)
84 typedef short int int16_t;
86 # error "16 bit int type not found."
88 # if (SIZEOF_INT == 4)
91 # error "32 bit int type not found."
95 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
96 #ifndef HAVE_U_INTXX_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
103 # if (SIZEOF_CHAR == 1)
104 typedef unsigned char u_int8_t;
106 # error "8 bit int type not found. Required!"
108 # if (SIZEOF_SHORT_INT == 2)
109 typedef unsigned short int u_int16_t;
111 # error "16 bit int type not found. Required!"
113 # if (SIZEOF_INT == 4)
114 typedef unsigned int u_int32_t;
116 # error "32 bit int type not found. Required!"
123 # if (SIZEOF_LONG_LONG_INT == 8)
124 typedef long long int int64_t;
125 # define HAVE_INT64_T 1
127 # if (SIZEOF_LONG_INT == 8)
128 typedef long int int64_t;
129 # define HAVE_INT64_T 1
134 #ifndef HAVE_INTMAX_T
136 typedef int64_t intmax_t;
138 # error "64 bit type not found. Required!"
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
147 # if (SIZEOF_LONG_INT == 8)
148 typedef unsigned long int u_int64_t;
149 # define HAVE_U_INT64_T 1
151 # error "64 bit type not found. Required!"
156 #ifndef HAVE_U_INTMAX_T
157 # ifdef HAVE_U_INT64_T
158 typedef u_int64_t u_intmax_t;
160 # error "64 bit type not found. Required!"
164 #ifndef HAVE_INTPTR_T
165 #define HAVE_INTPTR_T 1
166 # if (SIZEOF_INT_P == 4)
167 typedef int32_t intptr_t;
169 # if (SIZEOF_INT_P == 8)
170 typedef int64_t intptr_t;
172 # error "Can't find sizeof pointer. Required!"
177 #ifndef HAVE_UINTPTR_T
178 #define HAVE_UINTPTR_T 1
179 # if (SIZEOF_INT_P == 4)
180 typedef uint32_t uintptr_t;
182 # if (SIZEOF_INT_P == 8)
183 typedef uint64_t uintptr_t;
185 # error "Can't find sizeof pointer. Required!"
190 /* Limits for the above types. */
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)
211 typedef double float64_t;
212 typedef float float32_t;
215 /* Define the uint versions actually used in Bacula */
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
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
229 #ifndef HAVE_SOCKLEN_T
230 #define socklen_t int
233 #ifdef HAVE_OLD_SOCKOPT
234 #define sockopt_val_t char *
236 #define sockopt_val_t void *
240 * Status codes returned by create_file()
241 * Used in findlib, filed, and plugins
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 */
251 #define MAX(a, b) ((a) > (b) ? (a) : (b))
254 #define MIN(a, b) ((a) < (b) ? (a) : (b))
257 #endif /* __bc_types_INCLUDED */