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]

Re: ftpclient.c


Hi Thomas

This was something we fixed a while back but never sent back to
RedHat. Sorry!

There is a better way to fix this. command() already does the right
thing when passed a NULL argument.

I have a second patch which should also be applied. This fixes the
reading of multi line replies from the server. The old code worked for
all the tests i originally did. Then someone tried it with another
server and it broke. It should now be RFC compliant.

       Andrew

Index: packages/net/ftpclient/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ftpclient/current/ChangeLog,v
retrieving revision 1.4
diff -u -5 -p -c -r1.4 ChangeLog
cvs server: conflicting specifications of output style
*** packages/net/ftpclient/current/ChangeLog    23 May 2002 23:08:03 -0000      1.4
--- packages/net/ftpclient/current/ChangeLog    19 Jun 2002 09:49:03 -0000
***************
*** 1,5 ****
--- 1,10 ----
+ 2002-06-19  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.
  
  2001-12-04  Andrew Lunn  <andrew.lunn@ascom.ch>

Index: packages/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 -u -5 -p -c -r1.4 ftpclient.c
cvs server: conflicting specifications of output style
*** packages/net/ftpclient/current/src/ftpclient.c      23 May 2002 23:08:04 -00001.4
--- packages/net/ftpclient/current/src/ftpclient.c      19 Jun 2002 09:43:35 -0000
***************
*** 52,61 ****
--- 52,62 ----
  
  #include <pkgconf/system.h>
  
  #include <network.h>
  #include <stdio.h>
+ #include <stdlib.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>
  #include <ctype.h>
  #include "ftpclient.h"
*************** static int 
*** 126,145 ****
  get_reply(int s,ftp_printf_t ftp_printf) {
  
    char buf[BUFSIZ];
    int more = 0;
    int ret;
! 
    do {
      
      if ((ret=get_line(s,buf,sizeof(buf),ftp_printf)) < 0) {
        return(ret);
      }
      
      ftp_printf(0,"FTP: %s\n",buf);
      
!     more = (buf[3] == '-'); 
    } while (more);
  
    return (buf[0] - '0');
  }
  
--- 127,160 ----
  get_reply(int s,ftp_printf_t ftp_printf) {
  
    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) {
        return(ret);
      }
      
      ftp_printf(0,"FTP: %s\n",buf);
      
!     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');
  }
  
*************** static int quit(int s, 
*** 459,469 ****
                  unsigned msgbuflen,
                  ftp_printf_t ftp_printf) {
    
    int ret;
    
!   ret = command("QUIT","",s,msgbuf,msgbuflen,ftp_printf);
    if (ret < 0) {
      return (ret);
    }
    if (ret != 2) {
      ftp_printf(1,"FTP: Quit failed!\n");
--- 474,484 ----
                  unsigned msgbuflen,
                  ftp_printf_t ftp_printf) {
    
    int ret;
    
!   ret = command("QUIT",NULL,s,msgbuf,msgbuflen,ftp_printf);
    if (ret < 0) {
      return (ret);
    }
    if (ret != 2) {
      ftp_printf(1,"FTP: Quit failed!\n");


On Wed, Jun 19, 2002 at 10:17:35AM +0200, Edelmann Thomas wrote:
> Hi,
> 
> just a little patch for the ftpclient.c file.
> 
> It is workaround for a command without arguments, e.g. 'quit'. Without the
> patch ftpclient will send 'quit ', which gives me an error from my ftp
> server.
> 


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