]> git.sur5r.net Git - openldap/blob - include/ac/socket.h
Fix up socket.h
[openldap] / include / ac / socket.h
1 /*
2  * Generic socket.h
3  */
4
5 #ifndef _AC_SOCKET_H_
6 #define _AC_SOCKET_H_
7
8 #ifdef HAVE_SYS_TYPES_H
9 #include <sys/types.h>
10 #endif
11
12 #ifdef HAVE_SYS_SOCKET_H
13 #include <sys/socket.h>
14
15 #include <netinet/in.h>
16 #include <arpa/inet.h>
17 #include <arpa/nameser.h>
18 #include <netdb.h>
19 #include <resolv.h>
20 #endif
21
22 #ifdef HAVE_WINSOCK2
23 #include <winsock2.h>
24 #define EMSGSIZE WSAEMSGSIZE
25 #define EHOSTUNREACH WSAEHOSTUNREACH
26 #elif HAVE_WINSOCK
27 #include <winsock.h>
28 #endif
29
30 #ifdef HAVE_PCNFS
31 #include <tklib.h>
32 #endif /* HAVE_PCNFS */
33
34 #ifndef INADDR_LOOPBACK
35 #define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
36 #endif
37
38 #ifdef MACOS
39 #define tcp_close( s )          tcpclose( s )
40 #else /* MACOS */
41 #ifdef DOS
42 #ifdef PCNFS
43 #define tcp_close( s )          close( s )
44 #endif /* PCNFS */
45 #ifdef NCSA
46 #define tcp_close( s )          netclose( s ); netshut()
47 #endif /* NCSA */
48 #ifdef WINSOCK
49 #define tcp_close( s )          closesocket( s ); WSACleanup();
50 #endif /* WINSOCK */
51 #else /* DOS */
52 #define tcp_close( s )          close( s )
53 #endif /* DOS */
54 #endif /* MACOS */
55
56 #if !defined(__alpha) || defined(VMS)
57 #define AC_HTONL( l ) htonl( l )
58 #define AC_NTOHL( l ) ntohl( l )
59 #else /* __alpha && !VMS */
60 /*
61  * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
62  * lower-order 32-bits of a (64-bit) long, so we define correct versions
63  * here.
64  */ 
65 #define AC_HTONL( l )   (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
66         | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
67
68 #define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
69         | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
70
71 #endif /* __alpha && !VMS */
72
73
74 #endif /* _AC_SOCKET_H_ */