]> git.sur5r.net Git - openldap/blobdiff - include/ac/socket.h
Import headers with updated notices
[openldap] / include / ac / socket.h
index 81b4895e8cb5b7b2a67134a04bc95b5163e2f34a..000fc3b88ae4dd5004c8e3b3d29937444783d5cf 100644 (file)
@@ -1,13 +1,14 @@
 /* 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
@@ -120,10 +126,15 @@ LBER_F( char * ) ber_pvt_wsa_err2string LDAP_P((int));
 #      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 
@@ -167,5 +178,29 @@ LDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
 #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_ */