-# $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 <bsd.prog.mk>
-/* $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
#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 */
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; i<macnum; i++) {
code = togglevar(argc, argv, &bell, "Bell mode");
}
-#ifndef SMALLFTP
+#ifndef SMALL
/*
* Set command line editing
*/
code = togglevar(argc, argv, &editing, "Editing mode");
}
-#endif /* !SMALLFTP */
+#endif /* !SMALL */
/*
* Turn on packet tracing.
-/* $OpenBSD: cmdtab.c,v 1.7 1997/03/14 04:32:12 millert Exp $ */
-/* $NetBSD: cmdtab.c,v 1.13 1997/03/13 06:23:12 lukem Exp $ */
+/* $OpenBSD: cmdtab.c,v 1.8 1997/03/21 20:59:27 millert Exp $ */
+/* $NetBSD: cmdtab.c,v 1.14 1997/03/14 01:39:34 christos Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.7 1997/03/14 04:32:12 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.8 1997/03/21 20:59:27 millert Exp $";
#endif
#endif /* not lint */
char dirhelp[] = "list contents of remote directory";
char disconhelp[] = "terminate ftp session";
char domachelp[] = "execute macro";
-#ifndef SMALLFTP
+#ifndef SMALL
char edithelp[] = "toggle command line editing";
-#endif /* !SMALLFTP */
+#endif /* !SMALL */
char formhelp[] = "set file transfer format";
char globhelp[] = "toggle metacharacter expansion of local file names";
char hashhelp[] = "toggle printing `#' marks; specify number to set size";
char userhelp[] = "send new user information";
char verbosehelp[] = "toggle verbose mode";
-#ifdef SMALLFTP
+#ifdef SMALL
#define CMPL(x)
#define CMPL0
-#else /* !SMALLFTP */
+#else /* !SMALL */
#define CMPL(x) __STRING(x),
#define CMPL0 "",
-#endif /* !SMALLFTP */
+#endif /* !SMALL */
struct cmd cmdtab[] = {
{ "!", shellhelp, 0, 0, 0, CMPL0 shell },
{ "delete", deletehelp, 0, 1, 1, CMPL(r) delete },
{ "dir", dirhelp, 1, 1, 1, CMPL(rl) ls },
{ "disconnect", disconhelp, 0, 1, 1, CMPL0 disconnect },
-#ifndef SMALLFTP
+#ifndef SMALL
{ "edit", edithelp, 0, 0, 0, CMPL0 setedit },
-#endif /* !SMALLFTP */
+#endif /* !SMALL */
{ "exit", quithelp, 0, 0, 0, CMPL0 quit },
{ "form", formhelp, 0, 1, 1, CMPL0 setform },
{ "ftp", connecthelp, 0, 0, 1, CMPL0 setpeer },
-/* $OpenBSD: complete.c,v 1.4 1997/03/14 04:32:13 millert Exp $ */
-/* $NetBSD: complete.c,v 1.3 1997/03/13 06:23:13 lukem Exp $ */
+/* $OpenBSD: complete.c,v 1.5 1997/03/21 20:59:28 millert Exp $ */
+/* $NetBSD: complete.c,v 1.6 1997/03/16 14:24:16 lukem Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef SMALL
#ifndef lint
-static char rcsid[] = "$OpenBSD: complete.c,v 1.4 1997/03/14 04:32:13 millert Exp $";
+static char rcsid[] = "$OpenBSD: complete.c,v 1.5 1997/03/21 20:59:28 millert Exp $";
#endif /* not lint */
/*
return (CC_ERROR); /* no choices available */
if (words->sl_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
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);
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)
char *dummyargv[] = { "complete", dir, NULL };
if ((file = strrchr(word, '/')) == NULL) {
- (void)strcpy(dir, ".");
+ dir[0] = '.';
+ dir[1] = '\0';
file = word;
} else {
cp = file;
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 */
&& 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)
return (CC_ERROR);
}
+#endif
-/* $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.
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 **));
-/* $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.
*/
#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 */
/*
* 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;
interactive = 0;
xargv[0] = "mget";
mget(2, xargv);
- interactive = 1;
+ interactive = ointeractive;
} else
get(2, xargv);
-/* $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
#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 */
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 != '-')
if (oldinti)
(void)signal(SIGINFO, oldinti);
progress = oprogress;
+ preserve = opreserve;
code = -1;
return;
}
if (strcmp(local, "-") == 0) {
fout = stdout;
progress = 0;
+ preserve = 0;
} else if (*local == '|') {
oldintp = signal(SIGPIPE, SIG_IGN);
fout = popen(local + 1, "w");
goto abort;
}
progress = 0;
+ preserve = 0;
closefunc = pclose;
} else {
fout = fopen(local, lmode);
lseek(fileno(fout), restart_point, SEEK_SET) < 0) {
warn("local: %s", local);
progress = oprogress;
+ preserve = opreserve;
if (closefunc != NULL)
(*closefunc)(fout);
return;
done:
warn("local: %s", local);
progress = oprogress;
+ preserve = opreserve;
if (closefunc != NULL)
(*closefunc)(fout);
return;
}
progressmeter(1);
progress = oprogress;
+ preserve = opreserve;
if (closefunc != NULL)
(*closefunc)(fout);
(void)signal(SIGINT, oldintr);
/* abort using RFC959 recommended IP,SYNC sequence */
progress = oprogress;
+ preserve = opreserve;
if (oldintp)
(void)signal(SIGPIPE, oldintp);
(void)signal(SIGINT, SIG_IGN);
-/* $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
#include <sys/param.h>
#include <setjmp.h>
-#ifndef SMALLFTP
+#ifndef SMALL
#include <histedit.h>
-#endif /* !SMALLFTP */
+#endif /* !SMALL */
#include "stringlist.h"
#include "extern.h"
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 */
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 */
};
-/* $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
#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 */
preserve = 1;
verbose = 0;
progress = 0;
-#ifndef SMALLFTP
+#ifndef SMALL
editing = 0;
#endif
mark = HASHBYTES;
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
}
break;
case 'e':
-#ifndef SMALLFTP
+#ifndef SMALL
editing = 0;
#endif
break;
(void)strcpy(home, pw->pw_dir);
}
-#ifndef SMALLFTP
+#ifndef SMALL
if (editing) {
el = el_init(__progname, stdin, stdout); /* init editline */
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) {
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);
/* void */;
break;
} /* else it was a line without a newline */
-#ifndef SMALLFTP
+#ifndef SMALL
} else {
const char *buf;
cursor_pos = NULL;
line[num] = '\0';
history(hist, H_ENTER, buf);
}
-#endif /* !SMALLFTP */
+#endif /* !SMALL */
makeargv();
if (margc == 0)
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;
}
if (argp == NULL)
break;
}
-#ifndef SMALLFTP
+#ifndef SMALL
if (cursor_pos == line) {
cursor_argc = 0;
cursor_argo = 0;
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; \
cursor_pos = NULL; \
} }
-#endif /* !SMALLFTP */
+#endif /* !SMALL */
/*
* Parse string into argbuf;