pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/net/libfetch Import libfetch-2.0, based on the FreeBSD...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/df86ce898650
branches:  trunk
changeset: 538378:df86ce898650
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Thu Feb 07 01:48:22 2008 +0000

description:
Import libfetch-2.0, based on the FreeBSD version of today with a number
of smaller changes to not depend on sys/param.h. This library is
intended to replace the tnftp dependency in pkg_install.

diffstat:

 net/libfetch/DESCR             |    11 +
 net/libfetch/Makefile          |    28 +
 net/libfetch/PLIST             |     4 +
 net/libfetch/buildlink3.mk     |    28 +
 net/libfetch/files/Makefile    |    40 +
 net/libfetch/files/common.c    |   789 +++++++++++++++++++++++++
 net/libfetch/files/common.h    |   126 ++++
 net/libfetch/files/errlist.awk |    12 +
 net/libfetch/files/fetch.3     |   685 ++++++++++++++++++++++
 net/libfetch/files/fetch.c     |   436 ++++++++++++++
 net/libfetch/files/fetch.cat3  |   468 +++++++++++++++
 net/libfetch/files/fetch.h     |   154 +++++
 net/libfetch/files/file.c      |   145 ++++
 net/libfetch/files/ftp.c       |  1202 +++++++++++++++++++++++++++++++++++++++
 net/libfetch/files/ftp.errors  |    48 +
 net/libfetch/files/http.c      |  1227 ++++++++++++++++++++++++++++++++++++++++
 net/libfetch/files/http.errors |    46 +
 net/libfetch/options.mk        |    19 +
 18 files changed, 5468 insertions(+), 0 deletions(-)

diffs (truncated from 5540 to 300 lines):

