]> git.sur5r.net Git - openldap/blob - include/ac/socket.h
Allow using real db1 on glibc 2.1 instead of the db1 compatiblity in db2.
[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_NETINET_TCP_H
31 #include <netinet/tcp.h>
32 #endif
33
34 #include <arpa/inet.h>
35
36 #ifdef HAVE_ARPA_NAMESER_H
37 #include <arpa/nameser.h>
38 #endif
39
40 #include <netdb.h>
41
42 #ifdef HAVE_RESOLV_H
43 #include <resolv.h>
44 #endif
45
46 #endif /* HAVE_SYS_SOCKET_H */
47
48 #ifdef HAVE_WINSOCK2
49 #include <winsock2.h>
50 #elif HAVE_WINSOCK
51 #include <winsock.h>
52 #else
53 #define WSACleanup()
54 #endif
55
56 #ifdef HAVE_PCNFS
57 #include <tklib.h>
58 #endif /* HAVE_PCNFS */
59
60 #ifndef INADDR_LOOPBACK
61 #define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
62 #endif
63
64 #ifndef MAXHOSTNAMELEN
65 #define MAXHOSTNAMELEN  64
66 #endif
67
68 #ifdef HAVE_CLOSESOCKET
69 # define tcp_close( s )         closesocket( s )
70 #elif defined( MACOS )
71 # define tcp_close( s )         tcpclose( s )
72 #elif defined( DOS )
73
74 # ifdef PCNFS
75 #  define tcp_close( s )                close( s )
76 # endif /* PCNFS */
77 # ifdef NCSA
78 #  define tcp_close( s )                netclose( s ); netshut()
79 # endif /* NCSA */
80 # ifdef WINSOCK
81 #  define tcp_close( s )                closesocket( s )
82 # endif /* WINSOCK */
83
84 #else
85 # define tcp_close( s )         close( s )
86 #endif
87
88 #if !defined(__alpha) || defined(VMS)
89 #define AC_HTONL( l ) htonl( l )
90 #define AC_NTOHL( l ) ntohl( l )
91 #else /* __alpha && !VMS */
92 /*
93  * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
94  * lower-order 32-bits of a (64-bit) long, so we define correct versions
95  * here.
96  */ 
97 #define AC_HTONL( l )   (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
98         | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
99
100 #define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
101         | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
102
103 #endif /* __alpha && !VMS */
104
105 #endif /* _AC_SOCKET_H_ */