Imported from ../bash-4.0-rc1.tar.gz.
[platform/upstream/bash.git] / lib / sh / netopen.c
index 76a389b..736d413 100644 (file)
@@ -5,23 +5,23 @@
  * chet@ins.CWRU.Edu
  */
 
-/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
-   Bash is free software; you can redistribute it and/or modify it
-   under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   Bash is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-   Bash 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 General Public
-   License for more details.
+   Bash 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 General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with Bash; see the file COPYING.  If not, write to the Free
-   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
 #include <config.h>
 
@@ -51,6 +51,8 @@
 #endif
 
 #include <bashansi.h>
+#include <bashintl.h>
+
 #include <errno.h>
 
 #include <shell.h>
@@ -65,6 +67,16 @@ extern int inet_aton __P((const char *, struct in_addr *));
 #endif
 
 #ifndef HAVE_GETADDRINFO
+static int _getaddr __P((char *, struct in_addr *));
+static int _getserv __P((char *, int, unsigned short *));
+static int _netopen4 __P((char *, char *, int));
+#else /* HAVE_GETADDRINFO */
+static int _netopen6 __P((char *, char *, int));
+#endif
+
+static int _netopen __P((char *, char *, int));
+
+#ifndef HAVE_GETADDRINFO
 /* Stuff the internet address corresponding to HOST into AP, in network
    byte order.  Return 1 on success, 0 on failure. */
 
@@ -107,7 +119,7 @@ _getserv (serv, proto, pp)
      int proto;
      unsigned short *pp;
 {
-  long l;
+  intmax_t l;
   unsigned short s;
 
   if (legal_number (serv, &l))
@@ -153,19 +165,19 @@ _netopen4(host, serv, typ)
 
   if (_getaddr(host, &ina) == 0)
     {
-      internal_error ("%s: host unknown", host);
+      internal_error (_("%s: host unknown"), host);
       errno = EINVAL;
       return -1;
     }
 
   if (_getserv(serv, typ, &p) == 0)
     {
-      internal_error("%s: invalid service", serv);
+      internal_error(_("%s: invalid service"), serv);
       errno = EINVAL;
       return -1;
     }
        
-  bzero ((char *)&sin, sizeof(sin));
+  memset ((char *)&sin, 0, sizeof(sin));
   sin.sin_family = AF_INET;
   sin.sin_port = p;
   sin.sin_addr = ina;
@@ -205,7 +217,7 @@ _netopen6 (host, serv, typ)
   struct addrinfo hints, *res, *res0;
   int gerr;
 
-  bzero ((char *)&hints, sizeof (hints));
+  memset ((char *)&hints, 0, sizeof (hints));
   /* XXX -- if problems with IPv6, set to PF_INET for IPv4 only */
 #ifdef DEBUG   /* PF_INET is the one that works for me */
   hints.ai_family = PF_INET;
@@ -291,7 +303,7 @@ netopen (path)
   t = strchr (s, '/');
   if (t == 0)
     {
-      internal_error ("%s: bad network path specification", path);
+      internal_error (_("%s: bad network path specification"), path);
       return -1;
     }
   *t++ = '\0';
@@ -331,7 +343,7 @@ int
 netopen (path)
      char *path;
 {
-  internal_error ("network operations not supported");
+  internal_error (_("network operations not supported"));
   return -1;
 }