version 1.29, 1997/04/11 23:14:04 |
version 1.30, 1997/04/23 20:33:19 |
|
|
struct passwd *pw = NULL; |
struct passwd *pw = NULL; |
char *cp, homedir[MAXPATHLEN]; |
char *cp, homedir[MAXPATHLEN]; |
int dumb_terminal = 0; |
int dumb_terminal = 0; |
|
int outfd = -1; |
|
|
sp = getservbyname("ftp", "tcp"); |
sp = getservbyname("ftp", "tcp"); |
if (sp == 0) |
if (sp == 0) |
|
|
editing = 1; /* editing mode on if from a tty */ |
editing = 1; /* editing mode on if from a tty */ |
#endif |
#endif |
} |
} |
if (isatty(fileno(stdout)) && !dumb_terminal) |
|
|
ttyout = stdout; |
|
if (isatty(fileno(ttyout)) && !dumb_terminal) |
progress = 1; /* progress bar on if going to a tty */ |
progress = 1; /* progress bar on if going to a tty */ |
|
else { |
|
ttyout = stderr; |
|
outfd = fileno(stdout); |
|
} |
|
|
while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) { |
while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) { |
switch (ch) { |
switch (ch) { |
|
|
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. */ |
rval = auto_fetch(argc, argv); |
rval = auto_fetch(argc, argv, outfd); |
if (rval >= 0) /* -1 == connected and cd-ed */ |
if (rval >= 0) /* -1 == connected and cd-ed */ |
exit(rval); |
exit(rval); |
} else { |
} else { |
|
|
break; |
break; |
if (!connected) { |
if (!connected) { |
macnum = 0; |
macnum = 0; |
puts("Retrying..."); |
fputs("Retrying...\n", ttyout); |
sleep(retry_connect); |
sleep(retry_connect); |
} |
} |
} while (!connected); |
} while (!connected); |
|
|
&& !editing |
&& !editing |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
) |
) |
(void)putchar('\n'); |
(void)putc('\n', ttyout); |
for (;;) { |
for (;;) { |
#ifndef SMALL |
#ifndef SMALL |
if (!editing) { |
if (!editing) { |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
if (fromatty) { |
if (fromatty) { |
fputs(prompt(), stdout); |
fputs(prompt(), ttyout); |
(void)fflush(stdout); |
(void)fflush(ttyout); |
} |
} |
if (fgets(line, sizeof(line), stdin) == NULL) |
if (fgets(line, sizeof(line), stdin) == NULL) |
quit(0, 0); |
quit(0, 0); |
|
|
break; |
break; |
line[num] = '\0'; |
line[num] = '\0'; |
} else if (num == sizeof(line) - 2) { |
} else if (num == sizeof(line) - 2) { |
puts("sorry, input line too long."); |
fputs("sorry, input line too long.\n", ttyout); |
while ((num = getchar()) != '\n' && num != EOF) |
while ((num = getchar()) != '\n' && num != EOF) |
/* void */; |
/* void */; |
break; |
break; |
|
|
if (num == 0) |
if (num == 0) |
break; |
break; |
} else if (num >= sizeof(line)) { |
} else if (num >= sizeof(line)) { |
puts("sorry, input line too long."); |
fputs("sorry, input line too long.\n", ttyout); |
break; |
break; |
} |
} |
memcpy(line, buf, num); |
memcpy(line, buf, num); |
|
|
continue; |
continue; |
c = getcmd(margv[0]); |
c = getcmd(margv[0]); |
if (c == (struct cmd *)-1) { |
if (c == (struct cmd *)-1) { |
puts("?Ambiguous command."); |
fputs("?Ambiguous command.\n", ttyout); |
continue; |
continue; |
} |
} |
if (c == 0) { |
if (c == 0) { |
|
|
*/ |
*/ |
if (el_parse(el, margc, margv) != 0) |
if (el_parse(el, margc, margv) != 0) |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
puts("?Invalid command."); |
fputs("?Invalid command.\n", ttyout); |
continue; |
continue; |
} |
} |
if (c->c_conn && !connected) { |
if (c->c_conn && !connected) { |
puts("Not connected."); |
fputs("Not connected.\n", ttyout); |
continue; |
continue; |
} |
} |
confirmrest = 0; |
confirmrest = 0; |
(*c->c_handler)(margc, margv); |
(*c->c_handler)(margc, margv); |
if (bell && c->c_bell) |
if (bell && c->c_bell) |
(void)putchar('\007'); |
(void)putc('\007', ttyout); |
if (c->c_handler != help) |
if (c->c_handler != help) |
break; |
break; |
} |
} |
|
|
StringList *buf; |
StringList *buf; |
|
|
buf = sl_init(); |
buf = sl_init(); |
printf("%sommands may be abbreviated. Commands are:\n\n", |
fprintf(ttyout, "%sommands may be abbreviated. Commands are:\n\n", |
proxy ? "Proxy c" : "C"); |
proxy ? "Proxy c" : "C"); |
for (c = cmdtab; c < &cmdtab[NCMDS]; c++) |
for (c = cmdtab; c < &cmdtab[NCMDS]; c++) |
if (c->c_name && (!proxy || c->c_proxy)) |
if (c->c_name && (!proxy || c->c_proxy)) |
|
|
arg = *++argv; |
arg = *++argv; |
c = getcmd(arg); |
c = getcmd(arg); |
if (c == (struct cmd *)-1) |
if (c == (struct cmd *)-1) |
printf("?Ambiguous help command %s\n", arg); |
fprintf(ttyout, "?Ambiguous help command %s\n", arg); |
else if (c == (struct cmd *)0) |
else if (c == (struct cmd *)0) |
printf("?Invalid help command %s\n", arg); |
fprintf(ttyout, "?Invalid help command %s\n", arg); |
else |
else |
printf("%-*s\t%s\n", HELPINDENT, |
fprintf(ttyout, "%-*s\t%s\n", HELPINDENT, |
c->c_name, c->c_help); |
c->c_name, c->c_help); |
} |
} |
} |
} |