#define BUFFER_SIZE 4096
#include "ftp.h"
-#include "lib/messages.h"
static int ftpCheckResponse(int sock, char ** str);
static int ftpCommand(int sock, char * command, ...);
destPort.sin_port = htons(IPPORT_FTP);
destPort.sin_addr = serverAddress;
- message(MESS_DEBUG, "establishing connection\n");
-
if (connect(sock, (struct sockaddr *) &destPort, sizeof(destPort))) {
close(sock);
return FTPERR_FAILED_CONNECT;
strcat(password, "@");
}
- message(MESS_DEBUG, "logging in\n");
-
if ((rc = ftpCommand(sock, "USER", name, NULL))) {
close(sock);
return rc;
return rc;
}
- message(MESS_DEBUG, "logged into ftp site\n");
-
return sock;
}
char * retrCommand;
int rc;
- message(MESS_DEBUG, "sending PASV command\n");
if (write(sock, "PASV\n", 5) != 5) {
return FTPERR_SERVER_IO_ERROR;
}
return FTPERR_FAILED_CONNECT;
}
- message(MESS_DEBUG, "sending RETR command\n");
retrCommand = alloca(strlen(remotename) + 20);
sprintf(retrCommand, "RETR %s\n", remotename);
i = strlen(retrCommand);
return FTPERR_SERVER_IO_ERROR;
}
- message(MESS_DEBUG, "connecting to data socket\n");
if (connect(dataSocket, (struct sockaddr *) &dataAddress,
sizeof(dataAddress))) {
close(dataSocket);
return FTPERR_FAILED_DATA_CONNECT;
}
- message(MESS_DEBUG, "data socket open\n");
-
if (ftpCheckResponse(sock, NULL)) {
close(dataSocket);
return FTPERR_BAD_SERVER_RESPONSE;