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