]> git.sur5r.net Git - openldap/blob - include/ac/socket.h
#ifdef for <arpa/inet.h>
[openldap] / include / ac / socket.h
1 /*
2  * Generic socket.h
3  */
4 /*
5  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms are permitted only
9  * as authorized by the OpenLDAP Public License.  A copy of this
10  * license is available at http://www.OpenLDAP.org/license.html or
11  * in file LICENSE in the top-level directory of the distribution.
12  */
13
14 #ifndef _AC_SOCKET_H_
15 #define _AC_SOCKET_H_
16
17 #ifdef HAVE_SYS_TYPES_H
18 #include <sys/types.h>
19 #endif
20
21 #ifdef HAVE_SYS_SOCKET_H
22 #include <sys/socket.h>
23
24 #ifdef HAVE_SYS_SELECT_H
25 #include <sys/select.h>
26 #endif
27
28 #include <netinet/in.h>
29
30 #ifdef HAVE_ARPA_INET_H
31 #include <arpa/inet.h>
32 #endif
33
34 #ifdef HAVE_ARPA_NAMESER_H
35 #include <arpa/nameser.h>
36 #endif
37
38 #include <netdb.h>
39
40 #ifdef HAVE_RESOLV_H
41 #include <resolv.h>
42 #endif
43
44 #endif /* HAVE_SYS_SOCKET_H */
45
46 #ifdef HAVE_WINSOCK2
47 #include <winsock2.h>
48 #elif HAVE_WINSOCK
49 #include <winsock.h>
50 #else
51 #define WSACleanup()
52 #endif
53
54 #ifdef HAVE_PCNFS
55 #include <tklib.h>
56 #endif /* HAVE_PCNFS */
57
58 #ifndef INADDR_LOOPBACK
59 #define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
60 #endif
61
62 #ifndef MAXHOSTNAMELEN
63 #define MAXHOSTNAMELEN  64
64 #endif
65
66 #ifdef MACOS
67 #define tcp_close( s )          tcpclose( s )
68 #else /* MACOS */
69 #ifdef DOS
70 #ifdef PCNFS
71 #define tcp_close( s )          close( s )
72 #endif /* PCNFS */
73 #ifdef NCSA
74 #define tcp_close( s )          netclose( s ); netshut()
75 #endif /* NCSA */
76 #ifdef WINSOCK
77 #define tcp_close( s )          closesocket( s );
78 #endif /* WINSOCK */
79 #else /* DOS */
80 #define tcp_close( s )          close( s )
81 #endif /* DOS */
82 #endif /* MACOS */
83
84 #if !defined(__alpha) || defined(VMS)
85 #define AC_HTONL( l ) htonl( l )
86 #define AC_NTOHL( l ) ntohl( l )
87 #else /* __alpha && !VMS */
88 /*
89  * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
90  * lower-order 32-bits of a (64-bit) long, so we define correct versions
91  * here.
92  */ 
93 #define AC_HTONL( l )   (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
94         | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
95
96 #define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
97         | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
98
99 #endif /* __alpha && !VMS */
100
101 #endif /* _AC_SOCKET_H_ */