- /* $NetBSD: cmds.c,v 1.132 2011/09/16 15:39:26 joerg Exp $ */
+ /* $NetBSD: cmds.c,v 1.134 2012/01/15 20:43:24 christos Exp $ */
/*-
* Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
- __RCSID("$NetBSD: cmds.c,v 1.132 2011/09/16 15:39:26 joerg Exp $");
+ __RCSID("$NetBSD: cmds.c,v 1.134 2012/01/15 20:43:24 christos Exp $");
#endif
#endif /* not lint */
#include <ctype.h>
#include <err.h>
+ #include <errno.h>
#include <glob.h>
#include <limits.h>
#include <netdb.h>
#include <paths.h>
#include <stddef.h>
#include <stdio.h>
+#include <libutil.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
reget(int argc, char *argv[])
{
- (void)getit(argc, argv, 1, "r+");
+ (void)getit(argc, argv, 1, restart_point ? "r+" : "a");
}
void
get(int argc, char *argv[])
{
- (void)getit(argc, argv, 0, restart_point ? "r+" : "w" );
+ (void)getit(argc, argv, 0, restart_point ? "r+" : "w");
}
/*
ret = stat(locfile, &stbuf);
if (restartit == 1) {
if (ret < 0) {
- warn("Can't stat `%s'", locfile);
- goto freegetit;
+ if (errno != ENOENT) {
+ warn("Can't stat `%s'", locfile);
+ goto freegetit;
+ }
+ restart_point = 0;
}
- restart_point = stbuf.st_size;
+ else
+ restart_point = stbuf.st_size;
} else {
if (ret == 0) {
time_t mtime;
- /* $NetBSD: fetch.c,v 1.195 2011/12/10 05:53:58 lukem Exp $ */
+ /* $NetBSD: fetch.c,v 1.198 2012/07/04 06:09:37 is Exp $ */
/*-
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#ifndef lint
- __RCSID("$NetBSD: fetch.c,v 1.195 2011/12/10 05:53:58 lukem Exp $");
+ __RCSID("$NetBSD: fetch.c,v 1.198 2012/07/04 06:09:37 is Exp $");
#endif /* not lint */
/*
#include <netdb.h>
#include <fcntl.h>
#include <stdio.h>
+#include <libutil.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
hints.ai_protocol = 0;
error = getaddrinfo(host, port, &hints, &res0);
if (error) {
- warnx("Can't lookup `%s:%s': %s", host, port,
+ warnx("Can't LOOKUP `%s:%s': %s", host, port,
(error == EAI_SYSTEM) ? strerror(errno)
: gai_strerror(error));
goto cleanup_fetch_url;
continue;
}
- if (ftp_connect(s, res->ai_addr, res->ai_addrlen) < 0) {
+ if (ftp_connect(s, res->ai_addr, res->ai_addrlen,
+ verbose || !res->ai_next) < 0) {
close(s);
s = -1;
continue;
go_fetch(const char *url)
{
char *proxyenv;
+ char *p;
#ifndef NO_ABOUT
/*
return (fetch_url(url, NULL, NULL, NULL));
/*
+ * If it contains "://" but does not begin with ftp://
+ * or something that was already handled, then it's
+ * unsupported.
+ *
+ * If it contains ":" but not "://" then we assume the
+ * part before the colon is a host name, not an URL scheme,
+ * so we don't try to match that here.
+ */
+ if ((p = strstr(url, "://")) != NULL && ! STRNEQUAL(url, FTP_URL))
+ errx(1, "Unsupported URL scheme `%.*s'", (int)(p - url), url);
+
+ /*
* Try FTP URL-style and host:file arguments next.
* If ftpproxy is set with an FTP URL, use fetch_url()
* Othewise, use fetch_ftp().
- /* $NetBSD: util.c,v 1.156 2011/12/10 05:53:58 lukem Exp $ */
+ /* $NetBSD: util.c,v 1.157 2012/07/04 06:09:37 is Exp $ */
/*-
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#ifndef lint
- __RCSID("$NetBSD: util.c,v 1.156 2011/12/10 05:53:58 lukem Exp $");
+ __RCSID("$NetBSD: util.c,v 1.157 2012/07/04 06:09:37 is Exp $");
#endif /* not lint */
/*
* error message displayed.)
*/
int
- ftp_connect(int sock, const struct sockaddr *name, socklen_t namelen)
+ ftp_connect(int sock, const struct sockaddr *name, socklen_t namelen, int pe)
{
int flags, rv, timeout, error;
socklen_t slen;
rv = connect(sock, name, namelen); /* inititate the connection */
if (rv == -1) { /* connection error */
if (errno != EINPROGRESS) { /* error isn't "please wait" */
+ if (pe || (errno != EHOSTUNREACH))
connecterror:
- warn("Can't connect to `%s:%s'", hname, sname);
+ warn("Can't connect to `%s:%s'", hname, sname);
return -1;
}
ftp_sl_add(StringList *sl, char *i)
{
- if (sl_add(sl, i) == -1)
- err(1, "Unable to add `%s' to stringlist", i);
+ sl_add(sl, i);
}
/*