pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/39532: bootstrap fails under Interix (libfetch fails)



The following reply was made to PR pkg/39532; it has been noted by GNATS.

From: Joerg Sonnenberger <joerg%britannica.bec.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: cheusov%tut.by@localhost
Subject: Re: pkg/39532: bootstrap fails under Interix (libfetch fails)
Date: Wed, 17 Sep 2008 23:09:55 +0200

 --C7zPtVaVf+AK4Oqc
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Sat, Sep 13, 2008 at 12:55:00PM +0000, cheusov%tut.by@localhost wrote:
 > >Description:
 > bootstrap fails under Interix due to libfetch.
 
 Try the two attached patches. The first adds glue for libnbcompat to
 build some more fallback functions, the second changes libfetch to use
 it. The diffs have some unrelated changes, but that's a separate issue.
 
 Joerg
 
 --C7zPtVaVf+AK4Oqc
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="libfetch.diff"
 
 Index: Makefile
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/net/libfetch/Makefile,v
 retrieving revision 1.18
 diff -u -p -r1.18 Makefile
 --- Makefile   21 Aug 2008 15:22:45 -0000      1.18
 +++ Makefile   17 Sep 2008 19:58:35 -0000
 @@ -1,7 +1,7 @@
  # $NetBSD: Makefile,v 1.18 2008/08/21 15:22:45 joerg Exp $
  #
  
 -DISTNAME=     libfetch-2.15
 +DISTNAME=     libfetch-2.16
  CATEGORIES=   net
  MASTER_SITES= # empty
  DISTFILES=    # empty
 Index: files/common.c
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/net/libfetch/files/common.c,v
 retrieving revision 1.13
 diff -u -p -r1.13 common.c
 --- files/common.c     9 May 2008 00:39:06 -0000       1.13
 +++ files/common.c     17 Sep 2008 21:01:25 -0000
 @@ -30,6 +30,11 @@
   * $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $
   */
  
 +#if HAVE_CONFIG_H
 +#include "config.h"
 +#endif
 +#include <nbcompat.h>
 +
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <sys/time.h>
 @@ -40,7 +45,7 @@
  #include <ctype.h>
  #include <errno.h>
  #include <inttypes.h>
 -#include <netdb.h>
 +#include <nbcompat/netdb.h>
  #include <pwd.h>
  #include <stdarg.h>
  #include <stdlib.h>
 @@ -385,17 +390,19 @@ fetch_read(conn_t *conn, char *buf, size
  {
        struct timeval now, timeout, waittv;
        fd_set readfds;
 -      ssize_t rlen, total;
 +      ssize_t rlen;
        int r;
  
 +      if (len == 0)
 +              return 0;
 +
        if (fetchTimeout) {
                FD_ZERO(&readfds);
                gettimeofday(&timeout, NULL);
                timeout.tv_sec += fetchTimeout;
        }
  
 -      total = 0;
 -      while (len > 0) {
 +      for (;;) {
                while (fetchTimeout && !FD_ISSET(conn->sd, &readfds)) {
                        FD_SET(conn->sd, &readfds);
                        gettimeofday(&now, NULL);
 @@ -425,18 +432,13 @@ fetch_read(conn_t *conn, char *buf, size
                else
  #endif
                        rlen = read(conn->sd, buf, len);
 -              if (rlen == 0)
 +              if (rlen >= 0)
                        break;
 -              if (rlen < 0) {
 -                      if (errno == EINTR && fetchRestartCalls)
 -                              continue;
 +      
 +              if (errno != EINTR || !fetchRestartCalls)
                        return (-1);
 -              }
 -              len -= rlen;
 -              buf += rlen;
 -              total += rlen;
        }
 -      return (total);
 +      return (rlen);
  }
  
  
 @@ -451,7 +453,7 @@ fetch_getln(conn_t *conn)
        char *tmp;
        size_t tmpsize;
        ssize_t len;
 -      char c;
 +      int done;
  
        if (conn->buf == NULL) {
                if ((conn->buf = malloc(MIN_BUF_SIZE)) == NULL) {
 @@ -465,12 +467,14 @@ fetch_getln(conn_t *conn)
        conn->buflen = 0;
  
        do {
 -              len = fetch_read(conn, &c, 1);
 +              len = fetch_read(conn, conn->buf + conn->buflen,
 +                  conn->bufsize - conn->buflen);
                if (len == -1)
                        return (-1);
                if (len == 0)
                        break;
 -              conn->buf[conn->buflen++] = c;
 +              done = memchr(conn->buf + conn->buflen, '\n', len) != NULL;
 +              conn->buflen += len;
                if (conn->buflen == conn->bufsize) {
                        tmp = conn->buf;
                        tmpsize = conn->bufsize * 2 + 1;
 @@ -481,7 +485,7 @@ fetch_getln(conn_t *conn)
                        conn->buf = tmp;
                        conn->bufsize = tmpsize;
                }
 -      } while (c != '\n');
 +      } while (!done);
  
        conn->buf[conn->buflen] = '\0';
        return (0);
 Index: files/fetch.c
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/net/libfetch/files/fetch.c,v
 retrieving revision 1.12
 diff -u -p -r1.12 fetch.c
 --- files/fetch.c      26 Apr 2008 22:42:49 -0000      1.12
 +++ files/fetch.c      17 Sep 2008 21:01:46 -0000
 @@ -30,6 +30,11 @@
   * $FreeBSD: fetch.c,v 1.41 2007/12/19 00:26:36 des Exp $
   */
  
 +#if HAVE_CONFIG_H
 +#include "config.h"
 +#endif
 +#include <nbcompat.h>
 +
  #include <ctype.h>
  #include <errno.h>
  #include <stdio.h>
 Index: files/file.c
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/net/libfetch/files/file.c,v
 retrieving revision 1.11
 diff -u -p -r1.11 file.c
 --- files/file.c       25 Apr 2008 16:25:25 -0000      1.11
 +++ files/file.c       17 Sep 2008 21:01:40 -0000
 @@ -30,6 +30,11 @@
   * $FreeBSD: file.c,v 1.18 2007/12/14 10:26:58 des Exp $
   */
  
 +#if HAVE_CONFIG_H
 +#include "config.h"
 +#endif
 +#include <nbcompat.h>
 +
  #include <sys/stat.h>
  
  #include <dirent.h>
 Index: files/ftp.c
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/net/libfetch/files/ftp.c,v
 retrieving revision 1.22
 diff -u -p -r1.22 ftp.c
 --- files/ftp.c        25 Apr 2008 16:25:25 -0000      1.22
 +++ files/ftp.c        17 Sep 2008 20:49:35 -0000
 @@ -70,7 +70,7 @@
  #include <errno.h>
  #include <fcntl.h>
  #include <inttypes.h>
 -#include <netdb.h>
 +#include <nbcompat/netdb.h>
  #include <stdarg.h>
  #ifndef NETBSD
  #include <nbcompat/stdio.h>
 Index: files/http.c
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/net/libfetch/files/http.c,v
 retrieving revision 1.19
 diff -u -p -r1.19 http.c
 --- files/http.c       6 May 2008 17:37:30 -0000       1.19
 +++ files/http.c       17 Sep 2008 20:49:39 -0000
 @@ -79,7 +79,7 @@
  #include <ctype.h>
  #include <errno.h>
  #include <locale.h>
 -#include <netdb.h>
 +#include <nbcompat/netdb.h>
  #include <stdarg.h>
  #ifndef NETBSD
  #include <nbcompat/stdio.h>
 @@ -232,9 +232,12 @@ http_fillbuf(struct httpio *io, size_t l
  
        if (io->chunksize == 0) {
                char endl[2];
 +              ssize_t len2;
  
 -              if (fetch_read(io->conn, endl, 2) != 2 ||
 -                  endl[0] != '\r' || endl[1] != '\n')
 +              len2 = fetch_read(io->conn, endl, 2);
 +              if (len2 == 1 && fetch_read(io->conn, endl + 1, 1) != 1)
 +                      return (-1);
 +              if (len2 == -1 || endl[0] != '\r' || endl[1] != '\n')
                        return (-1);
        }
  
 
 --C7zPtVaVf+AK4Oqc
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="libnbcompat.diff"
 
 Index: Makefile
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/pkgtools/libnbcompat/Makefile,v
 retrieving revision 1.63
 diff -u -p -r1.63 Makefile
 --- Makefile   8 Sep 2008 20:20:22 -0000       1.63
 +++ Makefile   17 Sep 2008 20:55:12 -0000
 @@ -14,12 +14,10 @@ MAINTAINER=                grant%NetBSD.org@localhost
  HOMEPAGE=             http://www.NetBSD.org/
  COMMENT=              Portable NetBSD compatibility library
  
 -NO_PKGTOOLS_REQD_CHECK=       yes
 -NO_CHECKSUM=          yes
 -NO_MTREE=             yes
 +PKG_DESTDIR_SUPPORT=  user-destdir
  
  GNU_CONFIGURE=                yes
 -MAKE_ENV+=            BINMODE=${BINMODE}
 +MAKE_ENV+=            LIBMODE=${LIBMODE}
  
  do-extract:
        @${CP} -R ${FILESDIR} ${WRKSRC}
 Index: PLIST
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/pkgtools/libnbcompat/PLIST,v
 retrieving revision 1.14
 diff -u -p -r1.14 PLIST
 --- PLIST      7 May 2007 16:38:47 -0000       1.14
 +++ PLIST      17 Sep 2008 20:49:53 -0000
 @@ -15,6 +15,7 @@ include/nbcompat/limits.h
  include/nbcompat/md5.h
  include/nbcompat/nbconfig.h
  include/nbcompat/nbtypes.h
 +include/nbcompat/netdb.h
  include/nbcompat/param.h
  include/nbcompat/paths.h
  include/nbcompat/poll.h
 Index: files/Makefile.in
 ===================================================================
 RCS file: 
/home/joerg/repo/netbsd/pkgsrc/pkgtools/libnbcompat/files/Makefile.in,v
 retrieving revision 1.33
 diff -u -p -r1.33 Makefile.in
 --- files/Makefile.in  7 May 2007 16:38:47 -0000       1.33
 +++ files/Makefile.in  17 Sep 2008 20:55:02 -0000
 @@ -12,7 +12,7 @@ CFLAGS=              -I$(srcdir) -I. @INCLUDES@ @CFL
  CPPFLAGS=     @CPPFLAGS@
  DEFS=         @DEFS@
  INSTALL=      @INSTALL@
 -BINMODE?=     555
 +LIBMODE?=     644
  LDFLAGS=      @LDFLAGS@
  
  AWK=          @AWK@
 @@ -37,6 +37,7 @@ INCS=                nbcompat.h \
                nbcompat/md5.h \
                nbcompat/nbconfig.h \
                nbcompat/nbtypes.h \
 +              nbcompat/netdb.h \
                nbcompat/param.h \
                nbcompat/paths.h \
                nbcompat/poll.h \
 @@ -84,14 +85,14 @@ bits: bits.c
        $(LINK) bits.o
  
  install:
 -      $(INSTALL) -m 755 -d $(prefix)/lib
 -      $(INSTALL) -m $(BINMODE) ${LIB} $(prefix)/lib
 -      $(RANLIB) $(prefix)/lib/$(LIB)
 -      $(INSTALL) -m 755 -d $(prefix)/include
 -      $(INSTALL) -m 755 -d $(prefix)/include/nbcompat
 +      $(INSTALL) -m 755 -d ${DESTDIR}$(prefix)/lib
 +      $(INSTALL) -m $(LIBMODE) ${LIB} ${DESTDIR}$(prefix)/lib
 +      $(RANLIB) ${DESTDIR}$(prefix)/lib/$(LIB)
 +      $(INSTALL) -m 755 -d ${DESTDIR}$(prefix)/include
 +      $(INSTALL) -m 755 -d ${DESTDIR}$(prefix)/include/nbcompat
        @for file in $(INCS); do \
 -              echo "$(INSTALL) -m 444 $$file $(prefix)/include/$$file"; \
 -              $(INSTALL) -m 444 $$file $(prefix)/include/$$file; \
 +              echo "$(INSTALL) -m 444 $$file 
${DESTDIR}$(prefix)/include/$$file"; \
 +              $(INSTALL) -m 444 $$file ${DESTDIR}$(prefix)/include/$$file; \
        done
  
  clean:
 Index: files/configure
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/pkgtools/libnbcompat/files/configure,v
 retrieving revision 1.64
 diff -u -p -r1.64 configure
 --- files/configure    12 Sep 2008 13:47:26 -0000      1.64
 +++ files/configure    17 Sep 2008 20:48:54 -0000
 @@ -4146,11 +4146,13 @@ done
  
  
  
 +
 +
  for ac_header in alloca.h assert.h ctype.h dirent.h err.h errno.h fcntl.h \
        fnmatch.h fts.h grp.h libutil.h limits.h machine/endian.h ndir.h \
 -      paths.h pwd.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h \
 -      string.h sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h \
 -      sys/file.h sys/mkdev.h sys/ndir.h sys/param.h sys/stat.h \
 +      netdb.h paths.h pwd.h signal.h stdarg.h stddef.h stdint.h stdio.h \
 +      stdlib.h string.h sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h \
 +      sys/file.h sys/mkdev.h sys/ndir.h sys/param.h sys/socket.h sys/stat.h \
        sys/statfs.h sys/statvfs.h sys/time.h sys/ttycom.h sys/types.h \
        sys/uio.h sys/vfs.h termcap.h time.h tzfile.h unistd.h \
        util.h utime.h
 @@ -11137,10 +11139,11 @@ fi
  
  
  
 +
  for ac_func in asprintf err fgetln fnmatch fparseln getenv isblank \
        lchflags lchmod lchown lutimes mkdtemp mkstemp setenv setgroupent \
 -      setpassent setprogname snprintf statvfs strdup strerror strlcat \
 -      strlcpy strmode strsep strtoll unsetenv usleep utimes warn
 +      setpassent setprogname shquote snprintf statvfs strdup strerror \
 +      strlcat strlcpy strmode strsep strtoll unsetenv usleep utimes warn
  
  do
  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 @@ -11249,10 +11252,431 @@ done
  
  
  
 +need_getaddrinfo=no
 +{ $as_echo "$as_me:$LINENO: checking for struct addrinfo" >&5
 +$as_echo_n "checking for struct addrinfo... " >&6; }
 +if test "${ac_cv_type_struct_addrinfo+set}" = set; then
 +  $as_echo_n "(cached) " >&6
 +else
 +  ac_cv_type_struct_addrinfo=no
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <netdb.h>
  
 +int
 +main ()
 +{
 +if (sizeof (struct addrinfo))
 +       return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <netdb.h>
  
 +int
 +main ()
 +{
 +if (sizeof ((struct addrinfo)))
 +        return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  :
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
  
 -for ac_func in getenv setenv unsetenv
 +      ac_cv_type_struct_addrinfo=yes
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +fi
 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_struct_addrinfo" >&5
 +$as_echo "$ac_cv_type_struct_addrinfo" >&6; }
 +if test $ac_cv_type_struct_addrinfo = yes; then
 +
 +cat >>confdefs.h <<_ACEOF
 +#define HAVE_STRUCT_ADDRINFO 1
 +_ACEOF
 +
 +
 +fi
 +
 +{ $as_echo "$as_me:$LINENO: checking for struct in6_addr" >&5
 +$as_echo_n "checking for struct in6_addr... " >&6; }
 +if test "${ac_cv_type_struct_in6_addr+set}" = set; then
 +  $as_echo_n "(cached) " >&6
 +else
 +  ac_cv_type_struct_in6_addr=no
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <netinet/in.h>
 +
 +int
 +main ()
 +{
 +if (sizeof (struct in6_addr))
 +       return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <netinet/in.h>
 +
 +int
 +main ()
 +{
 +if (sizeof ((struct in6_addr)))
 +        return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  :
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      ac_cv_type_struct_in6_addr=yes
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +fi
 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_struct_in6_addr" >&5
 +$as_echo "$ac_cv_type_struct_in6_addr" >&6; }
 +if test $ac_cv_type_struct_in6_addr = yes; then
 +
 +cat >>confdefs.h <<_ACEOF
 +#define HAVE_STRUCT_IN6_ADDR 1
 +_ACEOF
 +
 +
 +fi
 +
 +{ $as_echo "$as_me:$LINENO: checking for struct sockaddr_in6" >&5
 +$as_echo_n "checking for struct sockaddr_in6... " >&6; }
 +if test "${ac_cv_type_struct_sockaddr_in6+set}" = set; then
 +  $as_echo_n "(cached) " >&6
 +else
 +  ac_cv_type_struct_sockaddr_in6=no
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <netinet/in.h>
 +
 +int
 +main ()
 +{
 +if (sizeof (struct sockaddr_in6))
 +       return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <netinet/in.h>
 +
 +int
 +main ()
 +{
 +if (sizeof ((struct sockaddr_in6)))
 +        return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  :
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      ac_cv_type_struct_sockaddr_in6=yes
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +fi
 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_struct_sockaddr_in6" >&5
 +$as_echo "$ac_cv_type_struct_sockaddr_in6" >&6; }
 +if test $ac_cv_type_struct_sockaddr_in6 = yes; then
 +
 +cat >>confdefs.h <<_ACEOF
 +#define HAVE_STRUCT_SOCKADDR_IN6 1
 +_ACEOF
 +
 +
 +fi
 +
 +{ $as_echo "$as_me:$LINENO: checking for struct sockaddr_storage" >&5
 +$as_echo_n "checking for struct sockaddr_storage... " >&6; }
 +if test "${ac_cv_type_struct_sockaddr_storage+set}" = set; then
 +  $as_echo_n "(cached) " >&6
 +else
 +  ac_cv_type_struct_sockaddr_storage=no
 +cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <sys/socket.h>
 +
 +int
 +main ()
 +{
 +if (sizeof (struct sockaddr_storage))
 +       return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +#include <sys/socket.h>
 +
 +int
 +main ()
 +{
 +if (sizeof ((struct sockaddr_storage)))
 +        return 0;
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext
 +if { (ac_try="$ac_compile"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_compile") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest.$ac_objext; then
 +  :
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      ac_cv_type_struct_sockaddr_storage=yes
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +
 +fi
 +
 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +fi
 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_struct_sockaddr_storage" >&5
 +$as_echo "$ac_cv_type_struct_sockaddr_storage" >&6; }
 +if test $ac_cv_type_struct_sockaddr_storage = yes; then
 +
 +cat >>confdefs.h <<_ACEOF
 +#define HAVE_STRUCT_SOCKADDR_STORAGE 1
 +_ACEOF
 +
 +
 +fi
 +
 +
 +
 +
 +for ac_func in getnameinfo gai_strerror getaddrinfo
  do
  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
  { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
 @@ -11349,19 +11773,134 @@ if test `eval 'as_val=${'$as_ac_var'}
  _ACEOF
   :
  else
 +  need_getaddrinfo=yes
 +fi
 +done
  
 +if test $need_getaddrinfo = yes; then
        case " $LIBOBJS " in
 -  *" findenv.$ac_objext "* ) ;;
 -  *) LIBOBJS="$LIBOBJS findenv.$ac_objext"
 +  *" getaddrinfo.$ac_objext "* ) ;;
 +  *) LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext"
   ;;
  esac
  
 -      break
 +fi
 +
 +need_findenv=no
 +
 +
 +
 +for ac_func in getenv setenv unsetenv
 +do
 +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
 +$as_echo_n "checking for $ac_func... " >&6; }
 +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
 +  $as_echo_n "(cached) " >&6
 +else
 +  cat >conftest.$ac_ext <<_ACEOF
 +/* confdefs.h.  */
 +_ACEOF
 +cat confdefs.h >>conftest.$ac_ext
 +cat >>conftest.$ac_ext <<_ACEOF
 +/* end confdefs.h.  */
 +/* Define $ac_func to an innocuous variant, in case <limits.h> declares 
$ac_func.
 +   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
 +#define $ac_func innocuous_$ac_func
 +
 +/* System header to define __stub macros and hopefully few prototypes,
 +    which can conflict with char $ac_func (); below.
 +    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
 +    <limits.h> exists even on freestanding compilers.  */
 +
 +#ifdef __STDC__
 +# include <limits.h>
 +#else
 +# include <assert.h>
 +#endif
 +
 +#undef $ac_func
 +
 +/* Override any GCC internal prototype to avoid an error.
 +   Use char because int might match the return type of a GCC
 +   builtin and then its argument prototype would still apply.  */
 +#ifdef __cplusplus
 +extern "C"
 +#endif
 +char $ac_func ();
 +/* The GNU C library defines this for functions which it implements
 +    to always fail with ENOSYS.  Some functions are actually named
 +    something starting with __ and the normal name is an alias.  */
 +#if defined __stub_$ac_func || defined __stub___$ac_func
 +choke me
 +#endif
 +
 +int
 +main ()
 +{
 +return $ac_func ();
 +  ;
 +  return 0;
 +}
 +_ACEOF
 +rm -f conftest.$ac_objext conftest$ac_exeext
 +if { (ac_try="$ac_link"
 +case "(($ac_try" in
 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
 +  *) ac_try_echo=$ac_try;;
 +esac
 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 +$as_echo "$ac_try_echo") >&5
 +  (eval "$ac_link") 2>conftest.er1
 +  ac_status=$?
 +  grep -v '^ *+' conftest.er1 >conftest.err
 +  rm -f conftest.er1
 +  cat conftest.err >&5
 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 +  (exit $ac_status); } && {
 +       test -z "$ac_c_werror_flag" ||
 +       test ! -s conftest.err
 +       } && test -s conftest$ac_exeext && {
 +       test "$cross_compiling" = yes ||
 +       $as_test_x conftest$ac_exeext
 +       }; then
 +  eval "$as_ac_var=yes"
 +else
 +  $as_echo "$as_me: failed program was:" >&5
 +sed 's/^/| /' conftest.$ac_ext >&5
 +
 +      eval "$as_ac_var=no"
 +fi
  
 +rm -rf conftest.dSYM
 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 +      conftest$ac_exeext conftest.$ac_ext
 +fi
 +ac_res=`eval 'as_val=${'$as_ac_var'}
 +               $as_echo "$as_val"'`
 +             { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 +$as_echo "$ac_res" >&6; }
 +if test `eval 'as_val=${'$as_ac_var'}
 +               $as_echo "$as_val"'` = yes; then
 +  cat >>confdefs.h <<_ACEOF
 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 +_ACEOF
 + :
 +else
 +  need_findenv=yes
  fi
  done
  
 +if test $need_findenv = yes; then
 +      case " $LIBOBJS " in
 +  *" findenv.$ac_objext "* ) ;;
 +  *) LIBOBJS="$LIBOBJS findenv.$ac_objext"
 + ;;
 +esac
  
 +fi
 +
 +need_gettemp=no
  
  
  for ac_func in mkdtemp mkstemp
 @@ -11461,18 +12000,18 @@ if test `eval 'as_val=${'$as_ac_var'}
  _ACEOF
   :
  else
 +   need_gettemp=yes
 +fi
 +done
  
 +if test $need_gettemp = yes; then
        case " $LIBOBJS " in
    *" gettemp.$ac_objext "* ) ;;
    *) LIBOBJS="$LIBOBJS gettemp.$ac_objext"
   ;;
  esac
  
 -      break
 -
  fi
 -done
 -
  
  
  
 Index: files/configure.ac
 ===================================================================
 RCS file: 
/home/joerg/repo/netbsd/pkgsrc/pkgtools/libnbcompat/files/configure.ac,v
 retrieving revision 1.65
 diff -u -p -r1.65 configure.ac
 --- files/configure.ac 12 Sep 2008 13:47:26 -0000      1.65
 +++ files/configure.ac 17 Sep 2008 20:48:38 -0000
 @@ -38,9 +38,9 @@ AC_CHECK_HEADERS([inttypes.h sys/types.h
  
  AC_CHECK_HEADERS([alloca.h assert.h ctype.h dirent.h err.h errno.h fcntl.h \
        fnmatch.h fts.h grp.h libutil.h limits.h machine/endian.h ndir.h \
 -      paths.h pwd.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h \
 -      string.h sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h \
 -      sys/file.h sys/mkdev.h sys/ndir.h sys/param.h sys/stat.h \
 +      netdb.h paths.h pwd.h signal.h stdarg.h stddef.h stdint.h stdio.h \
 +      stdlib.h string.h sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h \
 +      sys/file.h sys/mkdev.h sys/ndir.h sys/param.h sys/socket.h sys/stat.h \
        sys/statfs.h sys/statvfs.h sys/time.h sys/ttycom.h sys/types.h \
        sys/uio.h sys/vfs.h termcap.h time.h tzfile.h unistd.h \
        util.h utime.h
 @@ -239,19 +239,33 @@ AC_CHECK_DECLS([snprintf, vasprintf], []
  
  AC_REPLACE_FUNCS([asprintf err fgetln fnmatch fparseln getenv isblank \
        lchflags lchmod lchown lutimes mkdtemp mkstemp setenv setgroupent \
 -      setpassent setprogname snprintf statvfs strdup strerror strlcat \
 -      strlcpy strmode strsep strtoll unsetenv usleep utimes warn
 +      setpassent setprogname shquote snprintf statvfs strdup strerror \
 +      strlcat strlcpy strmode strsep strtoll unsetenv usleep utimes warn
  ])
  
 -AC_CHECK_FUNCS([getenv setenv unsetenv], [:], [
 +need_getaddrinfo=no
 +AC_CHECK_TYPES([struct addrinfo], [], [], [[#include <netdb.h>]])
 +AC_CHECK_TYPES([struct in6_addr], [], [], [[#include <netinet/in.h>]])
 +AC_CHECK_TYPES([struct sockaddr_in6], [], [], [[#include <netinet/in.h>]])
 +AC_CHECK_TYPES([struct sockaddr_storage], [], [], [[#include <sys/socket.h>]])
 +dnl Assume that freeaddrinfo is only missing if getaddrinfo is also missing
 +AC_CHECK_FUNCS([getnameinfo gai_strerror getaddrinfo], [:],
 +    [need_getaddrinfo=yes])
 +if test $need_getaddrinfo = yes; then
 +      AC_LIBOBJ(getaddrinfo)
 +fi
 +
 +need_findenv=no
 +AC_CHECK_FUNCS([getenv setenv unsetenv], [:], [need_findenv=yes])
 +if test $need_findenv = yes; then
        AC_LIBOBJ(findenv)
 -      break
 -])
 +fi
  
 -AC_CHECK_FUNCS([mkdtemp mkstemp], [:], [
 +need_gettemp=no
 +AC_CHECK_FUNCS([mkdtemp mkstemp], [:], [ need_gettemp=yes ])
 +if test $need_gettemp = yes; then
        AC_LIBOBJ(gettemp)
 -      break
 -])
 +fi
  
  AC_CHECK_FUNCS([bcopy bzero memset memcpy setlocale])
  AC_CHECK_FUNCS([getmode setmode], [:], [need_setmode=yes])
 Index: files/getaddrinfo.c
 ===================================================================
 RCS file: files/getaddrinfo.c
 diff -N files/getaddrinfo.c
 --- /dev/null  1 Jan 1970 00:00:00 -0000
 +++ files/getaddrinfo.c        17 Sep 2008 20:39:06 -0000
 @@ -0,0 +1,231 @@
 +/*
 + * Copyright (C) 2000-2003 Damien Miller.  All rights reserved.
 + * Copyright (C) 1999 WIDE Project.  All rights reserved.
 + * 
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *    notice, this list of conditions and the following disclaimer.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *    notice, this list of conditions and the following disclaimer in the
 + *    documentation and/or other materials provided with the distribution.
 + * 3. Neither the name of the project nor the names of its contributors
 + *    may be used to endorse or promote products derived from this software
 + *    without specific prior written permission.
 + * 
 + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 + * SUCH DAMAGE.
 + */
 +
 +/*
 + * Pseudo-implementation of RFC2553 name / address resolution functions
 + *
 + * But these functions are not implemented correctly. The minimum subset
 + * is implemented for ssh use only. For example, this routine assumes
 + * that ai_family is AF_INET. Don't use it for another purpose.
 + */
 +
 +
 +#include <nbcompat.h>
 +
 +#include <nbcompat/netdb.h>
 +#include <stdlib.h>
 +#include <string.h>
 +
 +#include <netinet/in.h>
 +#include <arpa/inet.h>
 +
 +#ifndef HAVE_GETNAMEINFO
 +int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, 
 +                size_t hostlen, char *serv, size_t servlen, int flags)
 +{
 +      struct sockaddr_in *sin = (struct sockaddr_in *)sa;
 +      struct hostent *hp;
 +      char tmpserv[16];
 +
 +      if (sa->sa_family != AF_UNSPEC && sa->sa_family != AF_INET)
 +              return (EAI_FAMILY);
 +      if (serv != NULL) {
 +              snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
 +              if (strlcpy(serv, tmpserv, servlen) >= servlen)
 +                      return (EAI_MEMORY);
 +      }
 +
 +      if (host != NULL) {
 +              if (flags & NI_NUMERICHOST) {
 +                      if (strlcpy(host, inet_ntoa(sin->sin_addr),
 +                          hostlen) >= hostlen)
 +                              return (EAI_MEMORY);
 +                      else
 +                              return (0);
 +              } else {
 +                      hp = gethostbyaddr((char *)&sin->sin_addr, 
 +                          sizeof(struct in_addr), AF_INET);
 +                      if (hp == NULL)
 +                              return (EAI_NODATA);
 +                      
 +                      if (strlcpy(host, hp->h_name, hostlen) >= hostlen)
 +                              return (EAI_MEMORY);
 +                      else
 +                              return (0);
 +              }
 +      }
 +      return (0);
 +}
 +#endif /* !HAVE_GETNAMEINFO */
 +
 +#ifndef HAVE_GAI_STRERROR
 +char *
 +gai_strerror(int err)
 +{
 +      switch (err) {
 +      case EAI_NODATA:
 +              return ("no address associated with name");
 +      case EAI_MEMORY:
 +              return ("memory allocation failure.");
 +      case EAI_NONAME:
 +              return ("nodename nor servname provided, or not known");
 +      case EAI_FAMILY:
 +              return ("ai_family not supported");
 +      default:
 +              return ("unknown/invalid error.");
 +      }
 +}    
 +#endif /* !HAVE_GAI_STRERROR */
 +
 +#ifndef HAVE_GETADDRINFO
 +void
 +freeaddrinfo(struct addrinfo *ai)
 +{
 +      struct addrinfo *next;
 +
 +      for(; ai != NULL;) {
 +              next = ai->ai_next;
 +              free(ai);
 +              ai = next;
 +      }
 +}
 +
 +static struct
 +addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints)
 +{
 +      struct addrinfo *ai;
 +
 +      ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in));
 +      if (ai == NULL)
 +              return (NULL);
 +      
 +      memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in));
 +      
 +      ai->ai_addr = (struct sockaddr *)(ai + 1);
 +      /* XXX -- ssh doesn't use sa_len */
 +      ai->ai_addrlen = sizeof(struct sockaddr_in);
 +      ai->ai_addr->sa_family = ai->ai_family = AF_INET;
 +
 +      ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
 +      ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
 +      
 +      /* XXX: the following is not generally correct, but does what we want */
 +      if (hints->ai_socktype)
 +              ai->ai_socktype = hints->ai_socktype;
 +      else
 +              ai->ai_socktype = SOCK_STREAM;
 +
 +      if (hints->ai_protocol)
 +              ai->ai_protocol = hints->ai_protocol;
 +
 +      return (ai);
 +}
 +
 +int
 +getaddrinfo(const char *hostname, const char *servname, 
 +    const struct addrinfo *hints, struct addrinfo **res)
 +{
 +      struct hostent *hp;
 +      struct servent *sp;
 +      struct in_addr in;
 +      int i;
 +      long int port;
 +      u_long addr;
 +
 +      port = 0;
 +      if (hints && hints->ai_family != AF_UNSPEC &&
 +          hints->ai_family != AF_INET)
 +              return (EAI_FAMILY);
 +      if (servname != NULL) {
 +              char *cp;
 +
 +              port = strtol(servname, &cp, 10);
 +              if (port > 0 && port <= 65535 && *cp == '\0')
 +                      port = htons(port);
 +              else if ((sp = getservbyname(servname, NULL)) != NULL)
 +                      port = sp->s_port;
 +              else
 +                      port = 0;
 +      }
 +
 +      if (hints && hints->ai_flags & AI_PASSIVE) {
 +              addr = htonl(0x00000000);
 +              if (hostname && inet_aton(hostname, &in) != 0)
 +                      addr = in.s_addr;
 +              *res = malloc_ai(port, addr, hints);
 +              if (*res == NULL) 
 +                      return (EAI_MEMORY);
 +              return (0);
 +      }
 +              
 +      if (!hostname) {
 +              *res = malloc_ai(port, htonl(0x7f000001), hints);
 +              if (*res == NULL) 
 +                      return (EAI_MEMORY);
 +              return (0);
 +      }
 +      
 +      if (inet_aton(hostname, &in)) {
 +              *res = malloc_ai(port, in.s_addr, hints);
 +              if (*res == NULL) 
 +                      return (EAI_MEMORY);
 +              return (0);
 +      }
 +      
 +      /* Don't try DNS if AI_NUMERICHOST is set */
 +      if (hints && hints->ai_flags & AI_NUMERICHOST)
 +              return (EAI_NONAME);
 +      
 +      hp = gethostbyname(hostname);
 +      if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
 +              struct addrinfo *cur, *prev;
 +
 +              cur = prev = *res = NULL;
 +              for (i = 0; hp->h_addr_list[i]; i++) {
 +                      struct in_addr *in = (struct in_addr 
*)hp->h_addr_list[i];
 +
 +                      cur = malloc_ai(port, in->s_addr, hints);
 +                      if (cur == NULL) {
 +                              if (*res != NULL)
 +                                      freeaddrinfo(*res);
 +                              return (EAI_MEMORY);
 +                      }
 +                      if (prev)
 +                              prev->ai_next = cur;
 +                      else
 +                              *res = cur;
 +
 +                      prev = cur;
 +              }
 +              return (0);
 +      }
 +      
 +      return (EAI_NODATA);
 +}
 +#endif /* !HAVE_GETADDRINFO */
 Index: files/shquote.c
 ===================================================================
 RCS file: files/shquote.c
 diff -N files/shquote.c
 --- /dev/null  1 Jan 1970 00:00:00 -0000
 +++ files/shquote.c    16 Sep 2008 21:38:59 -0000
 @@ -0,0 +1,188 @@
 +/* $NetBSD: shquote.c,v 1.8 2006/03/19 02:33:02 christos Exp $ */
 +
 +/*
 + * Copyright (c) 2001 Christopher G. Demetriou
 + * All rights reserved.
 + * 
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *    notice, this list of conditions and the following disclaimer.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *    notice, this list of conditions and the following disclaimer in the
 + *    documentation and/or other materials provided with the distribution.
 + * 3. All advertising materials mentioning features or use of this software
 + *    must display the following acknowledgement:
 + *          This product includes software developed for the
 + *          NetBSD Project.  See http://www.NetBSD.org/ for
 + *          information about NetBSD.
 + * 4. The name of the author may not be used to endorse or promote products
 + *    derived from this software without specific prior written permission.
 + * 
 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 + * 
 + * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
 + */
 +
 +#include <sys/cdefs.h>
 +#if defined(LIBC_SCCS) && !defined(lint)
 +__RCSID("$NetBSD: shquote.c,v 1.8 2006/03/19 02:33:02 christos Exp $");
 +#endif /* LIBC_SCCS and not lint */
 +
 +/*
 + * Define SHQUOTE_USE_MULTIBYTE if you want shquote() to handle multibyte
 + * characters using mbrtowc().
 + *
 + * Please DO NOT rip this #ifdef out of the code.  It's also here to help
 + * portability.
 + */
 +#undef        SHQUOTE_USE_MULTIBYTE
 +
 +#include <nbcompat/stdlib.h>
 +#include <string.h>
 +#ifdef SHQUOTE_USE_MULTIBYTE
 +#include <limits.h>
 +#include <stdio.h>
 +#include <wchar.h>
 +#endif
 +
 +#ifdef __weak_alias
 +__weak_alias(shquote,_shquote)
 +#endif
 +
 +/*
 + * shquote():
 + *
 + * Requotes arguments so that they'll be interpreted properly by the
 + * shell (/bin/sh).
 + *
 + * Wraps single quotes around the string, and replaces single quotes
 + * in the string with the sequence:
 + *    '\''
 + *
 + * Returns the number of characters required to hold the resulting quoted
 + * argument.
 + *
 + * The buffer supplied is filled in and NUL-terminated.  If 'bufsize'
 + * indicates that the buffer is too short to hold the output string, the
 + * first (bufsize - 1) bytes of quoted argument are filled in and the
 + * buffer is NUL-terminated.
 + *
 + * Changes could be made to optimize the length of strings output by this
 + * function:
 + *
 + *    * if there are no metacharacters or whitespace in the input,
 + *      the output could be the input string.
 + */
 +
 +#ifdef SHQUOTE_USE_MULTIBYTE
 +
 +#define       XLATE_OUTCH(x)          wcrtomb(outch, (x), &mbso)
 +#define       XLATE_INCH()                                            \
 +    do {                                                      \
 +      n = mbrtowc(&c, arg, MB_CUR_MAX, &mbsi);                \
 +    } while (/*LINTED const cond*/0)
 +
 +#else
 +
 +#define       XLATE_OUTCH(x)          (outch[0] = (x), 1)
 +#define       XLATE_INCH()                                            \
 +    do {                                                      \
 +      n = ((c = *arg) != '\0') ? 1 : 0;                       \
 +    } while (/*LINTED const cond*/0)
 +
 +#endif
 +
 +#define       PUT(x)                                                  \
 +    do {                                                      \
 +      outchlen = XLATE_OUTCH(x);                              \
 +      if (outchlen == (size_t)-1)                             \
 +              goto bad;                                       \
 +      rv += outchlen;                                         \
 +      if (bufsize != 0) {                                     \
 +              if (bufsize < outchlen ||                       \
 +                  (bufsize == outchlen &&                     \
 +                   outch[outchlen - 1] != '\0')) {            \
 +                      *buf = '\0';                            \
 +                      bufsize = 0;                            \
 +              } else {                                        \
 +                      memcpy(buf, outch, outchlen);           \
 +                      buf += outchlen;                        \
 +                      bufsize -= outchlen;                    \
 +              }                                               \
 +      }                                                       \
 +    } while (/*LINTED const cond*/0)
 +
 +size_t
 +shquote(const char *arg, char *buf, size_t bufsize)
 +{
 +#ifdef SHQUOTE_USE_MULTIBYTE
 +      char outch[MB_LEN_MAX];
 +      mbstate_t mbsi, mbso;
 +      wchar_t c, lastc;
 +      size_t outchlen;
 +#else
 +      char outch[1];
 +      char c, lastc;
 +      size_t outchlen;
 +#endif
 +      size_t rv;
 +      int n;
 +
 +      rv = 0;
 +      lastc = 0;
 +#ifdef SHQUOTE_USE_MULTIBYTE
 +      memset(&mbsi, 0, sizeof mbsi);
 +      memset(&mbso, 0, sizeof mbso);
 +#endif
 +
 +      if (*arg != '\'')
 +              PUT('\'');
 +      for (;;) {
 +              XLATE_INCH();
 +              if (n <= 0)
 +                      break;
 +              arg += n;
 +              lastc = c;
 +
 +              if (c == '\'') {
 +                      if (rv != 0)
 +                              PUT('\'');
 +                      PUT('\\');
 +                      PUT('\'');
 +                      for (;;) {
 +                              XLATE_INCH();
 +                              if (n <= 0 || c != '\'')
 +                                      break;
 +                              PUT('\\');
 +                              PUT('\'');
 +                              arg += n;
 +                      }
 +                      if (n > 0)
 +                              PUT('\'');
 +              } else
 +                      PUT(c);
 +      }
 +      if (lastc != '\'')
 +              PUT('\'');
 +
 +      /* Put multibyte or NUL terminator, but don't count the NUL. */
 +      PUT('\0');
 +      rv--;
 +
 +      return rv;
 +
 +bad:
 +      /* A multibyte character encoding or decoding error occurred. */
 +      return (size_t)-1;
 +}
 Index: files/nbcompat/config.h.in
 ===================================================================
 RCS file: 
/home/joerg/repo/netbsd/pkgsrc/pkgtools/libnbcompat/files/nbcompat/config.h.in,v
 retrieving revision 1.22
 diff -u -p -r1.22 config.h.in
 --- files/nbcompat/config.h.in 8 Sep 2008 20:20:23 -0000       1.22
 +++ files/nbcompat/config.h.in 17 Sep 2008 20:48:55 -0000
 @@ -97,12 +97,21 @@
  /* Define to 1 if you have the <fts.h> header file. */
  #undef HAVE_FTS_H
  
 +/* Define to 1 if you have the `gai_strerror' function. */
 +#undef HAVE_GAI_STRERROR
 +
 +/* Define to 1 if you have the `getaddrinfo' function. */
 +#undef HAVE_GETADDRINFO
 +
  /* Define to 1 if you have the `getenv' function. */
  #undef HAVE_GETENV
  
  /* Define to 1 if you have the `getmode' function. */
  #undef HAVE_GETMODE
  
 +/* Define to 1 if you have the `getnameinfo' function. */
 +#undef HAVE_GETNAMEINFO
 +
  /* Define to 1 if you have the <getopt.h> header file. */
  #undef HAVE_GETOPT_H
  
 @@ -236,6 +245,9 @@
  /* Define to 1 if you have the <ndir.h> header file. */
  #undef HAVE_NDIR_H
  
 +/* Define to 1 if you have the <netdb.h> header file. */
 +#undef HAVE_NETDB_H
 +
  /* Define to 1 if you have the <netinet/in6_machtypes.h> header file. */
  #undef HAVE_NETINET_IN6_MACHTYPES_H
  
 @@ -291,6 +303,9 @@
  /* Define to 1 if you have the <sha2.h> header file. */
  #undef HAVE_SHA2_H
  
 +/* Define to 1 if you have the `shquote' function. */
 +#undef HAVE_SHQUOTE
 +
  /* Define to 1 if you have the <signal.h> header file. */
  #undef HAVE_SIGNAL_H
  
 @@ -348,9 +363,21 @@
  /* Define to 1 if you have the `strtoll' function. */
  #undef HAVE_STRTOLL
  
 +/* Define to 1 if the system has the type `struct addrinfo'. */
 +#undef HAVE_STRUCT_ADDRINFO
 +
  /* Define to 1 if `d_namlen' is member of `struct dirent'. */
  #undef HAVE_STRUCT_DIRENT_D_NAMLEN
  
 +/* Define to 1 if the system has the type `struct in6_addr'. */
 +#undef HAVE_STRUCT_IN6_ADDR
 +
 +/* Define to 1 if the system has the type `struct sockaddr_in6'. */
 +#undef HAVE_STRUCT_SOCKADDR_IN6
 +
 +/* Define to 1 if the system has the type `struct sockaddr_storage'. */
 +#undef HAVE_STRUCT_SOCKADDR_STORAGE
 +
  /* Define to 1 if `f_flags' is member of `struct statfs'. */
  #undef HAVE_STRUCT_STATFS_F_FLAGS
  
 @@ -405,6 +432,9 @@
  /* Define to 1 if you have the <sys/queue.h> header file. */
  #undef HAVE_SYS_QUEUE_H
  
 +/* Define to 1 if you have the <sys/socket.h> header file. */
 +#undef HAVE_SYS_SOCKET_H
 +
  /* Define to 1 if you have the <sys/statfs.h> header file. */
  #undef HAVE_SYS_STATFS_H
  
 Index: files/nbcompat/netdb.h
 ===================================================================
 RCS file: files/nbcompat/netdb.h
 diff -N files/nbcompat/netdb.h
 --- /dev/null  1 Jan 1970 00:00:00 -0000
 +++ files/nbcompat/netdb.h     17 Sep 2008 20:46:19 -0000
 @@ -0,0 +1,167 @@
 +/* $Id: fake-rfc2553.h,v 1.16 2008/07/14 11:37:37 djm Exp $ */
 +
 +/*
 + * Copyright (C) 2000-2003 Damien Miller.  All rights reserved.
 + * Copyright (C) 1999 WIDE Project.  All rights reserved.
 + * 
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *    notice, this list of conditions and the following disclaimer.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *    notice, this list of conditions and the following disclaimer in the
 + *    documentation and/or other materials provided with the distribution.
 + * 3. Neither the name of the project nor the names of its contributors
 + *    may be used to endorse or promote products derived from this software
 + *    without specific prior written permission.
 + * 
 + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 + * SUCH DAMAGE.
 + */
 +
 +/*
 + * Pseudo-implementation of RFC2553 name / address resolution functions
 + *
 + * But these functions are not implemented correctly. The minimum subset
 + * is implemented for ssh use only. For example, this routine assumes
 + * that ai_family is AF_INET. Don't use it for another purpose.
 + */
 +
 +#ifndef _NBCOMPAT_NETDB_H
 +#define _NBCOMPAT_NETDB_H
 +
 +#include <sys/types.h>
 +#if defined(HAVE_NETDB_H)
 +# include <netdb.h>
 +#endif
 +#if defined(HAVE_SYS_SOCKET_H)
 +# include <sys/socket.h>
 +#endif
 +
 +/*
 + * First, socket and INET6 related definitions 
 + */
 +#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
 +# define      _SS_MAXSIZE     128     /* Implementation specific max size */
 +# define       _SS_PADSIZE     (_SS_MAXSIZE - sizeof (struct sockaddr))
 +struct sockaddr_storage {
 +      struct sockaddr ss_sa;
 +      char            __ss_pad2[_SS_PADSIZE];
 +};
 +# define ss_family ss_sa.sa_family
 +#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
 +
 +#ifndef IN6_IS_ADDR_LOOPBACK
 +# define IN6_IS_ADDR_LOOPBACK(a) \
 +      (((u_int32_t *)(a))[0] == 0 && ((u_int32_t *)(a))[1] == 0 && \
 +       ((u_int32_t *)(a))[2] == 0 && ((u_int32_t *)(a))[3] == htonl(1))
 +#endif /* !IN6_IS_ADDR_LOOPBACK */
 +
 +#ifndef HAVE_STRUCT_IN6_ADDR
 +struct in6_addr {
 +      u_int8_t        s6_addr[16];
 +};
 +#endif /* !HAVE_STRUCT_IN6_ADDR */
 +
 +#ifndef HAVE_STRUCT_SOCKADDR_IN6
 +struct sockaddr_in6 {
 +      unsigned short  sin6_family;
 +      u_int16_t       sin6_port;
 +      u_int32_t       sin6_flowinfo;
 +      struct in6_addr sin6_addr;
 +      u_int32_t       sin6_scope_id;
 +};
 +#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */
 +
 +#ifndef AF_INET6
 +/* Define it to something that should never appear */
 +#define AF_INET6 AF_MAX
 +#endif
 +
 +/*
 + * Next, RFC2553 name / address resolution API
 + */
 +
 +#ifndef NI_NUMERICHOST
 +# define NI_NUMERICHOST    (1)
 +#endif
 +#ifndef NI_NAMEREQD
 +# define NI_NAMEREQD       (1<<1)
 +#endif
 +#ifndef NI_NUMERICSERV
 +# define NI_NUMERICSERV    (1<<2)
 +#endif
 +
 +#ifndef AI_PASSIVE
 +# define AI_PASSIVE           (1)
 +#endif
 +#ifndef AI_CANONNAME
 +# define AI_CANONNAME         (1<<1)
 +#endif
 +#ifndef AI_NUMERICHOST
 +# define AI_NUMERICHOST               (1<<2)
 +#endif
 +
 +#ifndef NI_MAXSERV
 +# define NI_MAXSERV 32
 +#endif /* !NI_MAXSERV */
 +#ifndef NI_MAXHOST
 +# define NI_MAXHOST 1025
 +#endif /* !NI_MAXHOST */
 +
 +#ifndef EAI_NODATA
 +# define EAI_NODATA   (INT_MAX - 1)
 +#endif
 +#ifndef EAI_MEMORY
 +# define EAI_MEMORY   (INT_MAX - 2)
 +#endif
 +#ifndef EAI_NONAME
 +# define EAI_NONAME   (INT_MAX - 3)
 +#endif
 +#ifndef EAI_SYSTEM
 +# define EAI_SYSTEM   (INT_MAX - 4)
 +#endif
 +#ifndef EAI_FAMILY
 +# define EAI_FAMILY   (INT_MAX - 5)
 +#endif
 +
 +#ifndef HAVE_STRUCT_ADDRINFO
 +struct addrinfo {
 +      int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
 +      int     ai_family;      /* PF_xxx */
 +      int     ai_socktype;    /* SOCK_xxx */
 +      int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
 +      size_t  ai_addrlen;     /* length of ai_addr */
 +      char    *ai_canonname;  /* canonical name for hostname */
 +      struct sockaddr *ai_addr;       /* binary address */
 +      struct addrinfo *ai_next;       /* next structure in linked list */
 +};
 +#endif /* !HAVE_STRUCT_ADDRINFO */
 +
 +#ifndef HAVE_GETADDRINFO
 +void freeaddrinfo(struct addrinfo *);
 +int getaddrinfo(const char *, const char *, 
 +    const struct addrinfo *, struct addrinfo **);
 +#endif /* !HAVE_GETADDRINFO */
 +
 +#if !defined(HAVE_GAI_STRERROR)
 +char *gai_strerror(int);
 +#endif /* !HAVE_GAI_STRERROR */
 +
 +#ifndef HAVE_GETNAMEINFO
 +int getnameinfo(const struct sockaddr *, size_t, char *, size_t, 
 +    char *, size_t, int);
 +#endif /* !HAVE_GETNAMEINFO */
 +
 +#endif /* !_FAKE_RFC2553_H */
 +
 Index: files/nbcompat/stdlib.h
 ===================================================================
 RCS file: 
/home/joerg/repo/netbsd/pkgsrc/pkgtools/libnbcompat/files/nbcompat/stdlib.h,v
 retrieving revision 1.3
 diff -u -p -r1.3 stdlib.h
 --- files/nbcompat/stdlib.h    29 Apr 2008 05:46:08 -0000      1.3
 +++ files/nbcompat/stdlib.h    16 Sep 2008 21:23:14 -0000
 @@ -65,4 +65,8 @@ long long strtoll(const char *, char **,
  # define NO_LONG_LONG 1
  #endif  /* ! HAVE_WORKING_LONG_LONG */
  
 +#if !HAVE_SHQUOTE
 +size_t        shquote(const char *, char *, size_t);
 +#endif
 +
  #endif        /* !_NBCOMPAT_STDLIB_H_ */
 
 --C7zPtVaVf+AK4Oqc--
 


Home | Main Index | Thread Index | Old Index