• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2dnl This comes from libcurl's acinclude.m4.  it is not clear if this
3dnl is original libcurl code, or other code, so we include the libcurl
4dnl copyright here
5dnl
6dnl
7dnl Copyright (c) 1996 - 2005, Daniel Stenberg, <daniel@haxx.se>.
8dnl
9dnl All rights reserved.
10dnl
11dnl Permission to use, copy, modify, and distribute this software for any purpose
12dnl with or without fee is hereby granted, provided that the above copyright
13dnl notice and this permission notice appear in all copies.
14dnl
15dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
18dnl NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21dnl OR OTHER DEALINGS IN THE SOFTWARE.
22dnl
23dnl Except as contained in this notice, the name of a copyright holder shall not
24dnl be used in advertising or otherwise to promote the sale, use or other dealings
25dnl in this Software without prior written authorization of the copyright holder.
26
27dnl Check for socklen_t: historically on BSD it is an int, and in
28dnl POSIX 1g it is a type of its own, but some platforms use different
29dnl types for the argument to getsockopt, getpeername, etc.  So we
30dnl have to test to find something that will work.
31
32dnl Remove the AC_CHECK_TYPE - on HP-UX it would find a socklen_t, but the
33dnl function prototypes for getsockopt et al will not actually use
34dnl socklen_t args unless _XOPEN_SOURCE_EXTENDED is defined. so, the
35dnl AC_CHECK_TYPE will find a socklen_t and think all is happiness and
36dnl joy when you will really get warnings about mismatch types - type
37dnl mismatches that would be possibly Bad (tm) in a 64-bit compile.
38dnl raj 2005-05-11 this change may be redistributed at will
39
40dnl also, added "extern" to the "int getpeername" in an attempt to resolve
41dnl an issue with this code under Solaris 2.9.  this too may be
42dnl redistributed at will
43
44
45AC_DEFUN([OLD_TYPE_SOCKLEN_T],
46[
47      AC_MSG_CHECKING([for socklen_t equivalent])
48      AC_CACHE_VAL([curl_cv_socklen_t_equiv],
49      [
50         # Systems have either "struct sockaddr *" or
51         # "void *" as the second argument to getpeername
52         curl_cv_socklen_t_equiv=
53         for arg2 in "struct sockaddr" void; do
54            for t in int size_t unsigned long "unsigned long" socklen_t; do
55               AC_TRY_COMPILE([
56                  #ifdef HAVE_SYS_TYPES_H
57                  #include <sys/types.h>
58                  #endif
59                  #ifdef HAVE_SYS_SOCKET_H
60                  #include <sys/socket.h>
61                  #endif
62
63                  extern int getpeername (int, $arg2 *, $t *);
64               ],[
65                  $t len;
66                  getpeername(0,0,&len);
67               ],[
68                  curl_cv_socklen_t_equiv="$t"
69                  break 2
70               ])
71            done
72         done
73
74         if test "x$curl_cv_socklen_t_equiv" = x; then
75        # take a wild guess
76            curl_cv_socklen_t_equiv="socklen_t"
77            AC_MSG_WARN([Cannot find a type to use in place of socklen_t, guessing socklen_t])
78         fi
79      ])
80      AC_MSG_RESULT($curl_cv_socklen_t_equiv)
81      AC_DEFINE_UNQUOTED(netperf_socklen_t, $curl_cv_socklen_t_equiv,
82                        [type to use in place of socklen_t if not defined])
83])
84
85
86dnl *
87dnl * Copyright (c) 2001  Motoyuki Kasahara
88dnl *
89dnl * Redistribution and use in source and binary forms, with or without
90dnl * modification, are permitted provided that the following conditions
91dnl * are met:
92dnl * 1. Redistributions of source code must retain the above copyright
93dnl *    notice, this list of conditions and the following disclaimer.
94dnl * 2. Redistributions in binary form must reproduce the above copyright
95dnl *    notice, this list of conditions and the following disclaimer in the
96dnl *    documentation and/or other materials provided with the distribution.
97dnl * 3. Neither the name of the project nor the names of its contributors
98dnl *    may be used to endorse or promote products derived from this software
99dnl *    without specific prior written permission.
100dnl *
101dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
102dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
103dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
104dnl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE
105dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
106dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
107dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
108dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
109dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
110dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
111dnl * THE POSSIBILITY OF SUCH DAMAGE.
112dnl *
113
114dnl *
115dnl * Check for h_errno.
116dnl *
117AC_DEFUN([AC_DECL_H_ERRNO],
118[AC_CACHE_CHECK(for h_errno declaration in netdb.h, ac_cv_decl_h_errno,
119[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
120#include <netdb.h>]], [[
121h_errno = 0;
122]])],[ac_cv_decl_h_errno=yes],[ac_cv_decl_h_errno=no])])
123if test "$ac_cv_decl_h_errno" = yes; then
124    AC_DEFINE(H_ERRNO_DECLARED, 1,
125[Define to 1 if `h_errno' is declared by <netdb.h>])
126fi])
127
128dnl *
129dnl * Copyright (c) 2001  Motoyuki Kasahara
130dnl *
131dnl * Redistribution and use in source and binary forms, with or without
132dnl * modification, are permitted provided that the following conditions
133dnl * are met:
134dnl * 1. Redistributions of source code must retain the above copyright
135dnl *    notice, this list of conditions and the following disclaimer.
136dnl * 2. Redistributions in binary form must reproduce the above copyright
137dnl *    notice, this list of conditions and the following disclaimer in the
138dnl *    documentation and/or other materials provided with the distribution.
139dnl * 3. Neither the name of the project nor the names of its contributors
140dnl *    may be used to endorse or promote products derived from this software
141dnl *    without specific prior written permission.
142dnl *
143dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
144dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
145dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
146dnl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE
147dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
148dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
149dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
150dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
151dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
152dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
153dnl * THE POSSIBILITY OF SUCH DAMAGE.
154dnl *
155
156dnl *
157dnl * Check for struct sockaddr_in6
158dnl *
159AC_DEFUN([AC_STRUCT_SOCKADDR_IN6],
160[AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6,
161[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
162#include <sys/types.h>
163#include <sys/socket.h>
164#include <netinet/in.h>]], [[
165struct sockaddr_in6 address;
166]])],[ac_cv_struct_sockaddr_in6=yes],[ac_cv_struct_sockaddr_in6=no])])
167if test "$ac_cv_struct_sockaddr_in6" = yes; then
168    AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1,
169[Define to 1 if <netinet/in.h> defines `struct sockaddr_in6'])
170fi])
171
172dnl *
173dnl * Check for struct sockaddr_storage
174dnl *
175AC_DEFUN([AC_STRUCT_SOCKADDR_STORAGE],
176[AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage,
177[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
178#include <sys/types.h>
179#include <sys/socket.h>
180#include <netinet/in.h>]], [[
181struct sockaddr_storage address;
182]])],[ac_cv_struct_sockaddr_storage=yes],[ac_cv_struct_sockaddr_storage=no])])
183if test "$ac_cv_struct_sockaddr_storage" = yes; then
184    AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
185[Define to 1 if <netinet/in.h> defines `struct sockaddr_storage'])
186fi])
187
188dnl *
189dnl * Copyright (c) 2001, 2003  Motoyuki Kasahara
190dnl *
191dnl * Redistribution and use in source and binary forms, with or without
192dnl * modification, are permitted provided that the following conditions
193dnl * are met:
194dnl * 1. Redistributions of source code must retain the above copyright
195dnl *    notice, this list of conditions and the following disclaimer.
196dnl * 2. Redistributions in binary form must reproduce the above copyright
197dnl *    notice, this list of conditions and the following disclaimer in the
198dnl *    documentation and/or other materials provided with the distribution.
199dnl * 3. Neither the name of the project nor the names of its contributors
200dnl *    may be used to endorse or promote products derived from this software
201dnl *    without specific prior written permission.
202dnl *
203dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
204dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
205dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
206dnl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE
207dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
208dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
209dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
210dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
211dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
212dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
213dnl * THE POSSIBILITY OF SUCH DAMAGE.
214dnl *
215
216dnl *
217dnl * Check for socklen_t.
218dnl *
219AC_DEFUN([AC_TYPE_SOCKLEN_T],
220[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
221[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
222#include <sys/types.h>
223#include <sys/socket.h>]], [[
224socklen_t socklen;
225]])],[ac_cv_type_socklen_t=yes],[ac_cv_type_socklen_t=no])])
226if test "$ac_cv_type_socklen_t" != yes; then
227    AC_DEFINE(socklen_t, int,
228[Define to `int' if <sys/types.h> or <sys/socket.h> does not define.])
229fi])
230
231dnl *
232dnl * Check for in_port_t.
233dnl *
234AC_DEFUN([AC_TYPE_IN_PORT_T],
235[AC_CACHE_CHECK([for in_port_t], ac_cv_type_in_port_t,
236[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
237#include <sys/types.h>
238#include <sys/socket.h>
239#include <netinet/in.h>]], [[
240in_port_t in_port;
241]])],[ac_cv_type_in_port_t=yes],[ac_cv_type_in_port_t=no])])
242if test "$ac_cv_type_in_port_t" != yes; then
243    ac_cv_sin_port_size=unknown
244    AC_RUN_IFELSE([AC_LANG_SOURCE([[
245    #include <sys/types.h>
246    #include <sys/socket.h>
247    #include <netinet/in.h>
248    int main() {
249	struct sockaddr_in addr;
250	return (sizeof(addr.sin_port) == sizeof(long)) ? 0 : 1;
251    }
252    ]])],[ac_cv_sin_port_size=long],[],[])
253    AC_RUN_IFELSE([AC_LANG_SOURCE([[
254    #include <sys/types.h>
255    #include <sys/socket.h>
256    #include <netinet/in.h>
257    int main() {
258	struct sockaddr_in addr;
259	return (sizeof(addr.sin_port) == sizeof(int)) ? 0 : 1;
260    }
261    ]])],[ac_cv_sin_port_size=int],[],[])
262    AC_RUN_IFELSE([AC_LANG_SOURCE([[
263    #include <sys/types.h>
264    #include <sys/socket.h>
265    #include <netinet/in.h>
266    int main() {
267	struct sockaddr_in addr;
268	return (sizeof(addr.sin_port) == sizeof(short)) ? 0 : 1;
269    }
270    ]])],[ac_cv_sin_port_size=short],[],[])
271    AC_RUN_IFELSE([AC_LANG_SOURCE([[
272    #include <sys/types.h>
273    #include <sys/socket.h>
274    #include <netinet/in.h>
275    int main() {
276	struct sockaddr_in addr;
277	return (sizeof(addr.sin_port) == sizeof(char)) ? 0 : 1;
278    }
279    ]])],[ac_cv_sin_port_size=char],[],[])
280    if test "$ac_cv_sin_port_size" = unknown; then
281	AC_MSG_ERROR([Failed to get size of sin_port in struct sockaddr_in.])
282    fi
283    AC_DEFINE_UNQUOTED(in_port_t, unsigned $ac_cv_sin_port_size,
284[Define to `unsigned char', `unsigned short', `unsigned int' or
285`unsigned long' according with size of `sin_port' in `struct sockaddr_in',
286if <sys/types.h>, <sys/socket.h> or <netinet/in.h> does not define
287`in_port_t'.])
288fi])
289
290dnl *
291dnl * Check for sa_family_t.
292dnl *
293AC_DEFUN([AC_TYPE_SA_FAMILY_T],
294[AC_CACHE_CHECK([for sa_family_t], ac_cv_type_sa_family_t,
295[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
296#include <sys/types.h>
297#include <sys/socket.h>]], [[
298sa_family_t sa_family;
299]])],[ac_cv_type_sa_family_t=yes],[ac_cv_type_sa_family_t=no])])
300if test "$ac_cv_type_sa_family_t" != yes; then
301    ac_cv_sa_family_size=unknown
302    AC_RUN_IFELSE([AC_LANG_SOURCE([[
303    #include <sys/types.h>
304    #include <sys/socket.h>
305    int main() {
306	struct sockaddr addr;
307	return (sizeof(addr.sa_family) == sizeof(long)) ? 0 : 1;
308    }
309    ]])],[ac_cv_sa_family_size=long],[],[])
310    AC_RUN_IFELSE([AC_LANG_SOURCE([[
311    #include <sys/types.h>
312    #include <sys/socket.h>
313    int main() {
314	struct sockaddr addr;
315	return (sizeof(addr.sa_family) == sizeof(int)) ? 0 : 1;
316    }
317    ]])],[ac_cv_sa_family_size=int],[],[])
318    AC_RUN_IFELSE([AC_LANG_SOURCE([[
319    #include <sys/types.h>
320    #include <sys/socket.h>
321    int main() {
322	struct sockaddr addr;
323	return (sizeof(addr.sa_family) == sizeof(short)) ? 0 : 1;
324    }
325    ]])],[ac_cv_sa_family_size=short],[],[])
326    AC_RUN_IFELSE([AC_LANG_SOURCE([[
327    #include <sys/types.h>
328    #include <sys/socket.h>
329    int main() {
330	struct sockaddr addr;
331	return (sizeof(addr.sa_family) == sizeof(char)) ? 0 : 1;
332    }
333    ]])],[ac_cv_sa_family_size=char],[],[])
334    if test "$ac_cv_sa_family_size" = unknown; then
335	AC_MSG_ERROR([Failed to get size of sa_family in struct sockaddr.])
336    fi
337    AC_DEFINE_UNQUOTED(sa_family_t, unsigned $ac_cv_sa_family_size,
338[Define to `unsigned char', `unsigned short', `unsigned int' or
339`unsigned long' according with size of `sa_family' in `struct sockaddr',
340if <sys/types.h> or <sys/socket.h> does not define `sa_family_t'.])
341fi])
342