version 1.76, 2009/04/27 22:51:51 |
version 1.77, 2009/05/05 19:35:30 |
|
|
#include <unistd.h> |
#include <unistd.h> |
|
|
#include "ftp_var.h" |
#include "ftp_var.h" |
|
#include "cmds.h" |
|
|
int family = PF_UNSPEC; |
int family = PF_UNSPEC; |
|
|
|
|
hist = NULL; |
hist = NULL; |
cookiefile = NULL; |
cookiefile = NULL; |
resume = 0; |
resume = 0; |
|
marg_sl = sl_init(); |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
mark = HASHBYTES; |
mark = HASHBYTES; |
marg_sl = sl_init(); |
|
#ifdef INET6 |
#ifdef INET6 |
epsv4 = 1; |
epsv4 = 1; |
#else |
#else |
|
|
if (rval >= 0) /* -1 == connected and cd-ed */ |
if (rval >= 0) /* -1 == connected and cd-ed */ |
exit(rval); |
exit(rval); |
} else { |
} else { |
|
#ifndef SMALL |
char *xargv[5]; |
char *xargv[5]; |
|
|
if (setjmp(toplevel)) |
if (setjmp(toplevel)) |
|
|
if (!retry_connect) |
if (!retry_connect) |
break; |
break; |
if (!connected) { |
if (!connected) { |
#ifndef SMALL |
|
macnum = 0; |
macnum = 0; |
#endif /* !SMALL */ |
|
fputs("Retrying...\n", ttyout); |
fputs("Retrying...\n", ttyout); |
sleep(retry_connect); |
sleep(retry_connect); |
} |
} |
} while (!connected); |
} while (!connected); |
retry_connect = 0; /* connected, stop hiding msgs */ |
retry_connect = 0; /* connected, stop hiding msgs */ |
|
#endif /* !SMALL */ |
} |
} |
} |
} |
#ifndef SMALL |
#ifndef SMALL |
controlediting(); |
controlediting(); |
#endif /* !SMALL */ |
|
top = setjmp(toplevel) == 0; |
top = setjmp(toplevel) == 0; |
if (top) { |
if (top) { |
(void)signal(SIGINT, (sig_t)intr); |
(void)signal(SIGINT, (sig_t)intr); |
|
|
cmdscanner(top); |
cmdscanner(top); |
top = 1; |
top = 1; |
} |
} |
|
#else /* !SMALL */ |
|
usage(); |
|
#endif /* !SMALL */ |
} |
} |
|
|
void |
void |
|
|
errno = save_errno; |
errno = save_errno; |
} |
} |
|
|
|
#ifndef SMALL |
/* |
/* |
* Generate a prompt |
* Generate a prompt |
*/ |
*/ |
|
|
{ |
{ |
struct cmd *c; |
struct cmd *c; |
int num; |
int num; |
#ifndef SMALL |
|
HistEvent hev; |
HistEvent hev; |
#endif /* !SMALL */ |
|
|
|
if (!top |
if (!top && !editing) |
#ifndef SMALL |
|
&& !editing |
|
#endif /* !SMALL */ |
|
) |
|
(void)putc('\n', ttyout); |
(void)putc('\n', ttyout); |
for (;;) { |
for (;;) { |
#ifndef SMALL |
|
if (!editing) { |
if (!editing) { |
#endif /* !SMALL */ |
|
if (fromatty) { |
if (fromatty) { |
fputs(prompt(), ttyout); |
fputs(prompt(), ttyout); |
(void)fflush(ttyout); |
(void)fflush(ttyout); |
|
|
/* void */; |
/* void */; |
break; |
break; |
} /* else it was a line without a newline */ |
} /* else it was a line without a newline */ |
#ifndef SMALL |
|
} else { |
} else { |
const char *buf; |
const char *buf; |
cursor_pos = NULL; |
cursor_pos = NULL; |
|
|
line[num] = '\0'; |
line[num] = '\0'; |
history(hist, &hev, H_ENTER, buf); |
history(hist, &hev, H_ENTER, buf); |
} |
} |
#endif /* !SMALL */ |
|
|
|
makeargv(); |
makeargv(); |
if (margc == 0) |
if (margc == 0) |
|
|
continue; |
continue; |
} |
} |
if (c == 0) { |
if (c == 0) { |
#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 |
|
|
*/ |
*/ |
if (editing && |
if (editing && |
el_parse(el, margc, (const char **)margv) != 0) |
el_parse(el, margc, (const char **)margv) != 0) |
#endif /* !SMALL */ |
|
fputs("?Invalid command.\n", ttyout); |
fputs("?Invalid command.\n", ttyout); |
continue; |
continue; |
} |
} |
|
|
if (argp == NULL) |
if (argp == NULL) |
break; |
break; |
} |
} |
#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 /* !SMALL */ |
|
} |
} |
|
|
#ifdef SMALL |
|
#define INC_CHKCURSOR(x) (x)++ |
|
#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_argo = ap-argbase; \ |
cursor_argo = ap-argbase; \ |
cursor_pos = NULL; \ |
cursor_pos = NULL; \ |
} } |
} } |
|
|
#endif /* SMALL */ |
|
|
|
/* |
/* |
* Parse string into argbuf; |
* Parse string into argbuf; |
|
|
c->c_name, c->c_help); |
c->c_name, c->c_help); |
} |
} |
} |
} |
|
#endif /* !SMALL */ |
|
|
void |
void |
usage(void) |
usage(void) |
{ |
{ |
(void)fprintf(stderr, |
(void)fprintf(stderr, "usage: %s " |
"usage: %s [-46Aa" |
|
#ifndef SMALL |
#ifndef SMALL |
"d" |
"[-46AadEegimnptVv] [-k seconds] [-P port] " |
|
"[-r seconds] [host [port]]\n" |
|
" %s [-C] " |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
"EegimnptVv] [-k seconds] [-P port] [-r seconds] [host [port]]\n" |
|
" %s " |
|
#ifndef SMALL |
|
"[-C] " |
|
#endif /* !SMALL */ |
|
"[-o output] " |
"[-o output] " |
"ftp://[user:password@]host[:port]/file[/]\n" |
"ftp://[user:password@]host[:port]/file[/]\n" |
" %s " |
" %s " |
|
|
#ifndef SMALL |
#ifndef SMALL |
__progname, __progname, __progname, __progname, __progname); |
__progname, __progname, __progname, __progname, __progname); |
#else /* !SMALL */ |
#else /* !SMALL */ |
__progname, __progname, __progname, __progname); |
__progname, __progname, __progname); |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
exit(1); |
exit(1); |
} |
} |
|
|