00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <stdio.h>
00023 #include <errno.h>
00024
00025 #ifdef HAVE_STRING_H
00026 #include <string.h>
00027 #endif
00028
00029 #include "protocol.h"
00030
00042 int check_ftp(Port_T p) {
00043
00044 int status;
00045 char buf[STRLEN];
00046 char msg[STRLEN];
00047 const char *command= "QUIT\r\n";
00048
00049 ASSERT(p);
00050
00051 if(port_recv(p, buf, sizeof(buf), 0) <= 0) {
00052 log("FTP: error receiving data -- %s\n", STRERROR);
00053 return FALSE;
00054 }
00055
00056 chomp(buf);
00057
00058 sscanf(buf, "%d %s", &status, msg);
00059 if(status != 220) {
00060 log("FTP error: %s\n", buf);
00061 return FALSE;
00062 }
00063
00064 if(port_send(p, command, strlen(command), 0) < 0) {
00065 log("FTP: error sending data -- %s\n", STRERROR);
00066 return FALSE;
00067 }
00068
00069 if(port_recv(p, buf, sizeof(buf), 0) <= 0) {
00070 log("FTP: error receiving data -- %s\n", STRERROR);
00071 return FALSE;
00072 }
00073
00074 chomp(buf);
00075
00076 sscanf(buf, "%d %s", &status, msg);
00077 if(status != 221) {
00078 log("FTP error: %s\n", buf);
00079 return FALSE;
00080 }
00081
00082 return TRUE;
00083
00084 }
00085