diff -r 9e87e4a96532 -r df86ce898650 net/libfetch/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfetch/DESCR        Thu Feb 07 01:48:22 2008 +0000
@@ -0,0 +1,11 @@
+libfetch provides a high-level interface for retreiving and uploading
+files using Uniform Resource Locators (URLs).
+
+The library implements:
+
+    * local file access (file://)
+    * FTP
+    * HTTP
+    * HTTPS (optional, using OpenSSL)
+
+FTP and HTTP proxies can be used.
diff -r 9e87e4a96532 -r df86ce898650 net/libfetch/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfetch/Makefile     Thu Feb 07 01:48:22 2008 +0000
@@ -0,0 +1,28 @@
+# $NetBSD: Makefile,v 1.1.1.1 2008/02/07 01:48:22 joerg Exp $
+#
+
+DISTNAME=      libfetch-2.0
+CATEGORIES=    net
+MASTER_SITES=  # empty
+DISTFILES=     # empty
+
+NO_CHECKSUM=   yes
+
+MAINTAINER=    joerg%NetBSD.org@localhost
+HOMEPAGE=      http://www.FreeBSD.org/
+COMMENT=       Library to access HTTP/FTP server
+#LICENSE=      modified-bsd
+
+PKG_DESTDIR_SUPPORT=   user-destdir
+
+USE_BSD_MAKEFILE=      yes
+
+INSTALLATION_DIRS=     lib ${PKGMANDIR}/cat3 ${PKGMANDIR}/man3
+
+do-extract:
+       ${CP} -r ${FILESDIR} ${WRKSRC}
+
+.include "options.mk"
+
+.include "../../security/openssl/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff -r 9e87e4a96532 -r df86ce898650 net/libfetch/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfetch/PLIST        Thu Feb 07 01:48:22 2008 +0000
@@ -0,0 +1,4 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2008/02/07 01:48:22 joerg Exp $
+lib/libfetch.a
+man/cat3/fetch.0
+man/man3/fetch.3
diff -r 9e87e4a96532 -r df86ce898650 net/libfetch/buildlink3.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfetch/buildlink3.mk        Thu Feb 07 01:48:22 2008 +0000
@@ -0,0 +1,28 @@
+# $NetBSD: buildlink3.mk,v 1.1.1.1 2008/02/07 01:48:22 joerg Exp $
+
+BUILDLINK_DEPMETHOD.libfetch?= build
+
+BUILDLINK_DEPTH:=              ${BUILDLINK_DEPTH}+
+LIBFETCH_BUILDLINK3_MK:=       ${LIBFETCH_BUILDLINK3_MK}+
+
+.if ${BUILDLINK_DEPTH} == "+"
+BUILDLINK_DEPENDS+=    libfetch
+.endif
+
+BUILDLINK_PACKAGES:=   ${BUILDLINK_PACKAGES:Nlibfetch}
+BUILDLINK_PACKAGES+=   libfetch
+BUILDLINK_ORDER:=      ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}libfetch
+
+.if ${LIBFETCH_BUILDLINK3_MK} == "+"
+BUILDLINK_API_DEPENDS.libfetch+=       libfetch>=2.0
+BUILDLINK_PKGSRCDIR.libfetch?= ../../net/libfetch
+.endif # LIBFETCH_BUILDLINK3_MK
+
+pkgbase := libfetch
+.include "../../mk/pkg-build-options.mk"
+
+.if !empty(PKG_BUILD_OPTIONS.libfetch:Mopenssl)
+.include "../../security/openssl/buildlink3.mk"
+.endif
+
+BUILDLINK_DEPTH:=      ${BUILDLINK_DEPTH:S/+$//}
diff -r 9e87e4a96532 -r df86ce898650 net/libfetch/files/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfetch/files/Makefile       Thu Feb 07 01:48:22 2008 +0000
@@ -0,0 +1,40 @@
+# $NetBSD
+
+LIB=           fetch
+SRCS=          fetch.c common.c ftp.c http.c file.c ftperr.h httperr.h
+INCS=          fetch.h
+MAN=           fetch.3
+CLEANFILES=    ftperr.h httperr.h
+MKLINT=                no
+MKPIC=         no
+MKPROFILE=     no
+
+.include <bsd.own.mk>
+
+CPPFLAGS+=     -I.
+
+FETCH_WITH_INET6?=     no
+FETCH_WITH_OPENSSL?=   no
+
+.if !empty(FETCH_WITH_INET6:M[yY][eE][sS])
+CPPFLAGS+=     -DINET6
+.endif
+
+.if !empty(FETCH_WITH_OPENSSL:M[yY][eE][sS])
+CPPFLAGS+=     -DWITH_SSL
+LDADD=         -lssl -lcrypto
+.endif
+
+CPPFLAGS+=     -DFTP_COMBINE_CWDS
+
+WARNS?=                4
+
+ftperr.h: ${.CURDIR}/ftp.errors ${.CURDIR}/Makefile ${.CURDIR}/errlist.awk
+       awk -v variable=ftp_errlist -v protocol=FTP \
+           -f ${.CURDIR}/errlist.awk ${.CURDIR}/ftp.errors > ${.TARGET}
+
+httperr.h: ${.CURDIR}/http.errors ${.CURDIR}/Makefile ${.CURDIR}/errlist.awk
+       awk -v variable=http_errlist -v protocol=HTTP \
+           -f ${.CURDIR}/errlist.awk ${.CURDIR}/http.errors > ${.TARGET}
+
+.include <bsd.lib.mk>
diff -r 9e87e4a96532 -r df86ce898650 net/libfetch/files/common.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/libfetch/files/common.c       Thu Feb 07 01:48:22 2008 +0000
@@ -0,0 +1,789 @@
+/*     $NetBSD: common.c,v 1.1.1.1 2008/02/07 01:48:22 joerg Exp $     */
+/*-
+ * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
+ * 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
+ *    in this position and unchanged.
+ * 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. 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.
+ *
+ * $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "fetch.h"
+#include "common.h"
+
+#define DECONST(x,y) ((x)(uintptr_t)(y))
+
+
+/*** Local data **************************************************************/
+
+/*
+ * Error messages for resolver errors
+ */
+static struct fetcherr netdb_errlist[] = {
+#ifdef EAI_NODATA
+       { EAI_NODATA,   FETCH_RESOLV,   "Host not found" },
+#endif
+       { EAI_AGAIN,    FETCH_TEMP,     "Transient resolver failure" },
+       { EAI_FAIL,     FETCH_RESOLV,   "Non-recoverable resolver failure" },
+       { EAI_NONAME,   FETCH_RESOLV,   "No address record" },
+       { -1,           FETCH_UNKNOWN,  "Unknown resolver error" }
+};
+
+/* End-of-Line */
+static const char ENDL[2] = "\r\n";
+
+
+/*** Error-reporting functions ***********************************************/
+
+/*
+ * Map error code to string
+ */
+static struct fetcherr *
+fetch_finderr(struct fetcherr *p, int e)
+{
+       while (p->num != -1 && p->num != e)
+               p++;
+       return (p);
+}
+
+/*
+ * Set error code
+ */
+void
+fetch_seterr(struct fetcherr *p, int e)
+{
+       p = fetch_finderr(p, e);
+       fetchLastErrCode = p->cat;
+       snprintf(fetchLastErrString, MAXERRSTRING, "%s", p->string);
+}
+
+/*
+ * Set error code according to errno
+ */
+void
+fetch_syserr(void)
+{
+       switch (errno) {
+       case 0:
+               fetchLastErrCode = FETCH_OK;
+               break;
+       case EPERM:
+       case EACCES:
+       case EROFS:
+       case EAUTH:
+       case ENEEDAUTH:
+               fetchLastErrCode = FETCH_AUTH;
+               break;
+       case ENOENT:
+       case EISDIR: /* XXX */
+               fetchLastErrCode = FETCH_UNAVAIL;
+               break;
+       case ENOMEM:
+               fetchLastErrCode = FETCH_MEMORY;
+               break;
+       case EBUSY:
+       case EAGAIN:
+               fetchLastErrCode = FETCH_TEMP;
+               break;
+       case EEXIST:
+               fetchLastErrCode = FETCH_EXISTS;
+               break;
+       case ENOSPC:
+               fetchLastErrCode = FETCH_FULL;
+               break;
+       case EADDRINUSE:
+       case EADDRNOTAVAIL:
+       case ENETDOWN:
+       case ENETUNREACH:
+       case ENETRESET:
+       case EHOSTUNREACH:
+               fetchLastErrCode = FETCH_NETWORK;
+               break;
+       case ECONNABORTED:
+       case ECONNRESET:
+               fetchLastErrCode = FETCH_ABORT;
+               break;
+       case ETIMEDOUT:
+               fetchLastErrCode = FETCH_TIMEOUT;
+               break;
+       case ECONNREFUSED:
+       case EHOSTDOWN:
+               fetchLastErrCode = FETCH_DOWN;
+               break;
+default:
+               fetchLastErrCode = FETCH_UNKNOWN;
+       }
+       snprintf(fetchLastErrString, MAXERRSTRING, "%s", strerror(errno));
+}
+
+
+/*
+ * Emit status message
+ */
+void
+fetch_info(const char *fmt, ...)
+{
+       va_list ap;



Home | Main Index | Thread Index | Old Index