summaryrefslogtreecommitdiff
path: root/ftp.c
diff options
context:
space:
mode:
authorewt <devnull@localhost>1996-07-17 20:00:31 +0000
committerewt <devnull@localhost>1996-07-17 20:00:31 +0000
commit56a9277121e87d207f0ecd56ddf8d8c2179cf8f7 (patch)
tree7b39a508427fc1168a6974cd39d149c87b5aa7d6 /ftp.c
parentaed3be5ee5f84eeca72a61f15f116ed62e58b5c9 (diff)
downloadlibrpm-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.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/ftp.c b/ftp.c
index 6e4f9c509..d8e25d827 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;