version 1.24, 1997/03/14 05:36:02 |
version 1.25, 1997/03/21 20:59:30 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: main.c,v 1.18 1997/03/13 06:23:19 lukem Exp $ */ |
/* $NetBSD: main.c,v 1.20 1997/03/16 14:24:21 lukem Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1985, 1989, 1993, 1994 |
* Copyright (c) 1985, 1989, 1993, 1994 |
|
|
preserve = 1; |
preserve = 1; |
verbose = 0; |
verbose = 0; |
progress = 0; |
progress = 0; |
#ifndef SMALLFTP |
#ifndef SMALL |
editing = 0; |
editing = 0; |
#endif |
#endif |
mark = HASHBYTES; |
mark = HASHBYTES; |
|
|
fromatty = isatty(fileno(stdin)); |
fromatty = isatty(fileno(stdin)); |
if (fromatty) { |
if (fromatty) { |
verbose = 1; /* verbose if from a tty */ |
verbose = 1; /* verbose if from a tty */ |
#ifndef SMALLFTP |
#ifndef SMALL |
editing = 1; /* editing mode on if from a tty */ |
editing = 1; /* editing mode on if from a tty */ |
#endif |
#endif |
} |
} |
|
|
break; |
break; |
|
|
case 'e': |
case 'e': |
#ifndef SMALLFTP |
#ifndef SMALL |
editing = 0; |
editing = 0; |
#endif |
#endif |
break; |
break; |
|
|
(void)strcpy(home, pw->pw_dir); |
(void)strcpy(home, pw->pw_dir); |
} |
} |
|
|
#ifndef SMALLFTP |
#ifndef SMALL |
if (editing) { |
if (editing) { |
el = el_init(__progname, stdin, stdout); /* init editline */ |
el = el_init(__progname, stdin, stdout); /* init editline */ |
|
|
|
|
|
|
el_source(el, NULL); /* read ~/.editrc */ |
el_source(el, NULL); /* read ~/.editrc */ |
} |
} |
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
|
|
setttywidth(0); |
setttywidth(0); |
(void)signal(SIGWINCH, setttywidth); |
(void)signal(SIGWINCH, setttywidth); |
#ifndef SMALLFTP |
#ifndef SMALL |
if (editing) |
if (editing) |
el_set(el, EL_SIGNAL, 1); |
el_set(el, EL_SIGNAL, 1); |
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
|
|
if (argc > 0) { |
if (argc > 0) { |
if (strchr(argv[0], ':') != NULL) { |
if (strchr(argv[0], ':') != NULL) { |
|
|
int num; |
int num; |
|
|
if (!top |
if (!top |
#ifndef SMALLFTP |
#ifndef SMALL |
&& !editing |
&& !editing |
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
) |
) |
(void)putchar('\n'); |
(void)putchar('\n'); |
for (;;) { |
for (;;) { |
#ifndef SMALLFTP |
#ifndef SMALL |
if (!editing) { |
if (!editing) { |
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
if (fromatty) { |
if (fromatty) { |
fputs(prompt(), stdout); |
fputs(prompt(), stdout); |
(void)fflush(stdout); |
(void)fflush(stdout); |
|
|
/* void */; |
/* void */; |
break; |
break; |
} /* else it was a line without a newline */ |
} /* else it was a line without a newline */ |
#ifndef SMALLFTP |
#ifndef SMALL |
} else { |
} else { |
const char *buf; |
const char *buf; |
cursor_pos = NULL; |
cursor_pos = NULL; |
|
|
line[num] = '\0'; |
line[num] = '\0'; |
history(hist, H_ENTER, buf); |
history(hist, H_ENTER, buf); |
} |
} |
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
|
|
makeargv(); |
makeargv(); |
if (margc == 0) |
if (margc == 0) |
|
|
continue; |
continue; |
} |
} |
if (c == 0) { |
if (c == 0) { |
#ifndef SMALLFTP |
#ifndef SMALL |
/* |
/* |
* Give editline(3) a shot at unknown commands. |
* Give editline(3) a shot at unknown commands. |
* XXX - bogus commands with a colon in |
* XXX - bogus commands with a colon in |
* them will not elicit an error. |
* them will not elicit an error. |
*/ |
*/ |
if (el_parse(el, margc, margv) != 0) |
if (el_parse(el, margc, margv) != 0) |
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
puts("?Invalid command."); |
puts("?Invalid command."); |
continue; |
continue; |
} |
} |
|
|
if (argp == NULL) |
if (argp == NULL) |
break; |
break; |
} |
} |
#ifndef SMALLFTP |
#ifndef SMALL |
if (cursor_pos == line) { |
if (cursor_pos == line) { |
cursor_argc = 0; |
cursor_argc = 0; |
cursor_argo = 0; |
cursor_argo = 0; |
|
|
cursor_argc = margc; |
cursor_argc = margc; |
cursor_argo = strlen(margv[margc-1]); |
cursor_argo = strlen(margv[margc-1]); |
} |
} |
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
} |
} |
|
|
#ifdef SMALLFTP |
#ifdef SMALL |
#define INC_CHKCURSOR(x) (x)++ |
#define INC_CHKCURSOR(x) (x)++ |
#else /* !SMALLFTP */ |
#else /* !SMALL */ |
#define INC_CHKCURSOR(x) { (x)++ ; \ |
#define INC_CHKCURSOR(x) { (x)++ ; \ |
if (x == cursor_pos) { \ |
if (x == cursor_pos) { \ |
cursor_argc = margc; \ |
cursor_argc = margc; \ |
|
|
cursor_pos = NULL; \ |
cursor_pos = NULL; \ |
} } |
} } |
|
|
#endif /* !SMALLFTP */ |
#endif /* !SMALL */ |
|
|
/* |
/* |
* Parse string into argbuf; |
* Parse string into argbuf; |