pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/net/libfetch libfetch-2.16:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/016f5511f6de
branches:  trunk
changeset: 547984:016f5511f6de
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Mon Oct 06 12:58:29 2008 +0000

description:
libfetch-2.16:
- only include openssl if the openssl option is present
- include arpa/inet.h to get ntohl and friends on older platforms like
  Interix
- use new netdb.h compat code from libnbcompat
- include inttypes.h only when present
- don't name local variables err, Interix has a symbol like that in
  default namespace
- allow fetch_read to do short read and do more intelligent buffering
  for header processing; effectively don't do a system call for each
  byte read

diffstat:

 net/libfetch/Makefile          |   5 +--
 net/libfetch/files/common.c    |  57 +++++++++++++++++++++++++----------------
 net/libfetch/files/common.h    |   2 +-
 net/libfetch/files/errlist.sh  |   2 +-
 net/libfetch/files/fetch.3     |   2 +-
 net/libfetch/files/fetch.c     |   9 +++++-
 net/libfetch/files/fetch.h     |   2 +-
 net/libfetch/files/file.c      |   9 +++++-
 net/libfetch/files/ftp.c       |  11 ++++++-
 net/libfetch/files/ftp.errors  |   2 +-
 net/libfetch/files/http.c      |  16 ++++++++--
 net/libfetch/files/http.errors |   2 +-
 net/libfetch/options.mk        |   4 ++-
 13 files changed, 83 insertions(+), 40 deletions(-)

diffs (truncated from 396 to 300 lines):

diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/Makefile
--- a/net/libfetch/Makefile     Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/Makefile     Mon Oct 06 12:58:29 2008 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.18 2008/08/21 15:22:45 joerg Exp $
+# $NetBSD: Makefile,v 1.19 2008/10/06 12:58:29 joerg Exp $
 #
 
-DISTNAME=      libfetch-2.15
+DISTNAME=      libfetch-2.16
 CATEGORIES=    net
 MASTER_SITES=  # empty
 DISTFILES=     # empty
@@ -29,5 +29,4 @@
 
 .include "options.mk"
 
-.include "../../security/openssl/buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/common.c
--- a/net/libfetch/files/common.c       Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/common.c       Mon Oct 06 12:58:29 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.c,v 1.13 2008/05/09 00:39:06 joerg Exp $        */
+/*     $NetBSD: common.c,v 1.14 2008/10/06 12:58:29 joerg Exp $        */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
@@ -30,17 +30,31 @@
  * $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $
  */
 
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifndef NETBSD
+#include <nbcompat.h>
+#endif
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/uio.h>
 
+#include <arpa/inet.h>
 #include <netinet/in.h>
 
 #include <ctype.h>
 #include <errno.h>
+#if defined(HAVE_INTTYPES_H) || defined(NETBSD)
 #include <inttypes.h>
+#endif
+#ifndef NETBSD
+#include <nbcompat/netdb.h>
+#else
 #include <netdb.h>
