Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/ftp_get_buffer.c

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

revision 34 by hirohitohigashi, Sun Mar 1 12:43:14 2009 UTC revision 38 by hirohitohigashi, Sun Mar 1 15:51:51 2009 UTC
# Line 74  int ftp_get_buffer( LIBOFTP *ftp, const Line 74  int ftp_get_buffer( LIBOFTP *ftp, const
74          n = recv( data_socket, p, len, 0 );          n = recv( data_socket, p, len, 0 );
75          DEBUGPRINT1( "RECV: n=%d\n", n );          DEBUGPRINT1( "RECV: n=%d\n", n );
76          if( n < 0 ) {          if( n < 0 ) {
77                int ret;
78              DEBUGPRINT1( "recv error. %s\n", strerror(errno) );              DEBUGPRINT1( "recv error. %s\n", strerror(errno) );
79              copy_strerror();              if( errno == EAGAIN ) {
80                    ret = LIBOFTP_ERROR_TIMEOUT;
81                } else {
82                    ret = LIBOFTP_ERROR_OS;
83                    copy_strerror();
84                }
85              close( data_socket );              close( data_socket );
86              return LIBOFTP_ERROR_OS;              return ret;
87          }          }
88          if( n == 0 ) {          if( n == 0 ) {
89              break;              break;
# Line 85  int ftp_get_buffer( LIBOFTP *ftp, const Line 91  int ftp_get_buffer( LIBOFTP *ftp, const
91          p += n;          p += n;
92          bufsiz -= n;          bufsiz -= n;
93          if( bufsiz <= 0 ) {          if( bufsiz <= 0 ) {
94              break;              break;              /* buffer too small */
95          }          }
96      }      }
     close( data_socket );  
97    
98      /*      if( bufsiz > 0 ) {          /* バッファ不足だったか? */
99       * receive response.          /*
100       */           * 不足していない
101      res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );           */
102      if( res != 226 ) {                                          /* 226: Closing data connection. */          close( data_socket );
103          DEBUGPRINT1( "got illegal response %d\n", res );  
104          return res<0? res: LIBOFTP_ERROR_PROTOCOL;          /* receive response. */
105      }          res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
106            if( res != 226 ) {                                              /* 226: Closing data connection. */
107                DEBUGPRINT1( "got illegal response %d\n", res );
108                return res < 0? res: LIBOFTP_ERROR_PROTOCOL;
109            }
110    
111      if( bufsiz <= 0 ) {          return p - buf;         /* return with transfered bytes */
112            
113        } else {
114            /*
115             * バッファ不足時
116             */
117          DEBUGPRINT1( "buffer too small. %s\n", "" );          DEBUGPRINT1( "buffer too small. %s\n", "" );
118          strncpy( ftp->error_message, "buffer too small", sizeof( ftp->error_message ) - 1 );          strncpy( ftp->error_message, "buffer too small", sizeof( ftp->error_message ) - 1 );
119    
120            if( ftp_send_command( ftp, "ABOR\r\n" ) < 0 ) {
121                DEBUGPRINT1( "command sending error. %s\n", "ABOR" );
122                close( data_socket );
123                return LIBOFTP_ERROR_BUFFER;
124            }
125    
126            res = ftp_receive_response( ftp, 0, 0 );
127            if( res == 426 ) {                                              /* 426: Connection closed; transfer aborted. */
128                res = ftp_receive_response( ftp, 0, 0 );
129            }
130            close( data_socket );
131            if( res != 226 ) {                                              /* 226: Closing data connection. */
132                DEBUGPRINT1( "got illegal response %d\n", res );
133                return res < 0? res: LIBOFTP_ERROR_PROTOCOL;
134            }
135    
136          return LIBOFTP_ERROR_BUFFER;          return LIBOFTP_ERROR_BUFFER;
137      }      }
   
     return p - buf;             /* return with transfered bytes */  
138  }  }

Legend:
Removed from v.34  
changed lines
  Added in v.38

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