Develop and Download Open Source Software

Browse Subversion Repository

Diff of /tags/REL-2.2/ftp_rename.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by hirohitohigashi, Sat Feb 28 00:57:58 2009 UTC revision 29 by hirohitohigashi, Sat Feb 28 12:48:31 2009 UTC
# Line 39  Line 39 
39  int ftp_rename( LIBOFTP *ftp, const char *from, const char *to )  int ftp_rename( LIBOFTP *ftp, const char *from, const char *to )
40  {  {
41      char str1[512];      char str1[512];
42      int ret;      int res;
43    
44      /*      /*
45       * send RNFR command       * send RNFR command
46       */       */
47      snprintf( str1, sizeof(str1)-1, "RNFR %s\r\n", from );      snprintf( str1, sizeof(str1)-1, "RNFR %s\r\n", from );
48      if( ftp_send_command( ftp, str1 ) < 0 ) {      if( ftp_send_command( ftp, str1 ) < 0 ) {
49          DEBUGPRINT1( "rename: RNFR command sending error. %s\n", str1 );          DEBUGPRINT1( "RNFR command sending error. %s\n", str1 );
50          return -1;          return LIBOFTP_ERROR_OS;
51      }      }
52    
53      if( (ret = ftp_receive_response( ftp, str1, sizeof(str1) )) != 350 ) {      /* 350: Requested file action pending further information */      res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
54          DEBUGPRINT1( "rename: RNFR command response error. %d\n", ret );      if( res != 350 ) {                                  /* 350: Requested file action pending further information */
55          return -2;          DEBUGPRINT1( "RNFR command response error. %d\n", res );
56            return res < 0? res: LIBOFTP_ERROR_PROTOCOL;
57      }      }
58    
59      /*      /*
# Line 61  int ftp_rename( LIBOFTP *ftp, const char Line 62  int ftp_rename( LIBOFTP *ftp, const char
62      snprintf( str1, sizeof(str1)-1, "RNTO %s\r\n", to );      snprintf( str1, sizeof(str1)-1, "RNTO %s\r\n", to );
63      if( ftp_send_command( ftp, str1 ) < 0 ) {      if( ftp_send_command( ftp, str1 ) < 0 ) {
64          DEBUGPRINT1( "rename: RNTO command sending error. %s\n", str1 );          DEBUGPRINT1( "rename: RNTO command sending error. %s\n", str1 );
65          return -1;          return LIBOFTP_ERROR_OS;
66      }      }
67    
68      if( (ret = ftp_receive_response( ftp, str1, sizeof(str1) )) != 250 ) {      /* 250: Requested file action okay, completed. */      res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
69          DEBUGPRINT1( "rename: RNTO command response error. %d\n", ret );      if( res != 250 ) {                                          /* 250: Requested file action okay, completed. */
70          return -2;          DEBUGPRINT1( "RNTO command response error. %d\n", res );
71            return res < 0? res: LIBOFTP_ERROR_PROTOCOL;
72      }      }
73    
74      return 0;      return LIBOFTP_NOERROR;
75  }  }

Legend:
Removed from v.24  
changed lines
  Added in v.29

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26