+#endif
 #include <pwd.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -245,13 +259,13 @@
 fetch_bind(int sd, int af, const char *addr)
 {
        struct addrinfo hints, *res, *res0;
-       int err;
+       int error;
 
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = af;
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_protocol = 0;
-       if ((err = getaddrinfo(addr, NULL, &hints, &res0)) != 0)
+       if ((error = getaddrinfo(addr, NULL, &hints, &res0)) != 0)
                return (-1);
        for (res = res0; res; res = res->ai_next)
                if (bind(sd, res->ai_addr, res->ai_addrlen) == 0)
@@ -270,7 +284,7 @@
        char pbuf[10];
        const char *bindaddr;
        struct addrinfo hints, *res, *res0;
-       int sd, err;
+       int sd, error;
 
        if (verbose)
                fetch_info("looking up %s", host);
@@ -281,8 +295,8 @@
        hints.ai_family = af;
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_protocol = 0;
-       if ((err = getaddrinfo(host, pbuf, &hints, &res0)) != 0) {
-               netdb_seterr(err);
+       if ((error = getaddrinfo(host, pbuf, &hints, &res0)) != 0) {
+               netdb_seterr(error);
                return (NULL);
        }
        bindaddr = getenv("FETCH_BIND_ADDRESS");
@@ -385,17 +399,19 @@
 {
        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 +441,13 @@
                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 +462,7 @@
        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 +476,14 @@
        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 +494,7 @@
                        conn->buf = tmp;
                        conn->bufsize = tmpsize;
                }
-       } while (c != '\n');
+       } while (!done);
 
        conn->buf[conn->buflen] = '\0';
        return (0);
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/common.h
--- a/net/libfetch/files/common.h       Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/common.h       Mon Oct 06 12:58:29 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.h,v 1.8 2008/07/27 13:51:27 joerg Exp $ */
+/*     $NetBSD: common.h,v 1.9 2008/10/06 12:58:29 joerg Exp $ */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * All rights reserved.
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/errlist.sh
--- a/net/libfetch/files/errlist.sh     Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/errlist.sh     Mon Oct 06 12:58:29 2008 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: errlist.sh,v 1.1 2008/08/21 15:22:45 joerg Exp $
+# $NetBSD: errlist.sh,v 1.2 2008/10/06 12:58:29 joerg Exp $
 
 printf "static struct fetcherr $1[] = {\n"
 while read code type msg; do
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/fetch.3
--- a/net/libfetch/files/fetch.3        Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/fetch.3        Mon Oct 06 12:58:29 2008 +0000
@@ -24,7 +24,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD: fetch.3,v 1.64 2007/12/18 11:03:26 des Exp $
-.\" $NetBSD: fetch.3,v 1.8 2008/04/30 11:43:59 wiz Exp $
+.\" $NetBSD: fetch.3,v 1.9 2008/10/06 12:58:29 joerg Exp $
 .\"
 .Dd April 25, 2008
 .Dt FETCH 3
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/fetch.c
--- a/net/libfetch/files/fetch.c        Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/fetch.c        Mon Oct 06 12:58:29 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.c,v 1.12 2008/04/26 22:42:49 tnn Exp $   */
+/*     $NetBSD: fetch.c,v 1.13 2008/10/06 12:58:29 joerg Exp $ */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
@@ -30,6 +30,13 @@
  * $FreeBSD: fetch.c,v 1.41 2007/12/19 00:26:36 des Exp $
  */
 
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifndef NETBSD
+#include <nbcompat.h>
+#endif
+
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/fetch.h
--- a/net/libfetch/files/fetch.h        Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/fetch.h        Mon Oct 06 12:58:29 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.h,v 1.11 2008/04/25 19:59:30 joerg Exp $ */
+/*     $NetBSD: fetch.h,v 1.12 2008/10/06 12:58:29 joerg Exp $ */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * All rights reserved.
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/file.c
--- a/net/libfetch/files/file.c Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/file.c Mon Oct 06 12:58:29 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: file.c,v 1.11 2008/04/25 16:25:25 joerg Exp $  */
+/*     $NetBSD: file.c,v 1.12 2008/10/06 12:58:29 joerg Exp $  */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
@@ -30,6 +30,13 @@
  * $FreeBSD: file.c,v 1.18 2007/12/14 10:26:58 des Exp $
  */
 
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifndef NETBSD
+#include <nbcompat.h>
+#endif
+
 #include <sys/stat.h>
 
 #include <dirent.h>
diff -r 4f5acb582510 -r 016f5511f6de net/libfetch/files/ftp.c
--- a/net/libfetch/files/ftp.c  Mon Oct 06 12:58:11 2008 +0000
+++ b/net/libfetch/files/ftp.c  Mon Oct 06 12:58:29 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.22 2008/04/25 16:25:25 joerg Exp $   */
+/*     $NetBSD: ftp.c,v 1.23 2008/10/06 12:58:29 joerg Exp $   */
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
@@ -60,21 +60,28 @@
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
+#ifndef NETBSD
 #include <nbcompat.h>
+#endif
 
 #include <sys/types.h>
 #include <sys/socket.h>
+
+#include <arpa/inet.h>
 #include <netinet/in.h>
 
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#if defined(HAVE_INTTYPES_H) || defined(NETBSD)
 #include <inttypes.h>
-#include <netdb.h>
+#endif
 #include <stdarg.h>
 #ifndef NETBSD
+#include <nbcompat/netdb.h>
 #include <nbcompat/stdio.h>
 #else
+#include <netdb.h>
 #include <stdio.h>



Home | Main Index | Thread Index | Old Index