Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /tags/REL-2.2/ftp_quit.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (hide annotations) (download) (as text)
Wed Mar 4 08:27:07 2009 UTC (15 years, 1 month ago) by hirohitohigashi
Original Path: trunk/ftp_quit.c
File MIME type: text/x-csrc
File size: 2108 byte(s)
force close socket even if an error occurred.

1 hirohitohigashi 18 /*
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 hirohitohigashi 32 #include <unistd.h>
13 hirohitohigashi 18
14    
15     /***** Local headers ********************************************************/
16     #include "liboftp.h"
17     #include "sub.h"
18    
19    
20     /***** Constat values *******************************************************/
21     /***** Macros ***************************************************************/
22     /***** Typedefs *************************************************************/
23     /***** Function prototypes **************************************************/
24     /***** Local variables ******************************************************/
25     /***** Global variables *****************************************************/
26     /***** Signal catching functions ********************************************/
27     /***** Local functions ******************************************************/
28     /***** Global functions *****************************************************/
29    
30     /****************************************************************************/
31     /*! QUIT������������
32     *
33     *@param ftp LIBOFTP���������������������
34 hirohitohigashi 30 *@retval int ������������������
35 hirohitohigashi 18 *@note
36     */
37     int ftp_quit( LIBOFTP *ftp )
38     {
39     char str1[] = "QUIT\r\n";
40 hirohitohigashi 29 int res;
41 hirohitohigashi 18
42     /*
43     * send QUIT command
44     */
45 hirohitohigashi 20 if( ftp_send_command( ftp, str1 ) < 0 ) {
46 hirohitohigashi 29 DEBUGPRINT1( "command sending error. %s\n", str1 );
47 hirohitohigashi 46 res = LIBOFTP_ERROR_OS;
48     goto CLOSE;
49 hirohitohigashi 18 }
50    
51 hirohitohigashi 29 res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
52 hirohitohigashi 32 if( res == 221 ) { /* 221: Service closing control connection. */
53     res = LIBOFTP_NOERROR;
54     } else {
55 hirohitohigashi 29 DEBUGPRINT1( "command response error. %d\n", res );
56 hirohitohigashi 32 if( res >= 0 ) res = LIBOFTP_ERROR_PROTOCOL;
57 hirohitohigashi 18 }
58    
59 hirohitohigashi 32 /*
60     * close socket.
61     */
62 hirohitohigashi 46 CLOSE:
63 hirohitohigashi 32 close( ftp->socket );
64     ftp->socket = 0;
65    
66     return res;
67 hirohitohigashi 18 }

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