From: millert Date: Fri, 21 Mar 1997 20:59:26 +0000 (+0000) Subject: Add in recent NetBSD changes we didn't already have: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=04023a617659196fb92ba94dd65986082de6d62f;p=openbsd Add in recent NetBSD changes we didn't already have: Always compile complete.c but ifdef out the bits if -DSMALL (christos) reset interactive mode correctly in auto_fetch() mget mode (lukem) --- diff --git a/usr.bin/ftp/Makefile b/usr.bin/ftp/Makefile index e4ad344a9bb..2df00ea7eab 100644 --- a/usr.bin/ftp/Makefile +++ b/usr.bin/ftp/Makefile @@ -1,19 +1,14 @@ -# $OpenBSD: Makefile,v 1.6 1997/02/03 01:05:31 millert Exp $ -# $NetBSD: Makefile,v 1.8 1997/01/19 14:19:02 lukem Exp $ +# $OpenBSD: Makefile,v 1.7 1997/03/21 20:59:26 millert Exp $ +# $NetBSD: Makefile,v 1.10 1997/03/14 01:39:31 christos Exp $ # from: @(#)Makefile 8.2 (Berkeley) 4/3/94 -# define SMALLFTP if editing is to be disabled -#SMALLFTP=yes +# define SMALL to disable command line editing +#CFLAGS+=-DSMALL PROG= ftp -SRCS= cmds.c cmdtab.c domacro.c fetch.c ftp.c main.c ruserpass.c \ +SRCS= cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c ruserpass.c \ stringlist.c util.c -.if defined(SMALLFTP) -CFLAGS+=-DSMALLFTP -.else -SRCS+= complete.c LDADD+= -ledit -ltermcap -.endif .include diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c index 9d5e923797b..d30743a12f7 100644 --- a/usr.bin/ftp/cmds.c +++ b/usr.bin/ftp/cmds.c @@ -1,5 +1,5 @@ -/* $OpenBSD: cmds.c,v 1.16 1997/03/14 04:32:12 millert Exp $ */ -/* $NetBSD: cmds.c,v 1.19 1997/03/13 06:23:11 lukem Exp $ */ +/* $OpenBSD: cmds.c,v 1.17 1997/03/21 20:59:26 millert Exp $ */ +/* $NetBSD: cmds.c,v 1.21 1997/03/16 14:24:14 lukem Exp $ */ /* * Copyright (c) 1985, 1989, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -static char rcsid[] = "$OpenBSD: cmds.c,v 1.16 1997/03/14 04:32:12 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmds.c,v 1.17 1997/03/21 20:59:26 millert Exp $"; #endif #endif /* not lint */ @@ -669,9 +669,9 @@ status(argc, argv) printf("Hash mark printing: %s; Mark count: %d; Progress bar: %s.\n", onoff(hash), mark, onoff(progress)); printf("Use of PORT cmds: %s.\n", onoff(sendport)); -#ifndef SMALLFTP +#ifndef SMALL printf("Command line editing: %s.\n", onoff(editing)); -#endif /* !SMALLFTP */ +#endif /* !SMALL */ if (macnum > 0) { puts("Macros:"); for (i=0; isl_cur == 1) { /* only once choice available */ - strcpy(insertstr, words->sl_str[0]); + (void)strcpy(insertstr, words->sl_str[0]); if (el_insertstr(el, insertstr + wordlen) == -1) return (CC_ERROR); else @@ -105,7 +106,7 @@ complete_ambiguous(word, list, words) matchlen = j; } if (matchlen > wordlen) { - strncpy(insertstr, lastmatch, matchlen); + (void)strncpy(insertstr, lastmatch, matchlen); insertstr[matchlen] = '\0'; if (el_insertstr(el, insertstr + wordlen) == -1) return (CC_ERROR); @@ -167,16 +168,18 @@ complete_local(word, list) unsigned char rv; if ((file = strrchr(word, '/')) == NULL) { - strcpy(dir, "."); + dir[0] = '.'; + dir[1] = '\0'; file = word; } else { - if (file == word) - strcpy(dir, "/"); - else { - strncpy(dir, word, file - word); + if (file == word) { + dir[0] = '/'; + dir[1] = '\0'; + } else { + (void)strncpy(dir, word, file - word); dir[file - word] = '\0'; } - ++file; + file++; } if ((dd = opendir(dir)) == NULL) @@ -224,7 +227,8 @@ complete_remote(word, list) char *dummyargv[] = { "complete", dir, NULL }; if ((file = strrchr(word, '/')) == NULL) { - (void)strcpy(dir, "."); + dir[0] = '.'; + dir[1] = '\0'; file = word; } else { cp = file; @@ -320,7 +324,7 @@ complete(el, ch) len = lf->lastchar - lf->buffer; if (len >= sizeof(line)) return (CC_ERROR); - strncpy(line, lf->buffer, len); + (void)strncpy(line, lf->buffer, len); line[len] = '\0'; cursor_pos = line + (lf->cursor - lf->buffer); lastc_argc = cursor_argc; /* remember last cursor pos */ @@ -336,7 +340,7 @@ complete(el, ch) && strncmp(word, margv[cursor_argc], cursor_argo) == 0) dolist = 1; else - strncpy(word, margv[cursor_argc], cursor_argo); + (void)strncpy(word, margv[cursor_argc], cursor_argo); word[cursor_argo] = '\0'; if (cursor_argc == 0) @@ -376,3 +380,4 @@ complete(el, ch) return (CC_ERROR); } +#endif diff --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h index 67f4d958a61..e4f3aa6bab1 100644 --- a/usr.bin/ftp/extern.h +++ b/usr.bin/ftp/extern.h @@ -1,5 +1,5 @@ -/* $OpenBSD: extern.h,v 1.9 1997/03/14 04:32:14 millert Exp $ */ -/* $NetBSD: extern.h,v 1.12 1997/03/13 06:23:15 lukem Exp $ */ +/* $OpenBSD: extern.h,v 1.10 1997/03/21 20:59:28 millert Exp $ */ +/* $NetBSD: extern.h,v 1.13 1997/03/14 01:39:37 christos Exp $ */ /*- * Copyright (c) 1994 The Regents of the University of California. @@ -54,9 +54,9 @@ void changetype __P((int, int)); void cmdabort __P((int)); void cmdscanner __P((int)); int command __P((const char *, ...)); -#ifndef SMALLFTP +#ifndef SMALL unsigned char complete __P((EditLine *, int)); -#endif /* !SMALLFTP */ +#endif /* !SMALL */ int confirm __P((const char *, const char *)); FILE *dataconn __P((const char *)); void delete __P((int, char **)); diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 81377527412..f0f5484acca 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,5 +1,5 @@ -/* $OpenBSD: fetch.c,v 1.4 1997/03/14 04:32:14 millert Exp $ */ -/* $NetBSD: fetch.c,v 1.3 1997/03/13 06:23:15 lukem Exp $ */ +/* $OpenBSD: fetch.c,v 1.5 1997/03/21 20:59:29 millert Exp $ */ +/* $NetBSD: fetch.c,v 1.4 1997/03/16 14:24:18 lukem Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fetch.c,v 1.4 1997/03/14 04:32:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: fetch.c,v 1.5 1997/03/21 20:59:29 millert Exp $"; #endif /* not lint */ /* @@ -448,7 +448,7 @@ auto_fetch(argc, argv) * Set up the connection if we don't have one. */ if (strcmp(host, lasthost) != 0) { - strcpy(lasthost, host); + (void)strcpy(lasthost, host); if (connected) disconnect(0, NULL); xargv[0] = __progname; @@ -528,7 +528,7 @@ auto_fetch(argc, argv) interactive = 0; xargv[0] = "mget"; mget(2, xargv); - interactive = 1; + interactive = ointeractive; } else get(2, xargv); diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 99ca67c2a62..bfd62328979 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ftp.c,v 1.15 1997/03/14 23:25:46 millert Exp $ */ -/* $NetBSD: ftp.c,v 1.23 1997/03/13 06:23:17 lukem Exp $ */ +/* $OpenBSD: ftp.c,v 1.16 1997/03/21 20:59:29 millert Exp $ */ +/* $NetBSD: ftp.c,v 1.24 1997/03/16 14:24:19 lukem Exp $ */ /* * Copyright (c) 1985, 1989, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -static char rcsid[] = "$OpenBSD: ftp.c,v 1.15 1997/03/14 23:25:46 millert Exp $"; +static char rcsid[] = "$OpenBSD: ftp.c,v 1.16 1997/03/21 20:59:29 millert Exp $"; #endif #endif /* not lint */ @@ -810,12 +810,14 @@ recvrequest(cmd, local, remote, lmode, printnames) struct stat st; time_t mtime; int oprogress; + int opreserve; hashbytes = mark; direction = "received"; bytes = 0; filesize = -1; oprogress = progress; + opreserve = preserve; is_retr = strcmp(cmd, "RETR") == 0; if (is_retr && verbose && printnames) { if (local && *local != '-') @@ -844,6 +846,7 @@ recvrequest(cmd, local, remote, lmode, printnames) if (oldinti) (void)signal(SIGINFO, oldinti); progress = oprogress; + preserve = opreserve; code = -1; return; } @@ -933,6 +936,7 @@ recvrequest(cmd, local, remote, lmode, printnames) if (strcmp(local, "-") == 0) { fout = stdout; progress = 0; + preserve = 0; } else if (*local == '|') { oldintp = signal(SIGPIPE, SIG_IGN); fout = popen(local + 1, "w"); @@ -941,6 +945,7 @@ recvrequest(cmd, local, remote, lmode, printnames) goto abort; } progress = 0; + preserve = 0; closefunc = pclose; } else { fout = fopen(local, lmode); @@ -976,6 +981,7 @@ recvrequest(cmd, local, remote, lmode, printnames) lseek(fileno(fout), restart_point, SEEK_SET) < 0) { warn("local: %s", local); progress = oprogress; + preserve = opreserve; if (closefunc != NULL) (*closefunc)(fout); return; @@ -1029,6 +1035,7 @@ recvrequest(cmd, local, remote, lmode, printnames) done: warn("local: %s", local); progress = oprogress; + preserve = opreserve; if (closefunc != NULL) (*closefunc)(fout); return; @@ -1084,6 +1091,7 @@ break2: } progressmeter(1); progress = oprogress; + preserve = opreserve; if (closefunc != NULL) (*closefunc)(fout); (void)signal(SIGINT, oldintr); @@ -1116,6 +1124,7 @@ abort: /* abort using RFC959 recommended IP,SYNC sequence */ progress = oprogress; + preserve = opreserve; if (oldintp) (void)signal(SIGPIPE, oldintp); (void)signal(SIGINT, SIG_IGN); diff --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h index 2ab7545fc44..6148f8cd963 100644 --- a/usr.bin/ftp/ftp_var.h +++ b/usr.bin/ftp/ftp_var.h @@ -1,5 +1,5 @@ -/* $OpenBSD: ftp_var.h,v 1.9 1997/03/14 04:32:16 millert Exp $ */ -/* $NetBSD: ftp_var.h,v 1.14 1997/03/13 06:23:19 lukem Exp $ */ +/* $OpenBSD: ftp_var.h,v 1.10 1997/03/21 20:59:30 millert Exp $ */ +/* $NetBSD: ftp_var.h,v 1.15 1997/03/14 01:39:38 christos Exp $ */ /* * Copyright (c) 1985, 1989, 1993, 1994 @@ -43,9 +43,9 @@ #include #include -#ifndef SMALLFTP +#ifndef SMALL #include -#endif /* !SMALLFTP */ +#endif /* !SMALL */ #include "stringlist.h" #include "extern.h" @@ -109,14 +109,14 @@ int dirchange; /* remote directory changed by cd command */ int retry_connect; /* retry connect if failed */ int ttywidth; /* width of tty */ -#ifndef SMALLFTP +#ifndef SMALL int editing; /* command line editing enabled */ EditLine *el; /* editline(3) status structure */ History *hist; /* editline(3) history structure */ char *cursor_pos; /* cursor position we're looking for */ int cursor_argc; /* location of cursor in margv */ int cursor_argo; /* offset of cursor in margv[cursor_argc] */ -#endif /* !SMALLFTP */ +#endif /* !SMALL */ off_t bytes; /* current # of bytes read */ off_t filesize; /* size of file being transferred */ @@ -151,9 +151,9 @@ struct cmd { char c_bell; /* give bell when command completes */ char c_conn; /* must be connected to use command */ char c_proxy; /* proxy server may execute */ -#ifndef SMALLFTP +#ifndef SMALL char *c_complete; /* context sensitive completion list */ -#endif /* !SMALLFTP */ +#endif /* !SMALL */ void (*c_handler) __P((int, char **)); /* function to call */ }; diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index d1d59c3748f..9ba6afcb3b2 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -1,5 +1,5 @@ -/* $OpenBSD: main.c,v 1.24 1997/03/14 05:36:02 millert Exp $ */ -/* $NetBSD: main.c,v 1.18 1997/03/13 06:23:19 lukem Exp $ */ +/* $OpenBSD: main.c,v 1.25 1997/03/21 20:59:30 millert Exp $ */ +/* $NetBSD: main.c,v 1.20 1997/03/16 14:24:21 lukem Exp $ */ /* * Copyright (c) 1985, 1989, 1993, 1994 @@ -44,7 +44,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.24 1997/03/14 05:36:02 millert Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.25 1997/03/21 20:59:30 millert Exp $"; #endif #endif /* not lint */ @@ -92,7 +92,7 @@ main(argc, argv) preserve = 1; verbose = 0; progress = 0; -#ifndef SMALLFTP +#ifndef SMALL editing = 0; #endif mark = HASHBYTES; @@ -106,7 +106,7 @@ main(argc, argv) fromatty = isatty(fileno(stdin)); if (fromatty) { verbose = 1; /* verbose if from a tty */ -#ifndef SMALLFTP +#ifndef SMALL editing = 1; /* editing mode on if from a tty */ #endif } @@ -125,7 +125,7 @@ main(argc, argv) break; case 'e': -#ifndef SMALLFTP +#ifndef SMALL editing = 0; #endif break; @@ -198,7 +198,7 @@ main(argc, argv) (void)strcpy(home, pw->pw_dir); } -#ifndef SMALLFTP +#ifndef SMALL if (editing) { el = el_init(__progname, stdin, stdout); /* init editline */ @@ -217,14 +217,14 @@ main(argc, argv) el_source(el, NULL); /* read ~/.editrc */ } -#endif /* !SMALLFTP */ +#endif /* !SMALL */ setttywidth(0); (void)signal(SIGWINCH, setttywidth); -#ifndef SMALLFTP +#ifndef SMALL if (editing) el_set(el, EL_SIGNAL, 1); -#endif /* !SMALLFTP */ +#endif /* !SMALL */ if (argc > 0) { if (strchr(argv[0], ':') != NULL) { @@ -326,15 +326,15 @@ cmdscanner(top) int num; if (!top -#ifndef SMALLFTP +#ifndef SMALL && !editing -#endif /* !SMALLFTP */ +#endif /* !SMALL */ ) (void)putchar('\n'); for (;;) { -#ifndef SMALLFTP +#ifndef SMALL if (!editing) { -#endif /* !SMALLFTP */ +#endif /* !SMALL */ if (fromatty) { fputs(prompt(), stdout); (void)fflush(stdout); @@ -354,7 +354,7 @@ cmdscanner(top) /* void */; break; } /* else it was a line without a newline */ -#ifndef SMALLFTP +#ifndef SMALL } else { const char *buf; cursor_pos = NULL; @@ -372,7 +372,7 @@ cmdscanner(top) line[num] = '\0'; history(hist, H_ENTER, buf); } -#endif /* !SMALLFTP */ +#endif /* !SMALL */ makeargv(); if (margc == 0) @@ -383,14 +383,14 @@ cmdscanner(top) continue; } if (c == 0) { -#ifndef SMALLFTP +#ifndef SMALL /* * Give editline(3) a shot at unknown commands. * XXX - bogus commands with a colon in * them will not elicit an error. */ if (el_parse(el, margc, margv) != 0) -#endif /* !SMALLFTP */ +#endif /* !SMALL */ puts("?Invalid command."); continue; } @@ -462,7 +462,7 @@ makeargv() if (argp == NULL) break; } -#ifndef SMALLFTP +#ifndef SMALL if (cursor_pos == line) { cursor_argc = 0; cursor_argo = 0; @@ -470,12 +470,12 @@ makeargv() cursor_argc = margc; cursor_argo = strlen(margv[margc-1]); } -#endif /* !SMALLFTP */ +#endif /* !SMALL */ } -#ifdef SMALLFTP +#ifdef SMALL #define INC_CHKCURSOR(x) (x)++ -#else /* !SMALLFTP */ +#else /* !SMALL */ #define INC_CHKCURSOR(x) { (x)++ ; \ if (x == cursor_pos) { \ cursor_argc = margc; \ @@ -483,7 +483,7 @@ makeargv() cursor_pos = NULL; \ } } -#endif /* !SMALLFTP */ +#endif /* !SMALL */ /* * Parse string into argbuf;