]> git.sur5r.net Git - openldap/blob - include/ac/socket.h
Rework ac/socket.h for HAVE_WINSOCK:
[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 HAVE_WINSOCK
67 #       define tcp_close( s )           closesocket( s );
68 #       define ioctl( s, c, a )         ioctlsocket( (s), (c), (a) )
69 #elif MACOS
70 #       define tcp_close( s )           tcpclose( s )
71 #elif DOS
72 #       ifdef PCNFS
73 #               define tcp_close( s )   close( s )
74 #       endif /* PCNFS */
75 #       ifdef NCSA
76 #               define tcp_close( s )   do { netclose( s ); netshut() } while(0)
77 #       endif /* NCSA */
78 #else
79 #       define tcp_close( s )           close( s )
80 #endif /* MACOS */
81
82 #if !defined(__alpha) || defined(VMS)
83 #define AC_HTONL( l ) htonl( l )
84 #define AC_NTOHL( l ) ntohl( l )
85 #else /* __alpha && !VMS */
86 /*
87  * htonl and ntohl on the DEC Alpha under OSF 1 seem to only swap the
88  * lower-order 32-bits of a (64-bit) long, so we define correct versions
89  * here.
90  */ 
91 #define AC_HTONL( l )   (((long)htonl( (l) & 0x00000000FFFFFFFF )) << 32 \
92         | htonl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
93
94 #define AC_NTOHL( l ) (((long)ntohl( (l) & 0x00000000FFFFFFFF )) << 32 \
95         | ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
96
97 #endif /* __alpha && !VMS */
98
99 #endif /* _AC_SOCKET_H_ */