| 1 |
/* |
| 2 |
liboftp: this is an FTP library to simplify the work to a Developer |
| 3 |
who want to work with FTP servers (RFC 959). |
| 4 |
|
| 5 |
Copyright (c) 2009 hirohito higashi. All rights reserved. |
| 6 |
This file is distributed under BSD license. |
| 7 |
*/ |
| 8 |
|
| 9 |
|
| 10 |
/***** Feature test switches ************************************************/ |
| 11 |
/***** System headers *******************************************************/ |
| 12 |
/***** Local headers ********************************************************/ |
| 13 |
#include "liboftp.h" |
| 14 |
#include "sub.h" |
| 15 |
|
| 16 |
|
| 17 |
/***** Constat values *******************************************************/ |
| 18 |
/***** Macros ***************************************************************/ |
| 19 |
/***** Typedefs *************************************************************/ |
| 20 |
/***** Function prototypes **************************************************/ |
| 21 |
/***** Local variables ******************************************************/ |
| 22 |
/***** Global variables *****************************************************/ |
| 23 |
/***** Signal catching functions ********************************************/ |
| 24 |
/***** Local functions ******************************************************/ |
| 25 |
/***** Global functions *****************************************************/ |
| 26 |
|
| 27 |
/****************************************************************************/ |
| 28 |
/*! ��������������� |
| 29 |
* |
| 30 |
*@param ftp LIBOFTP��������������������� |
| 31 |
*@retval int ������������������ |
| 32 |
*@note |
| 33 |
* ���������������������ftp������������������������������������������������������������������������������ |
| 34 |
* ��������������������������������������������� |
| 35 |
*/ |
| 36 |
int ftp_reset( LIBOFTP *ftp ) |
| 37 |
{ |
| 38 |
int now_timeout_sec = ftp->timeout_sec; |
| 39 |
int ret; |
| 40 |
int i; |
| 41 |
|
| 42 |
if( ftp->socket < 0 ) return LIBOFTP_ERROR; |
| 43 |
|
| 44 |
/* |
| 45 |
* send "CRLF" only |
| 46 |
*/ |
| 47 |
if( ftp_send_command( ftp, "\r\n" ) < 0 ) { |
| 48 |
DEBUGPRINT1( "command sending error. %s\n", "CRLF" ); |
| 49 |
return LIBOFTP_ERROR_OS; |
| 50 |
} |
| 51 |
|
| 52 |
/* |
| 53 |
* receive response until timeout. 100 cycle maxmum. |
| 54 |
*/ |
| 55 |
ftp_timeout( ftp, 1 ); /* set 1 sec */ |
| 56 |
|
| 57 |
for( i = 0; i < 100; i++ ) { |
| 58 |
ret = ftp_receive_response( ftp, 0, 0 ); |
| 59 |
if( ret == LIBOFTP_ERROR_TIMEOUT ) { |
| 60 |
ret = LIBOFTP_NOERROR; |
| 61 |
break; |
| 62 |
} |
| 63 |
|
| 64 |
if( ret == LIBOFTP_ERROR_OS ) { |
| 65 |
DEBUGPRINT1( "os level error occurred.\n%s", "" ); |
| 66 |
break; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
ftp_timeout( ftp, now_timeout_sec ); |
| 71 |
return ret; |
| 72 |
} |