From: ewt Date: Wed, 17 Jul 1996 20:00:31 +0000 (+0000) Subject: began adding support for proxy ftp, though it doesn't work yet X-Git-Tag: rpm-4.4-release~4861 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56a9277121e87d207f0ecd56ddf8d8c2179cf8f7;p=platform%2Fupstream%2Frpm.git began adding support for proxy ftp, though it doesn't work yet CVS patchset: 874 CVS date: 1996/07/17 20:00:31 --- diff --git a/ftp.c b/ftp.c index 6e4f9c5..d8e25d8 100644 --- a/ftp.c +++ b/ftp.c @@ -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; diff --git a/ftp.h b/ftp.h index dc57ab5..aed9cc4 100644 --- a/ftp.h +++ b/ftp.h @@ -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);