began adding support for proxy ftp, though it doesn't work yet

CVS patchset: 874
CVS date: 1996/07/17 20:00:31
This commit is contained in:
ewt 1996-07-17 20:00:31 +00:00
parent aed3be5ee5
commit 56a9277121
2 changed files with 20 additions and 12 deletions

30
ftp.c
View File

@ -158,14 +158,32 @@ static int getHostAddress(const char * host, struct in_addr * address) {
return 0;
}
int ftpOpen(char * host, char * name, char * password) {
int ftpOpen(char * host, char * name, char * password, char * proxy) {
static int sock;
/*static char * lastHost = NULL;*/
struct in_addr serverAddress;
struct sockaddr_in destPort;
struct passwd * pw;
char * buf;
int rc;
if (!name)
name = "anonymous";
if (!password) {
pw = getpwuid(getuid());
password = alloca(strlen(pw->pw_name) + 2);
strcpy(password, pw->pw_name);
strcat(password, "@");
}
if (proxy) {
buf = alloca(strlen(name) + strlen(host) + 5);
sprintf(buf, "%s@%s", name, host);
name = buf;
host = proxy;
}
if ((rc = getHostAddress(host, &serverAddress))) return rc;
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
@ -192,16 +210,6 @@ int ftpOpen(char * host, char * name, char * password) {
return rc;
}
if (!name)
name = "anonymous";
if (!password) {
pw = getpwuid(getuid());
password = alloca(strlen(pw->pw_name) + 2);
strcpy(password, pw->pw_name);
strcat(password, "@");
}
if ((rc = ftpCommand(sock, "USER", name, NULL))) {
close(sock);
return rc;

2
ftp.h
View File

@ -14,7 +14,7 @@ const char * ftpStrerror(int ftpErrno);
#define FTPERR_FAILED_DATA_CONNECT -9
#define FTPERR_UNKNOWN -100
int ftpOpen(char * host, char * name, char * password);
int ftpOpen(char * host, char * name, char * password, char * proxy);
int ftpGetFile(int sock, char * remotename, int dest);
void ftpClose(int sock);