Skip to content

Commit

Permalink
sync with 27 (we don't really intend to compile it here...)
Browse files Browse the repository at this point in the history
  • Loading branch information
itojun committed Jun 19, 2000
1 parent 5dfe23e commit 051c2fd
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 20 deletions.
3 changes: 2 additions & 1 deletion openbsd/usr.bin/ftp/Makefile
@@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.15 1998/07/24 00:10:54 millert Exp $
# $OpenBSD: Makefile,v 1.16 1999/12/08 12:57:06 itojun Exp $

# Define SMALL to disable command line editing
#CFLAGS+=-DSMALL
Expand All @@ -15,6 +15,7 @@ PROG= ftp
SRCS= cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c ruserpass.c \
stringlist.c util.c

# not really used at this moment
CPPFLAGS+= -DINET6
CFLAGS+= -Wall
LDADD+= -L${.CURDIR}/../../lib/libinet6 \
Expand Down
4 changes: 2 additions & 2 deletions openbsd/usr.bin/ftp/cmds.c
@@ -1,4 +1,4 @@
/* $OpenBSD: cmds.c,v 1.31 1999/06/29 14:33:23 aaron Exp $ */
/* $OpenBSD: cmds.c,v 1.32 1999/12/08 12:57:06 itojun Exp $ */
/* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */

/*
Expand Down Expand Up @@ -67,7 +67,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
static char rcsid[] = "$OpenBSD: cmds.c,v 1.31 1999/06/29 14:33:23 aaron Exp $";
static char rcsid[] = "$OpenBSD: cmds.c,v 1.32 1999/12/08 12:57:06 itojun Exp $";
#endif
#endif /* not lint */

Expand Down
4 changes: 2 additions & 2 deletions openbsd/usr.bin/ftp/cmdtab.c
@@ -1,4 +1,4 @@
/* $OpenBSD: cmdtab.c,v 1.12 1998/12/24 17:00:12 aaron Exp $ */
/* $OpenBSD: cmdtab.c,v 1.13 1999/12/08 12:57:06 itojun Exp $ */
/* $NetBSD: cmdtab.c,v 1.17 1997/08/18 10:20:17 lukem Exp $ */

/*
Expand Down Expand Up @@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.12 1998/12/24 17:00:12 aaron Exp $";
static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.13 1999/12/08 12:57:06 itojun Exp $";
#endif
#endif /* not lint */

Expand Down
2 changes: 1 addition & 1 deletion openbsd/usr.bin/ftp/extern.h
@@ -1,4 +1,4 @@
/* $OpenBSD: extern.h,v 1.18 1998/07/07 17:26:39 art Exp $ */
/* $OpenBSD: extern.h,v 1.19 1999/12/08 12:57:06 itojun Exp $ */
/* $NetBSD: extern.h,v 1.17 1997/08/18 10:20:19 lukem Exp $ */

/*
Expand Down
23 changes: 17 additions & 6 deletions openbsd/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
/* $OpenBSD: fetch.c,v 1.24 1999/02/09 03:43:48 deraadt Exp $ */
/* $OpenBSD: fetch.c,v 1.30 2000/05/03 19:50:41 deraadt Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */

/*-
Expand Down Expand Up @@ -38,7 +38,7 @@
*/

#ifndef lint
static char rcsid[] = "$OpenBSD: fetch.c,v 1.24 1999/02/09 03:43:48 deraadt Exp $";
static char rcsid[] = "$OpenBSD: fetch.c,v 1.30 2000/05/03 19:50:41 deraadt Exp $";
#endif /* not lint */

/*
Expand Down Expand Up @@ -290,6 +290,16 @@ url_get(origline, proxyenv, outfile)
hints.ai_socktype = SOCK_STREAM;
port = portnum ? portnum : httpport;
error = getaddrinfo(host, port, &hints, &res0);
if (error == EAI_SERVICE && port == httpport) {
/*
* If the services file is corrupt/missing, fall back
* on our hard-coded defines.
*/
char pbuf[NI_MAXSERV];

snprintf(pbuf, sizeof(pbuf), "%d", HTTP_PORT);
error = getaddrinfo(host, pbuf, &hints, &res0);
}
if (error) {
warnx("%s: %s", gai_strerror(error), host);
goto cleanup_url_get;
Expand Down Expand Up @@ -836,10 +846,11 @@ int
isurl(p)
const char *p;
{

if (strncasecmp(p, FTP_URL, sizeof(FTP_URL) - 1) == 0 ||
strncasecmp(p, HTTP_URL, sizeof(HTTP_URL) - 1) == 0 ||
strncasecmp(p, FILE_URL, sizeof(FILE_URL) - 1) == 0) {
return 1;
}
return 0;
strncasecmp(p, FILE_URL, sizeof(FILE_URL) - 1) == 0 ||
strstr(p, ":/"))
return (1);
return (0);
}
21 changes: 19 additions & 2 deletions openbsd/usr.bin/ftp/ftp.c
@@ -1,4 +1,4 @@
/* $OpenBSD: ftp.c,v 1.33 1998/12/13 21:01:29 millert Exp $ */
/* $OpenBSD: ftp.c,v 1.35 2000/05/03 19:50:41 deraadt Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */

