summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdk-stage1/network.c14
-rw-r--r--mdk-stage1/url.c10
-rw-r--r--mdk-stage1/url.h1
3 files changed, 14 insertions, 11 deletions
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index 8bad63c93..17c39dc96 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -999,17 +999,9 @@ enum return_type ftp_prepare(void)
}
if (fd < 0) {
- log_message("FTP: error get %d", fd);
- if (fd == FTPERR_PASSIVE_ERROR)
- stg1_error_message("Error: error with passive connection.");
- else if (fd == FTPERR_FAILED_CONNECT)
- stg1_error_message("Error: couldn't connect to server.");
- else if (fd == FTPERR_FILE_NOT_FOUND)
- stg1_error_message("Error: file not found (%s).", location_full);
- else if (fd == FTPERR_BAD_SERVER_RESPONSE)
- stg1_error_message("Error: bad server response (server too busy?).");
- else
- stg1_error_message("Error: couldn't retrieve Installation program.");
+ char *msg = str_ftp_error(fd);
+ log_message("FTP: error get %d for remote file %s", fd, location_full);
+ stg1_error_message("Error: %s.", msg ? msg : "couldn't retrieve Installation program");
results = RETURN_BACK;
continue;
}
diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c
index c346564e1..6187a6195 100644
--- a/mdk-stage1/url.c
+++ b/mdk-stage1/url.c
@@ -391,6 +391,16 @@ int ftp_end_data_command(int sock)
}
+char *str_ftp_error(int error)
+{
+ return error == FTPERR_PASSIVE_ERROR ? "error with passive connection" :
+ error == FTPERR_FAILED_CONNECT ? "couldn't connect to server" :
+ error == FTPERR_FILE_NOT_FOUND ? "file not found" :
+ error == FTPERR_BAD_SERVER_RESPONSE ? "bad server response (server too busy?)" :
+ NULL;
+}
+
+
int http_download_file(char * hostname, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport)
{
char * buf;
diff --git a/mdk-stage1/url.h b/mdk-stage1/url.h
index 19c1a6874..7a9dcfb4b 100644
--- a/mdk-stage1/url.h
+++ b/mdk-stage1/url.h
@@ -26,6 +26,7 @@ int ftp_open_connection(char * host, char * name, char * password, char * proxy)
int ftp_get_filesize(int sock, char * remotename);
int ftp_start_download(int sock, char * remotename, int * size);
int ftp_end_data_command(int sock);
+char *str_ftp_error(int error);
int http_download_file(char * hostname, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport);