Browse Subversion Repository
Diff of /trunk/ftp_get_file.c
Parent Directory
| Revision Log
| Patch
| 58 |
*/ |
*/ |
| 59 |
fd = open( local_fname, O_WRONLY|O_CREAT, 0644 ); |
fd = open( local_fname, O_WRONLY|O_CREAT, 0644 ); |
| 60 |
if( fd < 0 ) { |
if( fd < 0 ) { |
| 61 |
DEBUGPRINT1( "get_file: local file open error. %s\n", strerror(errno) ); |
DEBUGPRINT1( "local file open error. %s\n", strerror(errno) ); |
| 62 |
return -1; |
copy_strerror(); |
| 63 |
|
return LIBOFTP_ERROR_OS; |
| 64 |
} |
} |
| 65 |
|
|
| 66 |
/* |
/* |
| 82 |
n = recv( data_socket, buf, TRANSFER_SEGMENT_SIZE, 0 ); |
n = recv( data_socket, buf, TRANSFER_SEGMENT_SIZE, 0 ); |
| 83 |
DEBUGPRINT1( "RECV: n=%d\n", n ); |
DEBUGPRINT1( "RECV: n=%d\n", n ); |
| 84 |
if( n < 0 ) { |
if( n < 0 ) { |
| 85 |
DEBUGPRINT1( "get_file: recv error. %s\n", strerror(errno) ); |
DEBUGPRINT1( "recv error. %s\n", strerror(errno) ); |
| 86 |
|
copy_strerror(); |
| 87 |
close( fd ); |
close( fd ); |
| 88 |
close( data_socket ); |
close( data_socket ); |
| 89 |
return -1; |
return LIBOFTP_ERROR_OS; |
| 90 |
} |
} |
| 91 |
if( n == 0 ) { |
if( n == 0 ) { |
| 92 |
break; |
break; |
| 93 |
} |
} |
| 94 |
|
|
| 95 |
if( write( fd, buf, n ) != n ) { |
if( write( fd, buf, n ) != n ) { |
| 96 |
DEBUGPRINT1( "get_file: write error. %s\n", strerror(errno) ); |
DEBUGPRINT1( "write error. %s\n", strerror(errno) ); |
| 97 |
|
copy_strerror(); |
| 98 |
close( fd ); |
close( fd ); |
| 99 |
close( data_socket ); |
close( data_socket ); |
| 100 |
return -1; |
return LIBOFTP_ERROR_OS; |
| 101 |
} |
} |
| 102 |
} |
} |
| 103 |
close( fd ); |
close( fd ); |
| 106 |
/* |
/* |
| 107 |
* receive response. |
* receive response. |
| 108 |
*/ |
*/ |
| 109 |
if( (res = ftp_receive_response( ftp, 0, 0 )) != 226 ) { /* 226: Closing data connection. */ |
res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 ); |
| 110 |
DEBUGPRINT1( "get_buffer: got illegal response %d\n", res ); |
if( res != 226 ) { /* 226: Closing data connection. */ |
| 111 |
return -2; |
DEBUGPRINT1( "got illegal response %d\n", res ); |
| 112 |
|
return res < 0? res: LIBOFTP_ERROR_PROTOCOL; |
| 113 |
} |
} |
| 114 |
|
|
| 115 |
return 0; |
return LIBOFTP_NOERROR; |
| 116 |
} |
} |
|
|
Legend:
| Removed from v.28 |
|
| changed lines |
| |
Added in v.29 |
|
|
| |