-# $OpenBSD: Makefile,v 1.8 1997/03/26 00:35:23 deraadt Exp $
-# $NetBSD: Makefile,v 1.10 1997/03/14 01:39:31 christos Exp $
+# $OpenBSD: Makefile,v 1.9 1997/04/10 00:17:06 millert Exp $
+# $NetBSD: Makefile,v 1.11 1997/03/24 21:59:36 christos Exp $
# from: @(#)Makefile 8.2 (Berkeley) 4/3/94
# define SMALL to disable command line editing
-/* $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 $ */
+/* $OpenBSD: cmds.c,v 1.18 1997/04/10 00:17:07 millert Exp $ */
+/* $NetBSD: cmds.c,v 1.22 1997/04/05 03:27:32 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.17 1997/03/21 20:59:26 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.18 1997/04/10 00:17:07 millert Exp $";
#endif
#endif /* not lint */
{
code = togglevar(argc, argv, &editing, "Editing mode");
+ controlediting();
}
#endif /* !SMALL */
-/* $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 $ */
+/* $OpenBSD: cmdtab.c,v 1.9 1997/04/10 00:17:08 millert Exp $ */
+/* $NetBSD: cmdtab.c,v 1.15 1997/04/05 03:27:33 lukem 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.8 1997/03/21 20:59:27 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.9 1997/04/10 00:17:08 millert Exp $";
#endif
#endif /* not lint */
{ "idle", idlehelp, 0, 1, 1, CMPL0 idle },
{ "image", binaryhelp, 0, 1, 1, CMPL0 setbinary },
{ "lcd", lcdhelp, 0, 0, 0, CMPL(l) lcd },
+ { "less", pagehelp, 1, 1, 1, CMPL(r) page },
{ "lpwd", lpwdhelp, 0, 0, 0, CMPL0 lpwd },
{ "ls", lshelp, 1, 1, 1, CMPL(rl) ls },
{ "macdef", macdefhelp, 0, 0, 0, CMPL0 macdef },
{ "mls", mlshelp, 1, 1, 1, CMPL(R) mls },
{ "mode", modehelp, 0, 1, 1, CMPL0 setftmode },
{ "modtime", modtimehelp, 0, 1, 1, CMPL(r) modtime },
+ { "more", pagehelp, 1, 1, 1, CMPL(r) page },
{ "mput", mputhelp, 1, 1, 1, CMPL(L) mput },
{ "msend", mputhelp, 1, 1, 1, CMPL(L) mput },
{ "newer", newerhelp, 1, 1, 1, CMPL(r) newer },
-/* $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 $ */
+/* $OpenBSD: extern.h,v 1.11 1997/04/10 00:17:08 millert Exp $ */
+/* $NetBSD: extern.h,v 1.14 1997/04/05 03:27:34 lukem Exp $ */
/*-
* Copyright (c) 1994 The Regents of the University of California.
int command __P((const char *, ...));
#ifndef SMALL
unsigned char complete __P((EditLine *, int));
+void controlediting __P((void));
#endif /* !SMALL */
int confirm __P((const char *, const char *));
FILE *dataconn __P((const char *));
-/* $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 $ */
+/* $OpenBSD: fetch.c,v 1.6 1997/04/10 00:17:08 millert Exp $ */
+/* $NetBSD: fetch.c,v 1.5 1997/04/05 03:27:36 lukem Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: fetch.c,v 1.5 1997/03/21 20:59:29 millert Exp $";
+static char rcsid[] = "$OpenBSD: fetch.c,v 1.6 1997/04/10 00:17:08 millert Exp $";
#endif /* not lint */
/*
#define FTP_URL "ftp://" /* ftp URL prefix */
#define HTTP_URL "http://" /* http URL prefix */
+#define FTP_PROXY "ftp_proxy" /* env var with ftp proxy location */
#define HTTP_PROXY "http_proxy" /* env var with http proxy location */
jmp_buf httpabort;
/*
- * Retrieve an http:// URL, via a proxy if necessary.
+ * Retrieve URL, via the proxy in $proxyvar if necessary.
* Modifies the string argument given.
* Returns -1 on failure, 0 on success
*/
int
-http_get(line)
+url_get(line, proxyenv)
char *line;
+ char *proxyenv;
{
struct sockaddr_in sin;
int i, out, port, s;
size_t buflen, len;
char c, *cp, *cp2, *savefile, *portnum, *path, buf[4096];
- char *proxyenv, *proxy, *host;
+ char *proxy, *host;
sig_t oldintr;
off_t hashbytes;
s = -1;
proxy = NULL;
- host = line + sizeof(HTTP_URL) - 1;
+ if (strncmp(line, HTTP_URL, sizeof(HTTP_URL) - 1) == 0)
+ host = line + sizeof(HTTP_URL) - 1;
+ else if (strncmp(line, FTP_URL, sizeof(FTP_URL) - 1) == 0)
+ host = line + sizeof(FTP_URL) - 1;
+ else
+ errx(1, "url_get: invalid url '%s'", line);
+
path = strchr(host, '/'); /* find path */
if (EMPTYSTRING(path))
- goto cleanup_http_get;
+ goto cleanup_url_get;
*path++ = '\0';
if (EMPTYSTRING(path))
- goto cleanup_http_get;
+ goto cleanup_url_get;
savefile = strrchr(path, '/'); /* find savefile */
if (savefile != NULL)
else
savefile = path;
if (EMPTYSTRING(savefile))
- goto cleanup_http_get;
+ goto cleanup_url_get;
- proxyenv = getenv(HTTP_PROXY);
if (proxyenv != NULL) { /* use proxy */
- if (strncmp(proxyenv, HTTP_URL, sizeof(HTTP_URL) - 1) != 0) {
- warnx("Malformed proxy url: %s", proxyenv);
- goto cleanup_http_get;
- }
proxy = strdup(proxyenv);
if (proxy == NULL)
errx(1, "Can't allocate memory for proxy url.");
- host = proxy + sizeof(HTTP_URL) - 1;
+ if (strncmp(proxy, HTTP_URL, sizeof(HTTP_URL) - 1) == 0)
+ host = proxy + sizeof(HTTP_URL) - 1;
+ else if (strncmp(proxy, FTP_URL, sizeof(FTP_URL) - 1) == 0)
+ host = proxy + sizeof(FTP_URL) - 1;
+ else {
+ warnx("Malformed proxy url: %s", proxy);
+ goto cleanup_url_get;
+ }
if (EMPTYSTRING(host))
- goto cleanup_http_get;
+ goto cleanup_url_get;
*--path = '/'; /* add / back to real path */
path = strchr(host, '/'); /* remove trailing / on host */
if (! EMPTYSTRING(path))
if (isdigit(host[0])) {
if (inet_aton(host, &sin.sin_addr) == 0) {
warnx("invalid IP address: %s", host);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
} else {
struct hostent *hp;
hp = gethostbyname(host);
if (hp == NULL) {
warnx("%s: %s", host, hstrerror(h_errno));
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
if (hp->h_addrtype != AF_INET) {
warnx("%s: not an Internet address?", host);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
memcpy(&sin.sin_addr, hp->h_addr, hp->h_length);
}
port = atoi(portnum);
if (port < 1 || (port & 0xffff) != port) {
warnx("invalid port: %s", portnum);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
port = htons(port);
} else
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == -1) {
warnx("Can't create socket");
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
warn("Can't connect to %s", host);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
/*
buflen = strlen(buf);
if (write(s, buf, buflen) < buflen) {
warn("write");
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
memset(buf, 0, sizeof(buf));
for (i = 0, buflen = sizeof(buf), cp = buf; i < buflen; cp++, i++) {
cp++;
if (strncmp(cp, "200", 3)) {
warnx("Error retrieving file: %s", cp);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
/*
out = open(savefile, O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (out < 0) {
warn("Can't open %s", savefile);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
/* Trap signals */
if (setjmp(httpabort)) {
if (oldintr)
(void)signal(SIGINT, oldintr);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
oldintr = signal(SIGINT, aborthttp);
for (cp = buf; len > 0; len -= i, cp += i) {
if ((i = write(out, cp, len)) == -1) {
warn("Writing %s", savefile);
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
else if (i == 0)
break;
}
if (len != 0) {
warn("Reading from socket");
- goto cleanup_http_get;
+ goto cleanup_url_get;
}
progressmeter(1);
if (verbose)
improper:
warnx("improper response from %s", host);
-cleanup_http_get:
+cleanup_url_get:
if (s != -1)
close(s);
if (proxy)
static char lasthost[MAXHOSTNAMELEN];
char *xargv[5];
char *cp, *line, *host, *dir, *file, *portnum;
+ char *ftpproxy, *httpproxy;
int rval, xargc, argpos;
int dirhasglob, filehasglob;
char rempath[MAXPATHLEN];
(void)signal(SIGINT, (sig_t)intr);
(void)signal(SIGPIPE, (sig_t)lostpeer);
+ ftpproxy = getenv(FTP_PROXY);
+ httpproxy = getenv(HTTP_PROXY);
+
/*
* Loop through as long as there's files to fetch.
*/
* Try HTTP URL-style arguments first.
*/
if (strncmp(line, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
- if (http_get(line) == -1)
+ if (url_get(line, httpproxy) == -1)
rval = argpos + 1;
continue;
}
/*
- * Try FTP URL-style arguments next, then host:file.
+ * Try FTP URL-style arguments next. If ftpproxy is
+ * set, use url_get() instead of standard ftp.
+ * Finally, try host:file.
*/
host = line;
if (strncmp(line, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
+ if (ftpproxy) {
+ if (url_get(line, ftpproxy) == -1)
+ rval = argpos + 1;
+ continue;
+ }
host += sizeof(FTP_URL) - 1;
cp = strchr(host, '/');
-.\" $OpenBSD: ftp.1,v 1.9 1997/03/14 04:32:15 millert Exp $
-.\" $NetBSD: ftp.1,v 1.18 1997/03/13 06:23:16 lukem Exp $
+.\" $OpenBSD: ftp.1,v 1.10 1997/04/10 00:17:09 millert Exp $
+.\" $NetBSD: ftp.1,v 1.19 1997/04/05 03:27:37 lukem Exp $
.\"
.\" Copyright (c) 1985, 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
no
.Ar directory
is specified, the user's home directory is used.
+.It Ic less Ar file
+A synonym for
+.Ic page .
.It Ic lpwd
Print the working directory on the local machine.
.It Ic \&ls Op Ar remote-directory Op Ar local-file
The default mode is \*(Lqstream\*(Rq mode.
.It Ic modtime Ar file-name
Show the last modification time of the file on the remote machine.
+.It Ic more Ar file
+A synonym for
+.Ic page .
.It Ic mput Ar local-files
Expand wild cards in the list of local files given as arguments
and do a
.Dq Classic
ftp format
.It ftp://host[:port]/file
-FTP URL, using the ftp protocol.
+FTP URL, using the ftp protocol if
+.Ev ftp_proxy
+isn't defined.
+Otherwise, transfer using http via the proxy defined in
+.Ev ftp_proxy .
.It http://host[:port]/file
HTTP URL, using the http protocol.
If
to display files.
.It Ev SHELL
For default shell.
+.It Ev ftp_proxy
+URL of FTP proxy to use when making FTP URL requests
+(if not defined, use the standard ftp protocol).
.It Ev http_proxy
-URL of HTTP proxy to use when making HTTP requests.
+URL of HTTP proxy to use when making HTTP URL requests.
.El
.Sh SEE ALSO
.Xr editrc 5 ,
-/* $OpenBSD: main.c,v 1.27 1997/04/05 19:53:10 kstailey Exp $ */
-/* $NetBSD: main.c,v 1.20 1997/03/16 14:24:21 lukem Exp $ */
+/* $OpenBSD: main.c,v 1.28 1997/04/10 00:17:10 millert Exp $ */
+/* $NetBSD: main.c,v 1.21 1997/04/05 03:27:39 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.27 1997/04/05 19:53:10 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.28 1997/04/10 00:17:10 millert Exp $";
#endif
#endif /* not lint */
int ch, top, port, rval;
struct passwd *pw = NULL;
char *cp, homedir[MAXPATHLEN];
- int from_emacs;
+ int dumb_terminal = 0;
sp = getservbyname("ftp", "tcp");
if (sp == 0)
progress = 0;
#ifndef SMALL
editing = 0;
+ el = NULL;
+ hist = NULL;
#endif
mark = HASHBYTES;
marg_sl = sl_init();
if (strcmp(cp, "pftp") == 0)
passivemode = 1;
- from_emacs = !strcmp(getenv("TERM"), "dumb");
+ dumb_terminal =
+ (!strcmp(getenv("TERM"), "dumb") || !strcmp(getenv("TERM"), "su"));
fromatty = isatty(fileno(stdin));
if (fromatty) {
verbose = 1; /* verbose if from a tty */
#ifndef SMALL
- if (!from_emacs)
+ if (!dumb_terminal)
editing = 1; /* editing mode on if from a tty */
#endif
}
- if (isatty(fileno(stdout)) && !from_emacs)
+ if (isatty(fileno(stdout)) && !dumb_terminal)
progress = 1; /* progress bar on if going to a tty */
while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) {
debug++;
break;
- case 'e': /* XXX should TERM=dumb be the only way to */
-#ifndef SMALL /* turn off editing or not? */
+ case 'e':
+#ifndef SMALL
editing = 0;
#endif
break;
(void)strcpy(home, pw->pw_dir);
}
-#ifndef SMALL
- if (argc > 0) /* batch mode */
- editing = 0;
- if (editing) {
- el = el_init(__progname, stdin, stdout); /* init editline */
-
- hist = history_init(); /* init the builtin history */
- history(hist, H_EVENT, 100); /* remember 100 events */
- el_set(el, EL_HIST, history, hist); /* use history */
-
- el_set(el, EL_EDITOR, "emacs"); /* default editor is emacs */
- el_set(el, EL_PROMPT, prompt); /* set the prompt function */
-
- /* add local file completion, bind to TAB */
- el_set(el, EL_ADDFN, "ftp-complete",
- "Context sensitive argument completion",
- complete);
- el_set(el, EL_BIND, "^I", "ftp-complete", NULL);
-
- el_source(el, NULL); /* read ~/.editrc */
- }
-#endif /* !SMALL */
-
setttywidth(0);
(void)signal(SIGWINCH, setttywidth);
-#ifndef SMALL
- if (editing)
- el_set(el, EL_SIGNAL, 1);
-#endif /* !SMALL */
if (argc > 0) {
if (strchr(argv[0], ':') != NULL) {
} while (!connected);
}
}
+#ifndef SMALL
+ controlediting();
+#endif /* !SMALL */
top = setjmp(toplevel) == 0;
if (top) {
(void)signal(SIGINT, (sig_t)intr);
-/* $OpenBSD: pathnames.h,v 1.5 1997/02/03 01:05:43 millert Exp $ */
+/* $OpenBSD: pathnames.h,v 1.6 1997/04/10 00:17:10 millert Exp $ */
/* $NetBSD: pathnames.h,v 1.7 1997/01/09 20:19:40 tls Exp $ */
/*
#include <paths.h>
-#define TMPFILE "ftpXXXXXX"
+#define TMPFILE "ftpXXXXXXXXXX"
-/* $OpenBSD: ruserpass.c,v 1.6 1997/03/14 04:32:17 millert Exp $ */
-/* $NetBSD: ruserpass.c,v 1.12 1997/03/13 06:23:20 lukem Exp $ */
+/* $OpenBSD: ruserpass.c,v 1.7 1997/04/10 00:17:10 millert Exp $ */
+/* $NetBSD: ruserpass.c,v 1.13 1997/04/01 14:20:34 mrg Exp $ */
/*
* Copyright (c) 1985, 1993, 1994
#if 0
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: ruserpass.c,v 1.6 1997/03/14 04:32:17 millert Exp $";
+static char rcsid[] = "$OpenBSD: ruserpass.c,v 1.7 1997/04/10 00:17:10 millert Exp $";
#endif
#endif /* not lint */
-/* $OpenBSD: util.c,v 1.4 1997/03/14 04:32:18 millert Exp $ */
-/* $NetBSD: util.c,v 1.5 1997/03/13 06:23:21 lukem Exp $ */
+/* $OpenBSD: util.c,v 1.5 1997/04/10 00:17:11 millert Exp $ */
+/* $NetBSD: util.c,v 1.6 1997/04/05 03:27:39 lukem Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: util.c,v 1.4 1997/03/14 04:32:18 millert Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.5 1997/04/10 00:17:11 millert Exp $";
#endif /* not lint */
/*
/*
* Set the SIGALRM interval timer for wait seconds, 0 to disable.
*/
-
void
alarmtimer(wait)
int wait;
itv.it_interval = itv.it_value;
setitimer(ITIMER_REAL, &itv, NULL);
}
+
+/*
+ * Setup or cleanup EditLine structures
+ */
+#ifndef SMALL
+void
+controlediting()
+{
+ if (editing && el == NULL && hist == NULL) {
+ el = el_init(__progname, stdin, stdout); /* init editline */
+ hist = history_init(); /* init the builtin history */
+ history(hist, H_EVENT, 100); /* remember 100 events */
+ el_set(el, EL_HIST, history, hist); /* use history */
+
+ el_set(el, EL_EDITOR, "emacs"); /* default editor is emacs */
+ el_set(el, EL_PROMPT, prompt); /* set the prompt function */
+
+ /* add local file completion, bind to TAB */
+ el_set(el, EL_ADDFN, "ftp-complete",
+ "Context sensitive argument completion",
+ complete);
+ el_set(el, EL_BIND, "^I", "ftp-complete", NULL);
+
+ el_source(el, NULL); /* read ~/.editrc */
+ el_set(el, EL_SIGNAL, 1);
+ } else if (!editing) {
+ if (hist) {
+ history_end(hist);
+ hist = NULL;
+ }
+ if (el) {
+ el_end(el);
+ el = NULL;
+ }
+ }
+}
+#endif /* !SMALL */