]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/mach/hurd/connect.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / mach / hurd / connect.c
index 019d1ea108c601f0202e71e35d101ea00dd7b85e..2014ec9828616c1aa642ee993bc0bfb6a93c3e4d 100644 (file)
@@ -1,22 +1,20 @@
-/* Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
-#include <ansidecl.h>
 #include <errno.h>
 #include <hurd.h>
 #include <hurd/fd.h>
@@ -24,24 +22,25 @@ Cambridge, MA 02139, USA.  */
 #include <hurd/socket.h>
 #include <sys/un.h>
 #include <hurd/ifsock.h>
+#include "hurd/hurdsocket.h"
 
 /* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
    For connectionless socket types, just set the default address to send to
    and the only address from which to accept transmissions.
    Return 0 on success, -1 for errors.  */
 int
-DEFUN(connect, (fd, addr, len),
-      int fd AND struct sockaddr *addr AND size_t len)
+__connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
 {
   error_t err;
   addr_port_t aport;
-  
-  if (addr->sa_family == AF_LOCAL)
+  const struct sockaddr_un *addr = addrarg.__sockaddr_un__;
+
+  if (addr->sun_family == AF_LOCAL)
     {
+      char *name = _hurd_sun_path_dupa (addr, len);
       /* For the local domain, we must look up the name as a file and talk
         to it with the ifsock protocol.  */
-      struct sockaddr_un *unaddr = (struct sockaddr_un *) addr;
-      file_t file = __file_name_lookup (unaddr->sun_path, 0, 0);
+      file_t file = __file_name_lookup (name, 0, 0);
       if (file == MACH_PORT_NULL)
        return -1;
       err = __ifsock_getsockaddr (file, &aport);
@@ -54,12 +53,12 @@ DEFUN(connect, (fd, addr, len),
     }
   else
     err = EIEIO;
-    
+
   err = HURD_DPORT_USE (fd,
                        ({
                          if (err)
                            err = __socket_create_address (port,
-                                                          addr->sa_family,
+                                                          addr->sun_family,
                                                           (char *) addr, len,
                                                           &aport);
                          if (! err)
@@ -73,3 +72,6 @@ DEFUN(connect, (fd, addr, len),
 
   return err ? __hurd_dfail (fd, err) : 0;
 }
+
+libc_hidden_def (__connect)
+weak_alias (__connect, connect)