version 1.39, 2004/09/16 04:39:16 |
version 1.40, 2005/04/11 15:16:50 |
|
|
void |
void |
setpeer(int argc, char *argv[]) |
setpeer(int argc, char *argv[]) |
{ |
{ |
char *host; |
char *host, *port; |
char *port; |
|
|
|
if (connected) { |
if (connected) { |
fprintf(ttyout, "Already connected to %s, use close first.\n", |
fprintf(ttyout, "Already connected to %s, use close first.\n", |
|
|
int |
int |
ftp_login(const char *host, char *user, char *pass) |
ftp_login(const char *host, char *user, char *pass) |
{ |
{ |
char tmp[80]; |
char tmp[80], *acct = NULL, hostname[MAXHOSTNAMELEN]; |
char *acct; |
|
char anonpass[MAXLOGNAME + 1 + MAXHOSTNAMELEN]; /* "user@hostname" */ |
char anonpass[MAXLOGNAME + 1 + MAXHOSTNAMELEN]; /* "user@hostname" */ |
char hostname[MAXHOSTNAMELEN]; |
|
struct passwd *pw; |
|
int n, aflag = 0, retry = 0; |
int n, aflag = 0, retry = 0; |
|
struct passwd *pw; |
|
|
acct = NULL; |
|
if (user == NULL) { |
if (user == NULL) { |
if (ruserpass(host, &user, &pass, &acct) < 0) { |
if (ruserpass(host, &user, &pass, &acct) < 0) { |
code = -1; |
code = -1; |
|
|
char * |
char * |
remglob(char *argv[], int doswitch, char **errbuf) |
remglob(char *argv[], int doswitch, char **errbuf) |
{ |
{ |
char temp[MAXPATHLEN]; |
char temp[MAXPATHLEN], *cp, *mode; |
static char buf[MAXPATHLEN]; |
static char buf[MAXPATHLEN], **args; |
static FILE *ftemp = NULL; |
static FILE *ftemp = NULL; |
static char **args; |
int oldverbose, oldhash, fd; |
int oldverbose, oldhash, fd; |
|
char *cp, *mode; |
|
|
|
if (!mflag) { |
if (!mflag) { |
if (!doglob) |
if (!doglob) |
args = NULL; |
args = NULL; |
else { |
else { |
if (ftemp) { |
if (ftemp) { |
(void)fclose(ftemp); |
(void)fclose(ftemp); |
ftemp = NULL; |
ftemp = NULL; |
} |
} |
} |
} |
return (NULL); |
return (NULL); |
} |
} |
if (!doglob) { |
if (!doglob) { |
if (args == NULL) |
if (args == NULL) |
args = argv; |
args = argv; |
if ((cp = *++args) == NULL) |
if ((cp = *++args) == NULL) |
args = NULL; |
args = NULL; |
return (cp); |
return (cp); |
} |
} |
if (ftemp == NULL) { |
if (ftemp == NULL) { |
int len; |
int len; |
|
|
if ((cp = getenv("TMPDIR")) == NULL || *cp == '\0') |
if ((cp = getenv("TMPDIR")) == NULL || *cp == '\0') |
|
|
if (temp[len-1] != '/') |
if (temp[len-1] != '/') |
temp[len++] = '/'; |
temp[len++] = '/'; |
(void)strlcpy(&temp[len], TMPFILE, sizeof temp - len); |
(void)strlcpy(&temp[len], TMPFILE, sizeof temp - len); |
if ((fd = mkstemp(temp)) < 0) { |
if ((fd = mkstemp(temp)) < 0) { |
warn("unable to create temporary file %s", temp); |
warn("unable to create temporary file %s", temp); |
return (NULL); |
return (NULL); |
} |
} |
close(fd); |
close(fd); |
oldverbose = verbose; |
oldverbose = verbose; |
verbose = (errbuf != NULL) ? -1 : 0; |
verbose = (errbuf != NULL) ? -1 : 0; |
oldhash = hash; |
oldhash = hash; |
hash = 0; |
hash = 0; |
if (doswitch) |
if (doswitch) |
pswitch(!proxy); |
pswitch(!proxy); |
for (mode = "w"; *++argv != NULL; mode = "a") |
for (mode = "w"; *++argv != NULL; mode = "a") |
recvrequest("NLST", temp, *argv, mode, 0, 0); |
recvrequest("NLST", temp, *argv, mode, 0, 0); |
if ((code / 100) != COMPLETE) { |
if ((code / 100) != COMPLETE) { |
if (errbuf != NULL) |
if (errbuf != NULL) |
*errbuf = reply_string; |
*errbuf = reply_string; |
} |
} |
if (doswitch) |
if (doswitch) |
pswitch(!proxy); |
pswitch(!proxy); |
verbose = oldverbose; |
verbose = oldverbose; |
hash = oldhash; |
hash = oldhash; |
ftemp = fopen(temp, "r"); |
ftemp = fopen(temp, "r"); |
(void)unlink(temp); |
(void)unlink(temp); |
if (ftemp == NULL) { |
if (ftemp == NULL) { |
if (errbuf == NULL) |
if (errbuf == NULL) |
fputs("can't find list of remote files, oops.\n", |
fputs("can't find list of remote files, oops.\n", |
ttyout); |
ttyout); |
else |
else |
*errbuf = |
*errbuf = |
"can't find list of remote files, oops."; |
"can't find list of remote files, oops."; |
return (NULL); |
return (NULL); |
} |
} |
} |
} |
if (fgets(buf, sizeof(buf), ftemp) == NULL) { |
if (fgets(buf, sizeof(buf), ftemp) == NULL) { |
(void)fclose(ftemp); |
(void)fclose(ftemp); |
ftemp = NULL; |
ftemp = NULL; |
return (NULL); |
return (NULL); |
} |
} |
if ((cp = strchr(buf, '\n')) != NULL) |
if ((cp = strchr(buf, '\n')) != NULL) |
*cp = '\0'; |
*cp = '\0'; |
return (buf); |
return (buf); |
} |
} |
|
|
int |
int |