Mercurial > gftp.yaz
diff lib/rfc959.c @ 40:66c064fd05bc
2002-10-17 Brian Masney <masneyb@gftp.org>
* lib/protocols.c - add gftp_abort_transfer function. Also, in
gftp_transfer_file, when we do a gftp_put_file, if that fails,
try to abort the transfer.
* lib/rfc959.c - add rfc959_abort_transfer function
* lib/rfc2068.c, lib/local.c - point abort_transfer pointer to
rfc2068_end_transfer and local_end_transfer respectively
* lib/ssh.c, lib/sshv2.c - add FIXME to implement abort function
* src/gtk/transfer.c - when we stop a transfer, try to abort it
first. If that fails, disconnect from the site completely
author | masneyb |
---|---|
date | Fri, 18 Oct 2002 02:53:52 +0000 |
parents | bc9473ba9a90 |
children | 4bcfaf6307b5 |
line wrap: on
line diff
--- a/lib/rfc959.c Wed Oct 16 02:11:09 2002 +0000 +++ b/lib/rfc959.c Fri Oct 18 02:53:52 2002 +0000 @@ -38,6 +38,7 @@ const char *tofile, off_t tosize ); static int rfc959_end_transfer ( gftp_request * request ); +static int rfc959_abort_transfer ( gftp_request * request ); static int rfc959_list_files ( gftp_request * request ); static int rfc959_set_data_type ( gftp_request * request, int data_type ); @@ -84,6 +85,7 @@ request->get_next_file_chunk = NULL; request->put_next_file_chunk = NULL; request->end_transfer = rfc959_end_transfer; + request->abort_transfer = rfc959_abort_transfer; request->list_files = rfc959_list_files; request->get_next_file = rfc959_get_next_file; request->set_data_type = rfc959_set_data_type; @@ -336,14 +338,7 @@ g_free (tempstr); if (ret != '1') - { - if (request->datafd != NULL) - { - fclose (request->datafd); - request->datafd = NULL; - } - return (-2); - } + return (-2); if (request->transfer_type == gftp_transfer_active && (ret = rfc959_accept_active_connection (request)) < 0) @@ -410,14 +405,7 @@ ret = rfc959_send_command (request, tempstr); g_free (tempstr); if (ret != '1') - { - if (request->datafd != NULL) - { - fclose (request->datafd); - request->datafd = NULL; - } - return (-2); - } + return (-2); if (request->transfer_type == gftp_transfer_active && (ret = rfc959_accept_active_connection (request)) < 0) @@ -509,6 +497,37 @@ static int +rfc959_abort_transfer (gftp_request * request) +{ + int ret; + + g_return_val_if_fail (request != NULL, -2); + g_return_val_if_fail (request->protonum == GFTP_FTP_NUM, -2); + g_return_val_if_fail (request->sockfd != NULL, -2); + + if (request->datafd) + { + fclose (request->datafd); + request->datafd = NULL; + } + + /* We need to read two lines of output. The first one is acknowleging + the transfer and the second line acknowleges the ABOR command */ + rfc959_send_command (request, "ABOR\r\n"); + + if (request->sockfd != NULL) + { + ret = rfc959_read_response (request); + + if (ret != '2') + gftp_disconnect (request); + } + + return (0); +} + + +static int rfc959_list_files (gftp_request * request) { char *tempstr, parms[3]; @@ -828,10 +847,7 @@ } if (write_to_socket (request, command) < 0) - { - gftp_disconnect (request); - return (-1); - } + return (-1); return (rfc959_read_response (request)); } @@ -929,7 +945,8 @@ request->last_ftp_response = g_malloc (strlen (tempstr) + 1); strcpy (request->last_ftp_response, tempstr); - if (*request->last_ftp_response == '4') + if (request->last_ftp_response[0] == '4' && + request->last_ftp_response[1] == '2') gftp_disconnect (request); return (*request->last_ftp_response);