]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/bc_types.h
Important protocol change -- see kes29Oct02
[bacula/bacula] / bacula / src / bc_types.h
1 /*
2     Integer types.  These types should be be used in all
3     contexts in which the length of an integer stored on
4     removable media must be known regardless of the
5     architecture of the platform.
6
7     Bacula types are:
8
9     int8_t,  int16_t,  int32_t,  int64_t
10     uint8_t, uint16_t, uint32_t, uint64_t
11     float32_t, float64_t
12
13     Also, we define types such as file address lengths.
14
15     Version $Id$
16
17  */
18 /*
19    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
20
21    This program is free software; you can redistribute it and/or
22    modify it under the terms of the GNU General Public License as
23    published by the Free Software Foundation; either version 2 of
24    the License, or (at your option) any later version.
25
26    This program is distributed in the hope that it will be useful,
27    but WITHOUT ANY WARRANTY; without even the implied warranty of
28    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29    General Public License for more details.
30
31    You should have received a copy of the GNU General Public
32    License along with this program; if not, write to the Free
33    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
34    MA 02111-1307, USA.
35
36  */
37
38
39 #ifndef __bc_types_INCLUDED
40 #define __bc_types_INCLUDED
41
42 /* ****FIXME***** implement 64 bit file addresses ! */
43 #define faddr_t long 
44
45 typedef char POOLMEM;
46
47 /* Types */
48
49 /* If sys/types.h does not supply intXX_t, supply them ourselves */
50 /* (or die trying) */
51
52 #ifndef HAVE_U_INT
53 typedef unsigned int u_int;
54 #endif
55
56 #ifndef HAVE_INTXX_T
57 # if (SIZEOF_CHAR == 1)
58 typedef char int8_t;
59 # else
60 #  error "8 bit int type not found."
61 # endif
62 # if (SIZEOF_SHORT_INT == 2)
63 typedef short int int16_t;
64 # else
65 #  error "16 bit int type not found."
66 # endif
67 # if (SIZEOF_INT == 4)
68 typedef int int32_t;
69 # else
70 #  error "32 bit int type not found."
71 # endif
72 #endif
73
74 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
75 #ifndef HAVE_U_INTXX_T
76 # ifdef HAVE_UINTXX_T
77 typedef uint8_t u_int8_t;
78 typedef uint16_t u_int16_t;
79 typedef uint32_t u_int32_t;
80 # define HAVE_U_INTXX_T 1
81 # else
82 #  if (SIZEOF_CHAR == 1)
83 typedef unsigned char u_int8_t;
84 #  else
85 #   error "8 bit int type not found. Required!"
86 #  endif
87 #  if (SIZEOF_SHORT_INT == 2)
88 typedef unsigned short int u_int16_t;
89 #  else
90 #   error "16 bit int type not found. Required!"
91 #  endif
92 #  if (SIZEOF_INT == 4)
93 typedef unsigned int u_int32_t;
94 #  else
95 #   error "32 bit int type not found. Required!"
96 #  endif
97 # endif
98 #endif
99
100 /* 64-bit types */
101 #ifndef HAVE_INT64_T
102 # if (SIZEOF_LONG_LONG_INT == 8)
103 typedef long long int int64_t;
104 #   define HAVE_INT64_T 1
105 # else
106 #  if (SIZEOF_LONG_INT == 8)
107 typedef long int int64_t;
108 #   define HAVE_INT64_T 1
109 #  endif
110 # endif
111 #endif
112
113 #ifndef HAVE_INTMAX_T
114 # ifdef HAVE_INT64_T
115 typedef int64_t intmax_t;
116 # else
117 #   error "64 bit type not found. Required!"
118 # endif
119 #endif
120
121 #ifndef HAVE_U_INT64_T
122 # if (SIZEOF_LONG_LONG_INT == 8)
123 typedef unsigned long long int u_int64_t;
124 #   define HAVE_U_INT64_T 1
125 # else
126 #  if (SIZEOF_LONG_INT == 8)
127 typedef unsigned long int u_int64_t;
128 #   define HAVE_U_INT64_T 1
129 #  else
130 #   error "64 bit type not found. Required!"
131 #  endif
132 # endif
133 #endif
134
135 #ifndef HAVE_U_INTMAX_T
136 # ifdef HAVE_U_INT64_T
137 typedef u_int64_t u_intmax_t;
138 # else
139 #   error "64 bit type not found. Required!"
140 # endif
141 #endif
142
143
144 /* Limits for the above types. */
145 #undef INT8_MIN  
146 #undef INT8_MAX  
147 #undef UINT8_MAX 
148 #undef INT16_MIN 
149 #undef INT16_MAX 
150 #undef UINT16_MAX
151 #undef INT32_MIN 
152 #undef INT32_MAX 
153 #undef UINT32_MAX
154
155 #define INT8_MIN        (-127-1)
156 #define INT8_MAX        (127)
157 #define UINT8_MAX       (255u)
158 #define INT16_MIN       (-32767-1)
159 #define INT16_MAX       (32767)
160 #define UINT16_MAX      (65535u)
161 #define INT32_MIN       (-2147483647-1)
162 #define INT32_MAX       (2147483647)
163 #define UINT32_MAX      (4294967295u)
164
165 typedef double            float64_t;
166 typedef float             float32_t;
167
168 #endif /* __bc_types_INCLUDED */
169
170 /* Define the uint versions actually used in Bacula */
171 #define uint8_t u_int8_t
172 #define uint16_t u_int16_t
173 #define uint32_t u_int32_t
174 #define uint64_t u_int64_t
175 #define uintmax_t u_intmax_t
176
177 #define btime_t uint64_t
178
179 #ifdef HAVE_CYGWIN
180 #define socklen_t int
181 #endif