]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/bc_types.h
kes Begin implementing new comm signals for API.
[bacula/bacula] / bacula / src / bc_types.h
1 /*
2     Define integer types for Bacula -- Kern Sibbald
3
4     Integer types.  These types should be be used in all
5     contexts in which the length of an integer stored on
6     removable media must be known regardless of the
7     architecture of the platform.
8
9     Bacula types are:
10
11     int8_t,  int16_t,  int32_t,  int64_t
12     uint8_t, uint16_t, uint32_t, uint64_t
13
14     Also, we define types such as file address lengths.
15
16     Version $Id$
17
18  */
19 /*
20    Bacula® - The Network Backup Solution
21
22    Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
23
24    The main author of Bacula is Kern Sibbald, with contributions from
25    many others, a complete list can be found in the file AUTHORS.
26    This program is Free Software; you can redistribute it and/or
27    modify it under the terms of version two of the GNU General Public
28    License as published by the Free Software Foundation plus additions
29    that are listed in the file LICENSE.
30
31    This program is distributed in the hope that it will be useful, but
32    WITHOUT ANY WARRANTY; without even the implied warranty of
33    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34    General Public License for more details.
35
36    You should have received a copy of the GNU General Public License
37    along with this program; if not, write to the Free Software
38    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
39    02110-1301, USA.
40
41    Bacula® is a registered trademark of John Walker.
42    The licensor of Bacula is the Free Software Foundation Europe
43    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
44    Switzerland, email:ftf@fsfeurope.org.
45 */
46
47
48 #ifndef __bc_types_INCLUDED
49 #define __bc_types_INCLUDED
50
51 typedef char POOLMEM;
52
53
54 /* Types */
55
56 /* If sys/types.h does not supply intXX_t, supply them ourselves */
57 /* (or die trying) */
58
59 #ifndef HAVE_U_INT
60 typedef unsigned int u_int;
61 #endif
62
63 #ifndef HAVE_INTXX_T
64 # if (SIZEOF_CHAR == 1)
65 typedef char int8_t;
66 # else
67 #  error "8 bit int type not found."
68 # endif
69 # if (SIZEOF_SHORT_INT == 2)
70 typedef short int int16_t;
71 # else
72 #  error "16 bit int type not found."
73 # endif
74 # if (SIZEOF_INT == 4)
75 typedef int int32_t;
76 # else
77 #  error "32 bit int type not found."
78 # endif
79 #endif
80
81 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
82 #ifndef HAVE_U_INTXX_T
83 # ifdef HAVE_UINTXX_T
84 typedef uint8_t u_int8_t;
85 typedef uint16_t u_int16_t;
86 typedef uint32_t u_int32_t;
87 # define HAVE_U_INTXX_T 1
88 # else
89 #  if (SIZEOF_CHAR == 1)
90 typedef unsigned char u_int8_t;
91 #  else
92 #   error "8 bit int type not found. Required!"
93 #  endif
94 #  if (SIZEOF_SHORT_INT == 2)
95 typedef unsigned short int u_int16_t;
96 #  else
97 #   error "16 bit int type not found. Required!"
98 #  endif
99 #  if (SIZEOF_INT == 4)
100 typedef unsigned int u_int32_t;
101 #  else
102 #   error "32 bit int type not found. Required!"
103 #  endif
104 # endif
105 #endif
106
107 /* 64-bit types */
108 #ifndef HAVE_INT64_T
109 # if (SIZEOF_LONG_LONG_INT == 8)
110 typedef long long int int64_t;
111 #   define HAVE_INT64_T 1
112 # else
113 #  if (SIZEOF_LONG_INT == 8)
114 typedef long int int64_t;
115 #   define HAVE_INT64_T 1
116 #  endif
117 # endif
118 #endif
119
120 #ifndef HAVE_INTMAX_T
121 # ifdef HAVE_INT64_T
122 typedef int64_t intmax_t;
123 # else
124 #   error "64 bit type not found. Required!"
125 # endif
126 #endif
127
128 #ifndef HAVE_U_INT64_T
129 # if (SIZEOF_LONG_LONG_INT == 8)
130 typedef unsigned long long int u_int64_t;
131 #   define HAVE_U_INT64_T 1
132 # else
133 #  if (SIZEOF_LONG_INT == 8)
134 typedef unsigned long int u_int64_t;
135 #   define HAVE_U_INT64_T 1
136 #  else
137 #   error "64 bit type not found. Required!"
138 #  endif
139 # endif
140 #endif
141
142 #ifndef HAVE_U_INTMAX_T
143 # ifdef HAVE_U_INT64_T
144 typedef u_int64_t u_intmax_t;
145 # else
146 #   error "64 bit type not found. Required!"
147 # endif
148 #endif
149
150
151 /* Limits for the above types. */
152 #undef INT8_MIN
153 #undef INT8_MAX
154 #undef UINT8_MAX
155 #undef INT16_MIN
156 #undef INT16_MAX
157 #undef UINT16_MAX
158 #undef INT32_MIN
159 #undef INT32_MAX
160 #undef UINT32_MAX
161
162 #define INT8_MIN        (-127-1)
163 #define INT8_MAX        (127)
164 #define UINT8_MAX       (255u)
165 #define INT16_MIN       (-32767-1)
166 #define INT16_MAX       (32767)
167 #define UINT16_MAX      (65535u)
168 #define INT32_MIN       (-2147483647-1)
169 #define INT32_MAX       (2147483647)
170 #define UINT32_MAX      (4294967295u)
171
172 typedef double            float64_t;
173 typedef float             float32_t;
174
175 #endif /* __bc_types_INCLUDED */
176
177 /* Define the uint versions actually used in Bacula */
178 #ifndef uint8_t
179 #define uint8_t u_int8_t
180 #define uint16_t u_int16_t
181 #define uint32_t u_int32_t
182 #define uint64_t u_int64_t
183 #define uintmax_t u_intmax_t
184 #endif
185
186 /* Bacula time -- Unix time with microseconds */
187 #define btime_t int64_t
188 /* Unix time (time_t) widened to 64 bits */
189 #define utime_t int64_t
190
191 #ifndef HAVE_SOCKLEN_T
192 #define socklen_t int
193 #endif
194
195 #ifdef HAVE_OLD_SOCKOPT
196 #define sockopt_val_t char *
197 #else
198 #define sockopt_val_t void *
199 #endif