Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (show 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 /*
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 #include <unistd.h>
13
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 *@retval int ������������������
35 *@note
36 */
37 int ftp_quit( LIBOFTP *ftp )
38 {
39 char str1[] = "QUIT\r\n";
40 int res;
41
42 /*
43 * send QUIT command
44 */
45 if( ftp_send_command( ftp, str1 ) < 0 ) {
46 DEBUGPRINT1( "command sending error. %s\n", str1 );
47 res = LIBOFTP_ERROR_OS;
48 goto CLOSE;
49 }
50
51 res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
52 if( res == 221 ) { /* 221: Service closing control connection. */
53 res = LIBOFTP_NOERROR;
54 } else {
55 DEBUGPRINT1( "command response error. %d\n", res );
56 if( res >= 0 ) res = LIBOFTP_ERROR_PROTOCOL;
57 }
58
59 /*
60 * close socket.
61 */
62 CLOSE:
63 close( ftp->socket );
64 ftp->socket = 0;
65
66 return res;
67 }

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