diff options
author | ewt <devnull@localhost> | 1996-07-17 20:00:31 +0000 |
---|---|---|
committer | ewt <devnull@localhost> | 1996-07-17 20:00:31 +0000 |
commit | 56a9277121e87d207f0ecd56ddf8d8c2179cf8f7 (patch) | |
tree | 7b39a508427fc1168a6974cd39d149c87b5aa7d6 /ftp.c | |
parent | aed3be5ee5f84eeca72a61f15f116ed62e58b5c9 (diff) | |
download | librpm-tizen-56a9277121e87d207f0ecd56ddf8d8c2179cf8f7.tar.gz librpm-tizen-56a9277121e87d207f0ecd56ddf8d8c2179cf8f7.tar.bz2 librpm-tizen-56a9277121e87d207f0ecd56ddf8d8c2179cf8f7.zip |
began adding support for proxy ftp, though it doesn't work yet
CVS patchset: 874
CVS date: 1996/07/17 20:00:31
Diffstat (limited to 'ftp.c')
-rw-r--r-- | ftp.c | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -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; |