version 1.33, 1997/06/10 19:39:54 |
version 1.34, 1997/07/25 21:56:22 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: main.c,v 1.21 1997/04/05 03:27:39 lukem Exp $ */ |
/* $NetBSD: main.c,v 1.23 1997/07/20 09:45:58 lukem Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1985, 1989, 1993, 1994 |
* Copyright (c) 1985, 1989, 1993, 1994 |
|
|
|
|
#include "ftp_var.h" |
#include "ftp_var.h" |
|
|
|
int main __P((int, char **)); |
|
|
int |
int |
main(argc, argv) |
main(argc, argv) |
int argc; |
int argc; |
char *argv[]; |
char *argv[]; |
{ |
{ |
struct servent *sp; |
struct servent *sp; |
int ch, top, port, rval; |
int ch, top, rval; |
|
long port; |
struct passwd *pw = NULL; |
struct passwd *pw = NULL; |
char *cp, homedir[MAXPATHLEN]; |
char *cp, homedir[MAXPATHLEN]; |
int dumb_terminal = 0; |
int dumb_terminal = 0; |
|
|
verbose = 1; /* verbose if from a tty */ |
verbose = 1; /* verbose if from a tty */ |
#ifndef SMALL |
#ifndef SMALL |
if (!dumb_terminal) |
if (!dumb_terminal) |
editing = 1; /* editing mode on if from a tty */ |
editing = 1; /* editing mode on if tty is usable */ |
#endif |
#endif |
} |
} |
|
|
ttyout = stdout; |
ttyout = stdout; |
if (isatty(fileno(ttyout)) && !dumb_terminal && foregroundproc()) |
if (isatty(fileno(ttyout)) && !dumb_terminal && foregroundproc()) |
progress = 1; /* progress bar on if going to a tty */ |
progress = 1; /* progress bar on if tty is usable */ |
|
|
if (!isatty(fileno(ttyout))) { |
if (!isatty(fileno(ttyout))) { |
outfd = fileno(stdout); |
outfd = fileno(stdout); |
|
|
break; |
break; |
|
|
case 'P': |
case 'P': |
port = atoi(optarg); |
port = strtol(optarg, &cp, 10); |
if (port <= 0) |
if (port < 1 || port > 0xffff || *cp != '\0') |
warnx("bad port number: %s (ignored)", optarg); |
warnx("bad port number: %s (ignored)", optarg); |
else |
else |
ftpport = htons(port); |
ftpport = htons((in_port_t)port); |
break; |
break; |
|
|
case 'r': |
case 'r': |
|
|
setttywidth(0); |
setttywidth(0); |
(void)signal(SIGWINCH, setttywidth); |
(void)signal(SIGWINCH, setttywidth); |
|
|
|
#ifdef __GNUC__ /* XXX: to shut up gcc warnings */ |
|
(void)&argc; |
|
(void)&argv; |
|
#endif |
|
|
if (argc > 0) { |
if (argc > 0) { |
if (strchr(argv[0], ':') != NULL) { |
if (strchr(argv[0], ':') != NULL) { |
anonftp = 1; /* Handle "automatic" transfers. */ |
anonftp = 1; /* Handle "automatic" transfers. */ |
|
|
fputs("sorry, input line too long.\n", ttyout); |
fputs("sorry, input line too long.\n", ttyout); |
break; |
break; |
} |
} |
memcpy(line, buf, num); |
memcpy(line, buf, (size_t)num); |
line[num] = '\0'; |
line[num] = '\0'; |
history(hist, H_ENTER, buf); |
history(hist, H_ENTER, buf); |
} |
} |