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