This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ftpclient patch


Hi Folks

I've been made an eCos maintainer :-)

I've just committed the following patch. This fixes a problem reported
a while back by Thomas Edelmann, when the client sends the quit command.

I've also fixed the handling of multiple line replies from the server.

     Andrew

Index: net/ftpclient/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ftpclient/current/ChangeLog,v
retrieving revision 1.4
diff -c -u -r1.4 ChangeLog
--- net/ftpclient/current/ChangeLog	23 May 2002 23:08:03 -0000	1.4
+++ net/ftpclient/current/ChangeLog	7 Aug 2002 07:59:28 -0000
@@ -1,3 +1,8 @@
+2002-08-06  Andrew Lunn <andrew.lunn@ascom.ch>
+
+	* src/ftpclient.c: Send "quit" not "quit " to keep some servers
+	  happy.  Also deal with multi line replies correctly.
+	
 2002-02-22  Hugo Tyson  <hmt@redhat.com>
 
 	* doc/ftpclient.sgml: New file.  Document it.
Index: net/ftpclient/current/src/ftpclient.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ftpclient/current/src/ftpclient.c,v
retrieving revision 1.4
diff -c -u -r1.4 ftpclient.c
--- net/ftpclient/current/src/ftpclient.c	23 May 2002 23:08:04 -0000	1.4
+++ net/ftpclient/current/src/ftpclient.c	7 Aug 2002 07:59:29 -0000
@@ -9,6 +9,7 @@
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Andrew Lunn.
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
@@ -54,6 +55,7 @@
 
 #include <network.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -128,7 +130,9 @@
   char buf[BUFSIZ];
   int more = 0;
   int ret;
-
+  int first_line=1;
+  int code=0;
+  
   do {
     
     if ((ret=get_line(s,buf,sizeof(buf),ftp_printf)) < 0) {
@@ -137,7 +141,19 @@
     
     ftp_printf(0,"FTP: %s\n",buf);
     
-    more = (buf[3] == '-'); 
+    if (first_line) {
+      code = strtoul(buf,NULL,0);
+      first_line=0;
+      more = (buf[3] == '-');
+    } else {
+      if (isdigit(buf[0]) && isdigit(buf[1]) && isdigit(buf[2]) &&
+          (code == strtoul(buf,NULL,0)) && 
+          buf[3]==' ') {
+        more=0;
+      } else {
+        more =1;
+      }
+    }
   } while (more);
 
   return (buf[0] - '0');
@@ -461,7 +477,7 @@
   
   int ret;
   
-  ret = command("QUIT","",s,msgbuf,msgbuflen,ftp_printf);
+  ret = command("QUIT",NULL,s,msgbuf,msgbuflen,ftp_printf);
   if (ret < 0) {
     return (ret);
   }





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]