Module Name:    src
Committed By:   snj
Date:           Sat May 30 15:58:17 UTC 2009

Modified Files:
        src/external/bsd/fetch/dist/libfetch [netbsd-5-0]: common.c common.h
            errlist.sh fetch.3 fetch.c fetch.cat3 fetch.h file.c ftp.c
            ftp.errors http.c http.errors

Log Message:
Pull up following revision(s) (requested by joerg in ticket #670):
        external/bsd/fetch/dist/libfetch/common.c: libfetch-2-23
        external/bsd/fetch/dist/libfetch/common.h: libfetch-2-23
        external/bsd/fetch/dist/libfetch/errlist.sh: libfetch-2-23
        external/bsd/fetch/dist/libfetch/fetch.3: libfetch-2-23
        external/bsd/fetch/dist/libfetch/fetch.c: libfetch-2-23
        external/bsd/fetch/dist/libfetch/fetch.cat3: libfetch-2-23
        external/bsd/fetch/dist/libfetch/fetch.h: libfetch-2-23
        external/bsd/fetch/dist/libfetch/file.c: libfetch-2-23
        external/bsd/fetch/dist/libfetch/ftp.c: libfetch-2-23
        external/bsd/fetch/dist/libfetch/ftp.errors: libfetch-2-23
        external/bsd/fetch/dist/libfetch/http.c: libfetch-2-23
        external/bsd/fetch/dist/libfetch/http.errors: libfetch-2-23
Pull up libfetch-2.23:
- if-not-modified support
- document that struct URL is not part of the ABI
- fetchRestartCalls cleanup for signal handlers
- allow HTTP basic auth to be specified in the URL, allow : as part of
  the cleartext password
- fix a file descriptor leak in the file:// iteration code


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.1.1.2.8.1 \
    src/external/bsd/fetch/dist/libfetch/common.c \
    src/external/bsd/fetch/dist/libfetch/common.h \
    src/external/bsd/fetch/dist/libfetch/errlist.sh \
    src/external/bsd/fetch/dist/libfetch/fetch.h \
    src/external/bsd/fetch/dist/libfetch/file.c \
    src/external/bsd/fetch/dist/libfetch/ftp.errors \
    src/external/bsd/fetch/dist/libfetch/http.c \
    src/external/bsd/fetch/dist/libfetch/http.errors
cvs rdiff -u -r1.1.1.3 -r1.1.1.3.6.1 \
    src/external/bsd/fetch/dist/libfetch/fetch.3 \
    src/external/bsd/fetch/dist/libfetch/ftp.c
cvs rdiff -u -r1.1.1.3 -r1.1.1.3.4.1 \
    src/external/bsd/fetch/dist/libfetch/fetch.c
cvs rdiff -u -r1.1.1.2 -r1.1.1.2.6.1 \
    src/external/bsd/fetch/dist/libfetch/fetch.cat3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/fetch/dist/libfetch/common.c
diff -u src/external/bsd/fetch/dist/libfetch/common.c:1.1.1.2 src/external/bsd/fetch/dist/libfetch/common.c:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/common.c:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/common.c	Sat May 30 15:58:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: common.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $	*/
+/*	$NetBSD: common.c,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $	*/
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008 Joerg Sonnenberger <[email protected]>
@@ -42,8 +42,8 @@
 #include <sys/time.h>
 #include <sys/uio.h>
 
-#include <arpa/inet.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 
 #include <ctype.h>
 #include <errno.h>
@@ -728,6 +728,7 @@
 
 	tmp->offset = 0;
 	tmp->length = 0;
+	tmp->last_modified = -1;
 
 	++ue->length;
 
Index: src/external/bsd/fetch/dist/libfetch/common.h
diff -u src/external/bsd/fetch/dist/libfetch/common.h:1.1.1.2 src/external/bsd/fetch/dist/libfetch/common.h:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/common.h:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/common.h	Sat May 30 15:58:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: common.h,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $	*/
+/*	$NetBSD: common.h,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $	*/
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * All rights reserved.
@@ -46,7 +46,8 @@
 #endif
 
 #if !defined(__sun) && !defined(__hpux) && !defined(__INTERIX) && \
-    !defined(__digital__) && !defined(__linux) && !defined(__sgi)
+    !defined(__digital__) && !defined(__linux) && !defined(__MINT__) && \
+    !defined(__sgi)
 #define HAVE_SA_LEN
 #endif
 
Index: src/external/bsd/fetch/dist/libfetch/errlist.sh
diff -u src/external/bsd/fetch/dist/libfetch/errlist.sh:1.1.1.2 src/external/bsd/fetch/dist/libfetch/errlist.sh:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/errlist.sh:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/errlist.sh	Sat May 30 15:58:17 2009
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: errlist.sh,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $
+# $NetBSD: errlist.sh,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $
 
 printf "static struct fetcherr $1[] = {\n"
 while read code type msg; do
Index: src/external/bsd/fetch/dist/libfetch/fetch.h
diff -u src/external/bsd/fetch/dist/libfetch/fetch.h:1.1.1.2 src/external/bsd/fetch/dist/libfetch/fetch.h:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/fetch.h:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/fetch.h	Sat May 30 15:58:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: fetch.h,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $	*/
+/*	$NetBSD: fetch.h,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $	*/
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * All rights reserved.
@@ -54,6 +54,7 @@
 	char		*doc;
 	off_t		 offset;
 	size_t		 length;
+	time_t		 last_modified;
 };
 
 struct url_stat {
@@ -94,6 +95,7 @@
 #define	FETCH_UNKNOWN	17
 #define	FETCH_URL	18
 #define	FETCH_VERBOSE	19
+#define	FETCH_UNCHANGED	20
 
 #if defined(__cplusplus)
 extern "C" {
@@ -168,7 +170,7 @@
 extern int		 fetchTimeout;
 
 /* Restart interrupted syscalls */
-extern int		 fetchRestartCalls;
+extern volatile int	 fetchRestartCalls;
 
 /* Extra verbosity */
 extern int		 fetchDebug;
Index: src/external/bsd/fetch/dist/libfetch/file.c
diff -u src/external/bsd/fetch/dist/libfetch/file.c:1.1.1.2 src/external/bsd/fetch/dist/libfetch/file.c:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/file.c:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/file.c	Sat May 30 15:58:17 2009
@@ -1,7 +1,7 @@
-/*	$NetBSD: file.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $	*/
+/*	$NetBSD: file.c,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $	*/
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
- * Copyright (c) 2008 Joerg Sonnenberger <[email protected]>
+ * Copyright (c) 2008, 2009 Joerg Sonnenberger <[email protected]>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,12 @@
 {
 	char *path;
 	fetchIO *f;
-	int fd, *cookie;
+	struct url_stat local_us;
+	int if_modified_since, fd, *cookie;
+
+	if_modified_since = CHECK_FLAG('i');
+	if (if_modified_since && us == NULL)
+		us = &local_us;
 
 	if ((path = fetchUnquotePath(u)) == NULL) {
 		fetch_syserr();
@@ -95,6 +100,15 @@
 
 	if (us && fetch_stat_file(fd, us) == -1) {
 		close(fd);
+		fetch_syserr();
+		return NULL;
+	}
+
+	if (if_modified_since && u->last_modified > 0 &&
+	    u->last_modified >= us->mtime) {
+		close(fd);
+		fetchLastErrCode = FETCH_UNCHANGED;
+		snprintf(fetchLastErrString, MAXERRSTRING, "Unchanged");
 		return NULL;
 	}
 
@@ -240,5 +254,7 @@
 		fetch_add_entry(ue, u, de->d_name, 0);
 	}
 
+	closedir(dir);
+
 	return 0;
 }
Index: src/external/bsd/fetch/dist/libfetch/ftp.errors
diff -u src/external/bsd/fetch/dist/libfetch/ftp.errors:1.1.1.2 src/external/bsd/fetch/dist/libfetch/ftp.errors:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/ftp.errors:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/ftp.errors	Sat May 30 15:58:17 2009
@@ -1,4 +1,4 @@
-# $NetBSD: ftp.errors,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $
+# $NetBSD: ftp.errors,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $
 # $FreeBSD: ftp.errors,v 1.6 2002/10/30 06:06:16 des Exp $
 #
 # This list is taken from RFC 959.
Index: src/external/bsd/fetch/dist/libfetch/http.c
diff -u src/external/bsd/fetch/dist/libfetch/http.c:1.1.1.2 src/external/bsd/fetch/dist/libfetch/http.c:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/http.c:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/http.c	Sat May 30 15:58:17 2009
@@ -1,8 +1,8 @@
-/*	$NetBSD: http.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $	*/
+/*	$NetBSD: http.c,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $	*/
 /*-
  * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2003 Thomas Klausner <[email protected]>
- * Copyright (c) 2008 Joerg Sonnenberger <[email protected]>
+ * Copyright (c) 2008, 2009 Joerg Sonnenberger <[email protected]>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -63,11 +63,14 @@
  * SUCH DAMAGE.
  */
 
-#ifdef __linux__
-/* Keep this down to Linux, it can create surprises else where. */
+#if defined(__linux__) || defined(__MINT__)
+/* Keep this down to Linux or MiNT, it can create surprises elsewhere. */
 #define _GNU_SOURCE
 #endif
 
+/* Needed for gmtime_r on Interix */
+#define _REENTRANT
+
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -83,10 +86,8 @@
 #include <locale.h>
 #include <stdarg.h>
 #ifndef NETBSD
-#include <nbcompat/netdb.h>
 #include <nbcompat/stdio.h>
 #else
-#include <netdb.h>
 #include <stdio.h>
 #endif
 #include <stdlib.h>
@@ -94,11 +95,17 @@
 #include <time.h>
 #include <unistd.h>
 
-#include <arpa/inet.h>
-
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 
+#ifndef NETBSD
+#include <nbcompat/netdb.h>
+#else
+#include <netdb.h>
+#endif
+
+#include <arpa/inet.h>
+
 #include "fetch.h"
 #include "common.h"
 #include "httperr.h"
@@ -112,6 +119,7 @@
 #define HTTP_MOVED_PERM		301
 #define HTTP_MOVED_TEMP		302
 #define HTTP_SEE_OTHER		303
+#define HTTP_NOT_MODIFIED	304
 #define HTTP_TEMP_REDIRECT	307
 #define HTTP_NEED_AUTH		401
 #define HTTP_NEED_PROXY_AUTH	407
@@ -745,6 +753,21 @@
 	return (NULL);
 }
 
+static void
+set_if_modified_since(conn_t *conn, time_t last_modified)
+{
+	static const char weekdays[] = "SunMonTueWedThuFriSat";
+	static const char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
+	struct tm tm;
+	char buf[80];
+	gmtime_r(&last_modified, &tm);
+	snprintf(buf, sizeof(buf), "%.3s, %02d %.3s %4d %02d:%02d:%02d GMT",
+	    weekdays + tm.tm_wday * 3, tm.tm_mday, months + tm.tm_mon * 3,
+	    tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
+	http_cmd(conn, "If-Modified-Since: %s", buf);
+}
+
+
 /*****************************************************************************
  * Core
  */
@@ -761,7 +784,7 @@
 {
 	conn_t *conn;
 	struct url *url, *new;
-	int chunked, direct, need_auth, noredirect, verbose;
+	int chunked, direct, if_modified_since, need_auth, noredirect, verbose;
 	int e, i, n, val;
 	off_t offset, clength, length, size;
 	time_t mtime;
@@ -773,6 +796,7 @@
 	direct = CHECK_FLAG('d');
 	noredirect = CHECK_FLAG('A');
 	verbose = CHECK_FLAG('v');
+	if_modified_since = CHECK_FLAG('i');
 
 	if (direct && purl) {
 		fetchFreeURL(purl);
@@ -841,6 +865,9 @@
 			    op, url->doc);
 		}
 
+		if (if_modified_since && url->last_modified > 0)
+			set_if_modified_since(conn, url->last_modified);
+
 		/* virtual host */
 		http_cmd(conn, "Host: %s", host);
 
@@ -904,6 +931,7 @@
 		switch (http_get_reply(conn)) {
 		case HTTP_OK:
 		case HTTP_PARTIAL:
+		case HTTP_NOT_MODIFIED:
 			/* fine */
 			break;
 		case HTTP_MOVED_PERM:
@@ -1036,7 +1064,10 @@
 		}
 
 		/* we have a hit or an error */
-		if (conn->err == HTTP_OK || conn->err == HTTP_PARTIAL || HTTP_ERROR(conn->err))
+		if (conn->err == HTTP_OK ||
+		    conn->err == HTTP_PARTIAL ||
+		    conn->err == HTTP_NOT_MODIFIED ||
+		    HTTP_ERROR(conn->err))
 			break;
 
 		/* all other cases: we got a redirect */
@@ -1089,6 +1120,11 @@
 	URL->offset = offset;
 	URL->length = clength;
 
+	if (conn->err == HTTP_NOT_MODIFIED) {
+		http_seterr(HTTP_NOT_MODIFIED);
+		return (NULL);
+	}
+
 	/* wrap it up in a fetchIO */
 	if ((f = http_funopen(conn, chunked)) == NULL) {
 		fetch_syserr();
Index: src/external/bsd/fetch/dist/libfetch/http.errors
diff -u src/external/bsd/fetch/dist/libfetch/http.errors:1.1.1.2 src/external/bsd/fetch/dist/libfetch/http.errors:1.1.1.2.8.1
--- src/external/bsd/fetch/dist/libfetch/http.errors:1.1.1.2	Tue Oct  7 15:55:20 2008
+++ src/external/bsd/fetch/dist/libfetch/http.errors	Sat May 30 15:58:17 2009
@@ -1,5 +1,5 @@
 # $FreeBSD: http.errors,v 1.5 2001/05/23 18:52:02 des Exp $
-# $NetBSD: http.errors,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $
+# $NetBSD: http.errors,v 1.1.1.2.8.1 2009/05/30 15:58:17 snj Exp $
 #
 # This list is taken from RFC 2068.
 #
@@ -16,7 +16,7 @@
 301 MOVED	Moved Permanently
 302 MOVED	Moved Temporarily
 303 MOVED	See Other
-304 OK		Not Modified
+304 UNCHANGED	Not Modified
 305 INFO	Use Proxy
 307 MOVED	Temporary Redirect
 400 PROTO	Bad Request

Index: src/external/bsd/fetch/dist/libfetch/fetch.3
diff -u src/external/bsd/fetch/dist/libfetch/fetch.3:1.1.1.3 src/external/bsd/fetch/dist/libfetch/fetch.3:1.1.1.3.6.1
--- src/external/bsd/fetch/dist/libfetch/fetch.3:1.1.1.3	Wed Oct 29 16:18:13 2008
+++ src/external/bsd/fetch/dist/libfetch/fetch.3	Sat May 30 15:58:17 2009
@@ -24,9 +24,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD: fetch.3,v 1.64 2007/12/18 11:03:26 des Exp $
-.\" $NetBSD: fetch.3,v 1.1.1.3 2008/10/29 16:18:13 joerg Exp $
+.\" $NetBSD: fetch.3,v 1.1.1.3.6.1 2009/05/30 15:58:17 snj Exp $
 .\"
-.Dd April 25, 2008
+.Dd February 4, 2009
 .Dt FETCH 3
 .Os
 .Sh NAME
@@ -148,8 +148,8 @@
 its components function according to the Common Internet Scheme Syntax
 detailed in RFC 1738.
 A regular expression which produces this syntax is:
-.Bd -literal
-    \*[Lt]scheme\*[Gt]:(//(\*[Lt]user\*[Gt](:\*[Lt]pwd\*[Gt])?@)?\*[Lt]host\*[Gt](:\*[Lt]port\*[Gt])?)?/(\*[Lt]document\*[Gt])?
+.Bd -literal -offset indent
+\*[Lt]scheme\*[Gt]:(//(\*[Lt]user\*[Gt](:\*[Lt]pwd\*[Gt])?@)?\*[Lt]host\*[Gt](:\*[Lt]port\*[Gt])?)?/(\*[Lt]document\*[Gt])?
 .Ed
 .Pp
 If the URL does not seem to begin with a scheme name, it is assumed to be a local path.
@@ -194,6 +194,7 @@
     char	*doc;
     off_t	 offset;
     size_t	 length;
+    time_t	 last_modified;
 };
 .Ed
 .Pp
@@ -204,6 +205,9 @@
 .Fn fetchParseURL
 should be freed using
 .Fn fetchFreeURL .
+The size of
+.Vt struct URL
+is not part of the ABI.
 .Pp
 .Fn fetchXGetURL ,
 .Fn fetchGetURL ,
@@ -326,6 +330,19 @@
 functions is read-only, and that a stream returned by one of the
 .Fn fetchPutXXX
 functions is write-only.
+.Sh PROTOCOL INDEPENDENT FLAGS
+If the
+.Ql i
+(if-modified-since) flag is specified, the library will try to fetch
+the content only if it is newer than
+.Va last_modified .
+For HTTP an
+.Li If-Modified-Since
+HTTP header is sent.
+For FTP a
+.Li MTDM
+command is sent first and compared locally.
+For FILE the source file is compared.
 .Sh FILE SCHEME
 .Fn fetchXGetFile ,
 .Fn fetchGetFile ,
Index: src/external/bsd/fetch/dist/libfetch/ftp.c
diff -u src/external/bsd/fetch/dist/libfetch/ftp.c:1.1.1.3 src/external/bsd/fetch/dist/libfetch/ftp.c:1.1.1.3.6.1
--- src/external/bsd/fetch/dist/libfetch/ftp.c:1.1.1.3	Wed Oct 29 16:18:14 2008
+++ src/external/bsd/fetch/dist/libfetch/ftp.c	Sat May 30 15:58:17 2009
@@ -1,7 +1,7 @@
-/*	$NetBSD: ftp.c,v 1.1.1.3 2008/10/29 16:18:14 joerg Exp $	*/
+/*	$NetBSD: ftp.c,v 1.1.1.3.6.1 2009/05/30 15:58:17 snj Exp $	*/
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
- * Copyright (c) 2008 Joerg Sonnenberger <[email protected]>
+ * Copyright (c) 2008, 2009 Joerg Sonnenberger <[email protected]>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -57,6 +57,11 @@
  *
  */
 
+#ifdef __linux__
+/* Keep this down to Linux, it can create surprises else where. */
+#define _GNU_SOURCE
+#endif
+
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -67,8 +72,8 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include <arpa/inet.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 
 #include <ctype.h>
 #include <errno.h>
@@ -1122,7 +1127,8 @@
 	fetchIO *f;
 	char *path;
 	conn_t *conn;
-	int oflag;
+	int if_modified_since, oflag;
+	struct url_stat local_us;
 
 	/* check if we should use HTTP instead */
 	if (purl && strcasecmp(purl->scheme, SCHEME_HTTP) == 0) {
@@ -1154,6 +1160,10 @@
 		return (NULL);
 	}
 
+	if_modified_since = CHECK_FLAG('i');
+	if (if_modified_since && us == NULL)
+		us = &local_us;
+
 	/* stat file */
 	if (us && ftp_stat(conn, path, us) == -1
 	    && fetchLastErrCode != FETCH_PROTO
@@ -1162,6 +1172,13 @@
 		return (NULL);
 	}
 
+	if (if_modified_since && url->last_modified > 0 &&
+	    url->last_modified >= us->mtime) {
+		fetchLastErrCode = FETCH_UNCHANGED;
+		snprintf(fetchLastErrString, MAXERRSTRING, "Unchanged");
+		return NULL;
+	}
+
 	/* just a stat */
 	if (strcmp(op, "STAT") == 0)
 		return fetchIO_unopen(NULL, NULL, NULL, NULL);

Index: src/external/bsd/fetch/dist/libfetch/fetch.c
diff -u src/external/bsd/fetch/dist/libfetch/fetch.c:1.1.1.3 src/external/bsd/fetch/dist/libfetch/fetch.c:1.1.1.3.4.1
--- src/external/bsd/fetch/dist/libfetch/fetch.c:1.1.1.3	Wed Oct 29 16:18:13 2008
+++ src/external/bsd/fetch/dist/libfetch/fetch.c	Sat May 30 15:58:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: fetch.c,v 1.1.1.3 2008/10/29 16:18:13 joerg Exp $	*/
+/*	$NetBSD: fetch.c,v 1.1.1.3.4.1 2009/05/30 15:58:17 snj Exp $	*/
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008 Joerg Sonnenberger <[email protected]>
@@ -50,7 +50,7 @@
 int	 fetchLastErrCode;
 char	 fetchLastErrString[MAXERRSTRING];
 int	 fetchTimeout;
-int	 fetchRestartCalls = 1;
+volatile int	 fetchRestartCalls = 1;
 int	 fetchDebug;
 
 
@@ -417,7 +417,7 @@
 		}
 		URL += 2;
 		p = URL;
-		goto find_hostname;
+		goto find_user;
 	}
 	if (strncmp(URL, "ftp:", 4) == 0) {
 		pre_quoted = 1;
@@ -446,7 +446,7 @@
 
 		/* password */
 		if (*q == ':') {
-			for (q++, i = 0; (*q != ':') && (*q != '@'); q++)
+			for (q++, i = 0; (*q != '@'); q++)
 				if (i < URL_PWDLEN)
 					u->pwd[i++] = *q;
 		}
@@ -456,7 +456,6 @@
 		p = URL;
 	}
 
-find_hostname:
 	/* hostname */
 #ifdef INET6
 	if (*p == '[' && (q = strchr(p + 1, ']')) != NULL &&

Index: src/external/bsd/fetch/dist/libfetch/fetch.cat3
diff -u src/external/bsd/fetch/dist/libfetch/fetch.cat3:1.1.1.2 src/external/bsd/fetch/dist/libfetch/fetch.cat3:1.1.1.2.6.1
--- src/external/bsd/fetch/dist/libfetch/fetch.cat3:1.1.1.2	Wed Oct 29 16:18:14 2008
+++ src/external/bsd/fetch/dist/libfetch/fetch.cat3	Sat May 30 15:58:17 2009
@@ -157,10 +157,12 @@
          char        *doc;
          off_t        offset;
          size_t       length;
+         time_t       last_modified;
      };
 
      The pointer returned by ffeettcchhMMaakkeeUURRLL(), ffeettcchhCCooppyyUURRLL(), and
-     ffeettcchhPPaarrsseeUURRLL() should be freed using ffeettcchhFFrreeeeUURRLL().
+     ffeettcchhPPaarrsseeUURRLL() should be freed using ffeettcchhFFrreeeeUURRLL().  The size of _s_t_r_u_c_t
+     _U_R_L is not part of the ABI.
 
      ffeettcchhXXGGeettUURRLL(), ffeettcchhGGeettUURRLL(), and ffeettcchhPPuuttUURRLL() constitute the recom-
      mended interface to the ffeettcchh library.  They examine the URL passed to
@@ -225,6 +227,12 @@
      ffeettcchhGGeettXXXXXX() functions is read-only, and that a stream returned by one
      of the ffeettcchhPPuuttXXXXXX() functions is write-only.
 
+PPRROOTTOOCCOOLL IINNDDEEPPEENNDDEENNTT FFLLAAGGSS
+     If the `i' (if-modified-since) flag is specified, the library will try to
+     fetch the content only if it is newer than _l_a_s_t___m_o_d_i_f_i_e_d.  For HTTP an
+     If-Modified-Since HTTP header is sent.  For FTP a MTDM command is sent
+     first and compared locally.  For FILE the source file is compared.
+
 FFIILLEE SSCCHHEEMMEE
      ffeettcchhXXGGeettFFiillee(), ffeettcchhGGeettFFiillee(), and ffeettcchhPPuuttFFiillee() provide access to
      documents which are files in a locally mounted file system.  Only the
@@ -495,4 +503,4 @@
 
      Some parts of the code are not fully reentrant.
 
-NetBSD 4.0                      April 25, 2008                      NetBSD 4.0
+NetBSD 5.0                     February 4, 2009                     NetBSD 5.0

Reply via email to