/*
Expand Down Expand Up @@ -67,7 +67,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
static char rcsid[] = "$OpenBSD: ftp.c,v 1.33 1998/12/13 21:01:29 millert Exp $";
static char rcsid[] = "$OpenBSD: ftp.c,v 1.35 2000/05/03 19:50:41 deraadt Exp $";
#endif
#endif /* not lint */

Expand Down Expand Up @@ -145,6 +145,23 @@ hookup(host, port)
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
error = getaddrinfo(host, port, &hints, &res0);
if (error == EAI_SERVICE) {
/*
* If the services file is corrupt/missing, fall back
* on our hard-coded defines.
*/
char pbuf[NI_MAXSERV];

pbuf[0] = '\0';
if (strcmp(port, "ftp") == 0)
snprintf(pbuf, sizeof(pbuf), "%d", FTP_PORT);
else if (strcmp(port, "ftpgate") == 0)
snprintf(pbuf, sizeof(pbuf), "%d", GATE_PORT);
else if (strcmp(port, "http") == 0)
snprintf(pbuf, sizeof(pbuf), "%d", HTTP_PORT);
if (pbuf[0])
error = getaddrinfo(host, pbuf, &hints, &res0);
}
if (error) {
warn(gai_strerror(error));
code = -1;
Expand Down
2 changes: 1 addition & 1 deletion openbsd/usr.bin/ftp/ftp_var.h
@@ -1,4 +1,4 @@
/* $OpenBSD: ftp_var.h,v 1.17 1997/12/17 16:03:04 millert Exp $ */
/* $OpenBSD: ftp_var.h,v 1.18 1999/12/08 12:57:06 itojun Exp $ */
/* $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $ */

/*
Expand Down
7 changes: 4 additions & 3 deletions openbsd/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.43 1998/11/21 02:58:37 d Exp $ */
/* $OpenBSD: main.c,v 1.45 2000/03/22 15:38:23 markus Exp $ */
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */

/*
Expand Down Expand Up @@ -73,7 +73,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
static char rcsid[] = "$OpenBSD: main.c,v 1.43 1998/11/21 02:58:37 d Exp $";
static char rcsid[] = "$OpenBSD: main.c,v 1.45 2000/03/22 15:38:23 markus Exp $";
#endif
#endif /* not lint */

Expand Down Expand Up @@ -450,7 +450,8 @@ cmdscanner(top)
* XXX - bogus commands with a colon in
* them will not elicit an error.
*/
if (el_parse(el, margc, margv) != 0)
if (editing &&
el_parse(el, margc, margv) != 0)
#endif /* !SMALL */
fputs("?Invalid command.\n", ttyout);
continue;
Expand Down
24 changes: 22 additions & 2 deletions openbsd/usr.bin/ftp/util.c
@@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.21 1998/09/22 04:42:49 deraadt Exp $ */
/* $OpenBSD: util.c,v 1.23 2000/02/01 20:53:06 espie Exp $ */
/* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */

/*
Expand Down Expand Up @@ -35,7 +35,7 @@
*/

#ifndef lint
static char rcsid[] = "$OpenBSD: util.c,v 1.21 1998/09/22 04:42:49 deraadt Exp $";
static char rcsid[] = "$OpenBSD: util.c,v 1.23 2000/02/01 20:53:06 espie Exp $";
#endif /* not lint */

/*
Expand Down Expand Up @@ -565,6 +565,26 @@ remotemodtime(file, noisy)
if (command("MDTM %s", file) == COMPLETE) {
struct tm timebuf;
int yy, mo, day, hour, min, sec;
/*
* time-val = 14DIGIT [ "." 1*DIGIT ]
* YYYYMMDDHHMMSS[.sss]
* mdtm-response = "213" SP time-val CRLF / error-response
*/
/* TODO: parse .sss as well, use timespecs. */
char *timestr = reply_string;

/* Repair `19%02d' bug on server side */
while (!isspace(*timestr))
timestr++;
while (isspace(*timestr))
timestr++;
if (strncmp(timestr, "191", 3) == 0) {
fprintf(ttyout,
"Y2K warning! Fixed incorrect time-val received from server.\n");
timestr[0] = ' ';
timestr[1] = '2';
timestr[2] = '0';
}
sscanf(reply_string, "%*s %04d%02d%02d%02d%02d%02d", &yy, &mo,
&day, &hour, &min, &sec);
memset(&timebuf, 0, sizeof(timebuf));
Expand Down

0 comments on commit 051c2fd

Please sign in to comment.