/* Generic socket.h */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
+ * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
- * Redistribution and use in source and binary forms are permitted only
- * as authorized by the OpenLDAP Public License. A copy of this
- * license is available at http://www.OpenLDAP.org/license.html or
- * in file LICENSE in the top-level directory of the distribution.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License. A copy of this license is available at
+ * http://www.OpenLDAP.org/license.html or in file LICENSE in the
+ * top-level directory of the distribution.
*/
#ifndef _AC_SOCKET_H_
#define sock_errstr(e) STRERROR(e)
#ifdef HAVE_WINSOCK
-# define tcp_close( s ) closesocket( s )
# define tcp_read( s, buf, len ) recv( s, buf, len, 0 )
# define tcp_write( s, buf, len ) send( s, buf, len, 0 )
# define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) )
# define ioctl_t u_long
# define AC_SOCKET_INVALID ((unsigned int) ~0)
+# if SD_BOTH
+# define tcp_close( s ) (shutdown( s, SD_BOTH ), closesocket( s ))
+#else
+# define tcp_close( s ) closesocket( s )
+#endif
+
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define ETIMEDOUT WSAETIMEDOUT
# endif
#else
-# define tcp_close( s ) close( s )
# define tcp_read( s, buf, len) read( s, buf, len )
# define tcp_write( s, buf, len) write( s, buf, len )
+# if SHUT_RDWR
+# define tcp_close( s ) (shutdown( s, SHUT_RDWR ), close( s ))
+#else
+# define tcp_close( s ) close( s )
+#endif
+
#ifdef HAVE_PIPE
/*
* Only use pipe() on systems where file and socket descriptors
#define AC_HTONS( s ) htons( s )
#define AC_NTOHS( s ) ntohs( s )
+#ifdef LDAP_PF_LOCAL
+# if !defined( AF_LOCAL ) && defined( AF_UNIX )
+# define AF_LOCAL AF_UNIX
+# endif
+# if !defined( PF_LOCAL ) && defined( PF_UNIX )
+# define PF_LOCAL PF_UNIX
+# endif
+#endif
+
+#ifndef INET_ADDRSTRLEN
+# define INET_ADDRSTRLEN 16
+#endif
+#ifndef INET6_ADDRSTRLEN
+# define INET6_ADDRSTRLEN 46
+#endif
+
+#ifdef HAVE_GETADDRINFO
+# ifdef HAVE_GAI_STRERROR
+# define AC_GAI_STRERROR(x) (gai_strerror((x)))
+# else
+# define AC_GAI_STRERROR(x) (ldap_pvt_gai_strerror((x)))
+ char * ldap_pvt_gai_strerror( int );
+# endif
+#endif
#endif /* _AC_SOCKET_H_ */