Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/ftp_reset.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (hide annotations) (download) (as text)
Wed Dec 2 15:13:30 2009 UTC (14 years, 4 months ago) by hirohitohigashi
File MIME type: text/x-csrc
File size: 2333 byte(s)
add error check
1 hirohitohigashi 36 /*
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 hirohitohigashi 38 int i;
41 hirohitohigashi 36
42 hirohitohigashi 50 if( ftp->socket < 0 ) return LIBOFTP_ERROR;
43    
44 hirohitohigashi 36 /*
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 hirohitohigashi 38 * receive response until timeout. 100 cycle maxmum.
54 hirohitohigashi 36 */
55     ftp_timeout( ftp, 1 ); /* set 1 sec */
56    
57 hirohitohigashi 38 for( i = 0; i < 100; i++ ) {
58 hirohitohigashi 36 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     }

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