]> git.sur5r.net Git - openldap/blobdiff - include/ac/socket.h
Import headers with updated notices
[openldap] / include / ac / socket.h
index 5a141e0f0c5bca9fceef524da46df1235edae62e..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
@@ -92,7 +98,7 @@
 #define        sock_errno()    WSAGetLastError()
 #define        sock_errstr(e)  ber_pvt_wsa_err2string(e)
 
-LIBLBER_F (char *) ber_pvt_wsa_err2string LDAP_P((int));
+LBER_F( char * ) ber_pvt_wsa_err2string LDAP_P((int));
 
 #elif MACOS
 #      define tcp_close( s )           tcpclose( s )
@@ -120,10 +126,15 @@ LIBLBER_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 
@@ -148,7 +159,7 @@ LIBLBER_F (char *) ber_pvt_wsa_err2string LDAP_P((int));
 #if !defined( HAVE_INET_ATON ) && !defined( inet_aton )
 #define inet_aton ldap_pvt_inet_aton
 struct in_addr;
-LIBLDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
+LDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
 #endif
 
 #if    defined(__WIN32) && defined(_ALPHA)
@@ -167,5 +178,29 @@ LIBLDAP_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_ */