X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fftp.c;fp=src%2Fftp.c;h=262140d79b2e3b2432539cb9d7a3dc9cac44f886;hb=2ba6401e39bcfaaccaa45e6b7ef780a7a15b0c48;hp=46fad28d1230d3c88b8e4a3fd84b96306ef999d7;hpb=2f4fb7c15c5017546238241ea318b16b9a032c52;p=oftp diff --git a/src/ftp.c b/src/ftp.c index 46fad28..262140d 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -8,6 +9,11 @@ #include "ftp.h" #include "util.h" +#ifdef __unix__ +#include +#define closesocket(s) close(s) +#endif + struct ftp *ftp_alloc(void) { struct ftp *ftp; @@ -44,8 +50,9 @@ int ftp_connect(struct ftp *ftp, const char *hostname, int port) return -1; } + memset(&addr, 0, sizeof addr); addr.sin_family = AF_INET; - addr.sin_addr.s_addr = inet_addr(host->h_addr); + addr.sin_addr = *((struct in_addr*)host->h_addr); addr.sin_port = htons(port); if(connect(ftp->ctl, (struct sockaddr*)&addr, sizeof addr) == -1) { @@ -54,7 +61,6 @@ int ftp_connect(struct ftp *ftp, const char *hostname, int port) ftp->ctl = -1; return -1; } - return 0; }