]> andersk Git - openssh.git/blob - defines.h
- Include macro for IN6_IS_ADDR_V4MAPPED. Report from
[openssh.git] / defines.h
1 #ifndef _DEFINES_H
2 #define _DEFINES_H
3
4 /* Necessary headers */
5
6 #include <sys/types.h> /* For [u]intxx_t */
7
8 #include <sys/socket.h> /* For SHUT_XXXX */
9
10 #include <netinet/in.h> /* For IPv6 macros */
11
12 #ifdef HAVE_SYS_BITYPES_H
13 # include <sys/bitypes.h> /* For u_intXX_t */
14 #endif 
15
16 #ifdef HAVE_PATHS_H
17 # include <paths.h> /* For _PATH_XXX */
18 #endif 
19
20 #ifdef HAVE_UTMP_H
21 # include <utmp.h> /* For _PATH_XXX */
22 #endif 
23
24 #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
25 # include <utmpx.h> /* For _PATH_XXX */
26 #endif 
27
28 #ifdef HAVE_SYS_TIME_H
29 # include <sys/time.h> /* For timersub */
30 #endif
31
32 #ifdef HAVE_MAILLOCK_H
33 # include <maillock.h> /* For _PATH_MAILDIR */
34 #endif
35
36 #ifdef HAVE_SYS_CDEFS_H
37 # include <sys/cdefs.h> /* For __P() */
38 #endif 
39
40 #ifdef HAVE_SYS_SYSMACROS_H
41 # include <sys/sysmacros.h> /* For MIN, MAX, etc */
42 #endif
43
44 /* Constants */
45
46 #ifndef SHUT_RDWR
47 enum
48 {
49   SHUT_RD = 0,          /* No more receptions.  */
50   SHUT_WR,                      /* No more transmissions.  */
51   SHUT_RDWR                     /* No more receptions or transmissions.  */
52 };
53 # define SHUT_RD   SHUT_RD
54 # define SHUT_WR   SHUT_WR
55 # define SHUT_RDWR SHUT_RDWR
56 #endif
57
58 /* Types */
59
60 /* If sys/types.h does not supply intXX_t, supply them ourselves */
61 /* (or die trying) */
62 #ifndef HAVE_INTXX_T
63 # if (SIZEOF_CHAR == 1)
64 typedef char int8_t;
65 # else
66 #  error "8 bit int type not found."
67 # endif
68 # if (SIZEOF_SHORT_INT == 2)
69 typedef short int int16_t;
70 # else
71 #  error "16 bit int type not found."
72 # endif
73 # if (SIZEOF_INT == 4)
74 typedef int int32_t;
75 # else
76 #  error "32 bit int type not found."
77 # endif
78 # if (SIZEOF_LONG_INT == 8)
79 typedef long int int64_t;
80 # else
81 #  if (SIZEOF_LONG_LONG_INT == 8)
82 typedef long long int int64_t;
83 #   define HAVE_INTXX_T 1
84 #  else
85 #   error "64 bit int type not found."
86 #  endif
87 # endif
88 #endif
89
90 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
91 #ifndef HAVE_U_INTXX_T
92 # ifdef HAVE_UINTXX_T
93 typedef uint8_t u_int8_t;
94 typedef uint16_t u_int16_t;
95 typedef uint32_t u_int32_t;
96 typedef  uint64_t u_int64_t;
97 # define HAVE_U_INTXX_T 1
98 # else
99 #  if (SIZEOF_CHAR == 1)
100 typedef unsigned char u_int8_t;
101 #  else
102 #   error "8 bit int type not found."
103 #  endif
104 #  if (SIZEOF_SHORT_INT == 2)
105 typedef unsigned short int u_int16_t;
106 #  else
107 #   error "16 bit int type not found."
108 #  endif
109 #  if (SIZEOF_INT == 4)
110 typedef unsigned int u_int32_t;
111 #  else
112 #   error "32 bit int type not found."
113 #  endif
114 #  if (SIZEOF_LONG_INT == 8)
115 typedef unsigned long int u_int64_t;
116 #  else
117 #   if (SIZEOF_LONG_LONG_INT == 8)
118 typedef unsigned long long int u_int64_t;
119 #    define HAVE_U_INTXX_T 1
120 #   else
121 #    error "64 bit int type not found."
122 #   endif
123 #  endif
124 # endif
125 #endif
126
127 #ifndef HAVE_SOCKLEN_T
128 typedef unsigned int socklen_t;
129 # define HAVE_SOCKLEN_T
130 #endif /* HAVE_SOCKLEN_T */
131
132 #ifndef HAVE_SIZE_T
133 typedef unsigned int size_t;
134 # define HAVE_SIZE_T
135 #endif /* HAVE_SIZE_T */
136
137 #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
138 # define ss_family __ss_family
139 #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
140
141 /* Paths */
142
143 /* If _PATH_LASTLOG is not defined by system headers, set it to the */
144 /* lastlog file detected by autoconf */
145 #ifndef _PATH_LASTLOG
146 # ifdef LASTLOG_LOCATION
147 #  define _PATH_LASTLOG LASTLOG_LOCATION
148 # endif
149 #endif
150
151 #ifndef _PATH_UTMP
152 # ifdef UTMP_FILE
153 #  define _PATH_UTMP UTMP_FILE
154 # else
155 #  define _PATH_UTMP "/var/adm/utmp"
156 # endif
157 #endif
158
159 #ifndef _PATH_WTMP
160 # ifdef WTMP_FILE
161 #  define _PATH_WTMP WTMP_FILE
162 # else
163 #  define _PATH_WTMP "/var/adm/wtmp"
164 # endif
165 #endif
166
167 #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
168 # ifndef _PATH_UTMPX
169 #  ifdef UTMPX_FILE
170 #   define _PATH_UTMPX UTMPX_FILE
171 #  else
172 #   define _PATH_UTMPX "/var/adm/utmpx"
173 #  endif
174 # endif
175 # ifndef _PATH_WTMPX
176 #  ifdef WTMPX_FILE
177 #   define _PATH_WTMPX WTMPX_FILE
178 #  else
179 #   define _PATH_WTMPX "/var/adm/wtmp"
180 #  endif
181 # endif
182 #endif
183
184 #ifndef _PATH_BSHELL
185 # define _PATH_BSHELL "/bin/sh"
186 #endif
187
188 #ifdef USER_PATH
189 # ifdef _PATH_STDPATH
190 #  undef _PATH_STDPATH
191 # endif
192 # define _PATH_STDPATH USER_PATH
193 #endif
194
195 #ifndef _PATH_STDPATH
196 # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
197 #endif
198
199 #ifndef _PATH_DEVNULL
200 # define _PATH_DEVNULL "/dev/null"
201 #endif
202
203 #ifndef MAILDIR
204 # define MAILDIR MAIL_DIRECTORY
205 #endif
206
207 #if !defined(_PATH_MAILDIR) && defined(MAILDIR)
208 # define _PATH_MAILDIR MAILDIR
209 #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */
210
211 #ifndef _PATH_RSH
212 # ifdef RSH_PATH
213 #  define _PATH_RSH RSH_PATH
214 # endif /* RSH_PATH */
215 #endif /* _PATH_RSH */
216
217 /* Macros */
218
219 #ifndef MAX
220 # define MAX(a,b) (((a)>(b))?(a):(b))
221 # define MIN(a,b) (((a)<(b))?(a):(b))
222 #endif
223
224 #ifndef timersub
225 #define timersub(a, b, result)                                                                            \
226    do {                                                                                                                                           \
227       (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;           \
228       (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;        \
229       if ((result)->tv_usec < 0) {                            \
230          --(result)->tv_sec;                                  \
231          (result)->tv_usec += 1000000;                        \
232       }                                                       \
233    } while (0)
234 #endif
235
236 #ifndef __P
237 # define __P(x) x
238 #endif
239
240 #if !defined(IN6_IS_ADDR_V4MAPPED)
241 # define IN6_IS_ADDR_V4MAPPED(a) \
242         ((((uint32_t *) (a))[0] == 0) && (((uint32_t *) (a))[1] == 0) && \
243          (((uint32_t *) (a))[2] == htonl (0xffff)))
244 #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */
245
246 #if !defined(__GNUC__) || (__GNUC__ < 2)
247 # define __attribute__(x)
248 #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
249
250 #if defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM)
251 # define USE_PAM
252 #endif /* defined(HAVE_SECURITY_PAM_APPL_H) && !defined(DISABLE_PAM) */
253
254 /* Function replacement / compatibility hacks */
255
256 /* In older versions of libpam, pam_strerror takes a single argument */
257 #ifdef HAVE_OLD_PAM
258 # define PAM_STRERROR(a,b) pam_strerror((b))
259 #else
260 # define PAM_STRERROR(a,b) pam_strerror((a),(b))
261 #endif
262
263 #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO)
264 # undef HAVE_GETADDRINFO
265 #endif /* defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) */
266
267 #endif /* _DEFINES_H */
This page took 0.082741 seconds and 5 git commands to generate.