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