aboutsummaryrefslogtreecommitdiffstats
path: root/ftp.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ftp.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/ftp.c b/ftp.c
index 5c33b7a..1e8e137 100644
--- a/ftp.c
+++ b/ftp.c
@@ -1,4 +1,4 @@
-/* $Id: ftp.c,v 1.13 2002/10/30 17:21:42 ukai Exp $ */
+/* $Id: ftp.c,v 1.14 2002/11/18 18:12:35 ukai Exp $ */
#include <stdio.h>
#include <pwd.h>
#include <Str.h>
@@ -249,6 +249,27 @@ ftp_pasv(FTP ftp)
return 0;
}
+static int
+ftp_fclose(FTP ftp)
+{
+ int control_closed = 0;
+
+ if (ftp->rcontrol != NULL) {
+ fclose(ftp->rcontrol);
+ ftp->rcontrol = NULL;
+ control_closed = 1;
+ }
+ if (ftp->wcontrol != NULL) {
+ fclose(ftp->wcontrol);
+ ftp->wcontrol = NULL;
+ control_closed = 1;
+ }
+ if (control_closed && ftp->data != NULL) {
+ fclose(ftp->data);
+ ftp->data = NULL;
+ }
+}
+
int
FtpCwd(FTP ftp, char *path)
{
@@ -298,7 +319,7 @@ Ftpfclose(FILE * f)
fclose(f);
if (f == current_ftp->data)
current_ftp->data = NULL;
- read_response(current_ftp);
+ ftp_fclose(current_ftp);
return 0;
}
@@ -346,7 +367,7 @@ int
FtpBye(FTP ftp)
{
Str tmp;
- int ret_val, control_closed;
+ int ret_val;
fwrite("QUIT\r\n", 6, sizeof(char), ftp->wcontrol);
fflush(ftp->wcontrol);
@@ -355,21 +376,7 @@ FtpBye(FTP ftp)
ret_val = -1;
else
ret_val = 0;
- control_closed = 0;
- if (ftp->rcontrol != NULL) {
- fclose(ftp->rcontrol);
- ftp->rcontrol = NULL;
- control_closed = 1;
- }
- if (ftp->wcontrol != NULL) {
- fclose(ftp->wcontrol);
- ftp->wcontrol = NULL;
- control_closed = 1;
- }
- if (control_closed && ftp->data != NULL) {
- fclose(ftp->data);
- ftp->data = NULL;
- }
+ ftp_fclose(ftp);
return ret_val;
}