split the "SMALL" #ifdefs into ones for NO_ABOUT, NO_EDITCOMPLETE, and

NO_PROGRESS.  -DSMALL still implies all of those.  progress meter support
isn't necessary for the smallest possible ftp client, but it adds very
little space and makes users' lives much better.  Therefore, it should
be enabled for installation media if at all possible.
This commit is contained in:
cgd 1999-06-20 22:07:28 +00:00
parent f4ce9a35ea
commit d78b6bd31e
8 changed files with 78 additions and 65 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.50 1999/06/11 14:12:19 lukem Exp $ */
/* $NetBSD: cmds.c,v 1.51 1999/06/20 22:07:28 cgd Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
__RCSID("$NetBSD: cmds.c,v 1.50 1999/06/11 14:12:19 lukem Exp $");
__RCSID("$NetBSD: cmds.c,v 1.51 1999/06/20 22:07:28 cgd Exp $");
#endif
#endif /* not lint */
@ -728,9 +728,9 @@ status(argc, argv)
"Hash mark printing: %s; Mark count: %d; Progress bar: %s.\n",
onoff(hash), mark, onoff(progress));
fprintf(ttyout, "Use of PORT cmds: %s.\n", onoff(sendport));
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
fprintf(ttyout, "Command line editing: %s.\n", onoff(editing));
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
if (macnum > 0) {
fputs("Macros:\n", ttyout);
for (i=0; i<macnum; i++) {
@ -778,7 +778,7 @@ setbell(argc, argv)
code = togglevar(argc, argv, &bell, "Bell mode");
}
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
/*
* Set command line editing
*/
@ -792,7 +792,7 @@ setedit(argc, argv)
code = togglevar(argc, argv, &editing, "Editing mode");
controlediting();
}
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
/*
* Turn on packet tracing.

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmdtab.c,v 1.20 1999/03/08 03:09:08 lukem Exp $ */
/* $NetBSD: cmdtab.c,v 1.21 1999/06/20 22:07:28 cgd Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
__RCSID("$NetBSD: cmdtab.c,v 1.20 1999/03/08 03:09:08 lukem Exp $");
__RCSID("$NetBSD: cmdtab.c,v 1.21 1999/06/20 22:07:28 cgd Exp $");
#endif
#endif /* not lint */
@ -65,9 +65,9 @@ char deletehelp[] = "delete remote file";
char dirhelp[] = "list contents of remote directory";
char disconhelp[] = "terminate ftp session";
char domachelp[] = "execute macro";
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
char edithelp[] = "toggle command line editing";
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
char formhelp[] = "set file transfer format";
char gatehelp[] = "toggle gate-ftp; specify host[:port] to change proxy";
char globhelp[] = "toggle metacharacter expansion of local file names";
@ -129,13 +129,13 @@ char umaskhelp[] = "get (set) umask on remote side";
char userhelp[] = "send new user information";
char verbosehelp[] = "toggle verbose mode";
#ifdef SMALL
#ifdef NO_EDITCOMPLETE
#define CMPL(x)
#define CMPL0
#else /* !SMALL */
#else /* !NO_EDITCOMPLETE */
#define CMPL(x) __STRING(x),
#define CMPL0 "",
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
struct cmd cmdtab[] = {
{ "!", shellhelp, 0, 0, 0, CMPL0 shell },
@ -156,9 +156,9 @@ struct cmd cmdtab[] = {
{ "delete", deletehelp, 0, 1, 1, CMPL(r) delete },
{ "dir", dirhelp, 1, 1, 1, CMPL(rl) ls },
{ "disconnect", disconhelp, 0, 1, 1, CMPL0 disconnect },
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
{ "edit", edithelp, 0, 0, 0, CMPL0 setedit },
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
{ "exit", quithelp, 0, 0, 0, CMPL0 quit },
{ "form", formhelp, 0, 1, 1, CMPL0 setform },
{ "ftp", connecthelp, 0, 0, 1, CMPL0 setpeer },

View File

@ -1,4 +1,4 @@
/* $NetBSD: complete.c,v 1.23 1999/06/12 18:19:53 christos Exp $ */
/* $NetBSD: complete.c,v 1.24 1999/06/20 22:07:28 cgd Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@ -36,11 +36,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SMALL
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: complete.c,v 1.23 1999/06/12 18:19:53 christos Exp $");
__RCSID("$NetBSD: complete.c,v 1.24 1999/06/20 22:07:28 cgd Exp $");
#endif /* not lint */
/*
@ -58,6 +56,8 @@ __RCSID("$NetBSD: complete.c,v 1.23 1999/06/12 18:19:53 christos Exp $");
#include "ftp_var.h"
#ifndef NO_EDITCOMPLETE
static int comparstr __P((const void *, const void *));
static unsigned char complete_ambiguous __P((char *, int, StringList *));
static unsigned char complete_command __P((char *, int));
@ -411,4 +411,4 @@ complete(el, ch)
return (CC_ERROR);
}
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.28 1999/03/22 07:36:40 lukem Exp $ */
/* $NetBSD: extern.h,v 1.29 1999/06/20 22:07:28 cgd Exp $ */
/*-
* Copyright (c) 1994 The Regents of the University of California.
@ -54,10 +54,10 @@ void changetype __P((int, int));
void cmdabort __P((int));
void cmdscanner __P((int));
int command __P((const char *, ...));
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
unsigned char complete __P((EditLine *, int));
void controlediting __P((void));
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
int confirm __P((const char *, const char *));
FILE *dataconn __P((const char *));
void delete __P((int, char **));

View File

@ -1,4 +1,4 @@
/* $NetBSD: fetch.c,v 1.55 1999/06/02 02:03:57 lukem Exp $ */
/* $NetBSD: fetch.c,v 1.56 1999/06/20 22:07:28 cgd Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fetch.c,v 1.55 1999/06/02 02:03:57 lukem Exp $");
__RCSID("$NetBSD: fetch.c,v 1.56 1999/06/20 22:07:28 cgd Exp $");
#endif /* not lint */
/*
@ -1369,7 +1369,7 @@ go_fetch(url)
const char *url;
{
#ifndef SMALL
#ifndef NO_ABOUT
/*
* Check for about:*
*/
@ -1388,7 +1388,7 @@ go_fetch(url)
}
return (0);
}
#endif /* SMALL */
#endif /* NO_ABOUT */
/*
* Check for file:// and http:// URLs.

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftp_var.h,v 1.31 1999/03/22 07:36:40 lukem Exp $ */
/* $NetBSD: ftp_var.h,v 1.32 1999/06/20 22:07:29 cgd Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
@ -39,6 +39,15 @@
* FTP global variables.
*/
#ifdef SMALL
#undef NO_ABOUT
#define NO_ABOUT
#undef NO_EDITCOMPLETE
#define NO_EDITCOMPLETE
#undef NO_PROGRESS
#define NO_PROGRESS
#endif
#include <sys/param.h>
#include <netinet/in.h>
@ -47,9 +56,9 @@
#include <setjmp.h>
#include <stringlist.h>
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
#include <histedit.h>
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
#include "extern.h"
@ -126,14 +135,14 @@ int ttywidth; /* width of tty */
char *tmpdir; /* temporary directory */
FILE *ttyout; /* stdout, or stderr if retrieving to stdout */
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
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 */
size_t cursor_argc; /* location of cursor in margv */
size_t cursor_argo; /* offset of cursor in margv[cursor_argc] */
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
off_t bytes; /* current # of bytes read */
off_t filesize; /* size of file being transferred */
@ -185,9 +194,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 SMALL
#ifndef NO_EDITCOMPLETE
char *c_complete; /* context sensitive completion list */
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
void (*c_handler) __P((int, char **)); /* function to call */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.42 1999/06/02 02:03:58 lukem Exp $ */
/* $NetBSD: main.c,v 1.43 1999/06/20 22:07:29 cgd Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
__RCSID("$NetBSD: main.c,v 1.42 1999/06/02 02:03:58 lukem Exp $");
__RCSID("$NetBSD: main.c,v 1.43 1999/06/20 22:07:29 cgd Exp $");
#endif
#endif /* not lint */
@ -125,7 +125,7 @@ main(argc, argv)
gatemode = 0;
outfile = NULL;
restartautofetch = 0;
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
editing = 0;
el = NULL;
hist = NULL;
@ -178,14 +178,16 @@ main(argc, argv)
ttyout = stdout;
if (isatty(fileno(ttyout))) {
verbose = 1; /* verbose if to a tty */
#ifndef SMALL
if (! dumbterm) {
#ifndef NO_EDITCOMPLETE
if (fromatty) /* editing mode on if tty is usable */
editing = 1;
#endif
#ifndef NO_PROGRESS
if (foregroundproc())
progress = 1; /* progress bar on if fg */
}
#endif
}
}
while ((ch = getopt(argc, argv, "Aadefgino:pP:r:RtvV")) != -1) {
@ -205,7 +207,7 @@ main(argc, argv)
break;
case 'e':
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
editing = 0;
#endif
break;
@ -334,9 +336,9 @@ main(argc, argv)
retry_connect = 0; /* connected, stop hiding msgs */
}
}
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
controlediting();
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
top = setjmp(toplevel) == 0;
if (top) {
(void)signal(SIGINT, (sig_t)intr);
@ -407,15 +409,15 @@ cmdscanner(top)
int num;
if (!top
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
&& !editing
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
)
(void)putc('\n', ttyout);
for (;;) {
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
if (!editing) {
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
if (fromatty) {
fputs(prompt(), ttyout);
(void)fflush(ttyout);
@ -435,7 +437,7 @@ cmdscanner(top)
/* void */;
break;
} /* else it was a line without a newline */
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
} else {
const char *buf;
HistEvent ev;
@ -454,7 +456,7 @@ cmdscanner(top)
line[num] = '\0';
history(hist, &ev, H_ENTER, buf);
}
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
makeargv();
if (margc == 0)
@ -465,7 +467,7 @@ cmdscanner(top)
continue;
}
if (c == NULL) {
#if !defined(SMALL)
#if !defined(NO_EDITCOMPLETE)
/*
* attempt to el_parse() unknown commands.
* any command containing a ':' would be parsed
@ -475,7 +477,7 @@ cmdscanner(top)
*/
if (strchr(margv[0], ':') != NULL ||
el_parse(el, margc, margv) != 0)
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
fputs("?Invalid command.\n", ttyout);
continue;
}
@ -547,7 +549,7 @@ makeargv()
if (argp == NULL)
break;
}
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
if (cursor_pos == line) {
cursor_argc = 0;
cursor_argo = 0;
@ -555,12 +557,12 @@ makeargv()
cursor_argc = margc;
cursor_argo = strlen(margv[margc-1]);
}
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
}
#ifdef SMALL
#ifdef NO_EDITCOMPLETE
#define INC_CHKCURSOR(x) (x)++
#else /* !SMALL */
#else /* !NO_EDITCOMPLETE */
#define INC_CHKCURSOR(x) { (x)++ ; \
if (x == cursor_pos) { \
cursor_argc = margc; \
@ -568,7 +570,7 @@ makeargv()
cursor_pos = NULL; \
} }
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
/*
* Parse string into argbuf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.49 1999/06/02 02:03:58 lukem Exp $ */
/* $NetBSD: util.c,v 1.50 1999/06/20 22:07:29 cgd Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -75,7 +75,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: util.c,v 1.49 1999/06/02 02:03:58 lukem Exp $");
__RCSID("$NetBSD: util.c,v 1.50 1999/06/20 22:07:29 cgd Exp $");
#endif /* not lint */
/*
@ -759,7 +759,7 @@ mkgmtime(tm)
}
#endif /* not HAVE_TIMEGM */
#ifndef SMALL
#ifndef NO_PROGRESS
/*
* return non-zero if we're the current foreground process
@ -787,7 +787,7 @@ updateprogressmeter(dummy)
progressmeter(0);
}
#endif /* SMALL */
#endif /* NO_PROGRESS */
/*
@ -806,14 +806,16 @@ static const char prefixes[] = " KMGTP";
* with flag = 0
* - After the transfer, call with flag = 1
*/
#ifndef NO_PROGRESS
static struct timeval start;
static struct timeval lastupdate;
#endif
void
progressmeter(flag)
int flag;
{
#ifndef SMALL
#ifndef NO_PROGRESS
static off_t lastsize;
struct timeval now, td, wait;
off_t cursize, abbrevsize, bytespersec;
@ -932,7 +934,7 @@ progressmeter(flag)
(void)putc('\n', ttyout);
}
fflush(ttyout);
#endif /* SMALL */
#endif /* NO_PROGRESS */
}
/*
@ -947,7 +949,7 @@ void
ptransfer(siginfo)
int siginfo;
{
#ifndef SMALL
#ifndef NO_PROGRESS
struct timeval now, td, wait;
double elapsed;
off_t bytespersec;
@ -1020,7 +1022,7 @@ ptransfer(siginfo)
}
len += snprintf(buf + len, sizeof(buf) - len, "\n");
(void)write(siginfo ? STDERR_FILENO : fileno(ttyout), buf, len);
#endif /* SMALL */
#endif /* NO_PROGRESS */
}
/*
@ -1099,7 +1101,7 @@ alarmtimer(wait)
/*
* Setup or cleanup EditLine structures
*/
#ifndef SMALL
#ifndef NO_EDITCOMPLETE
void
controlediting()
{
@ -1140,7 +1142,7 @@ controlediting()
}
}
}
#endif /* !SMALL */
#endif /* !NO_EDITCOMPLETE */
/*
* Parse the specified socket buffer size.