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 55 - (show annotations) (download) (as text)
Wed Mar 24 08:04:56 2010 UTC (13 years, 11 months ago) by hirohitohigashi
File MIME type: text/x-csrc
File size: 2158 byte(s)
Tag release 2.2
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 if( ftp->socket < 0 ) return LIBOFTP_ERROR;
43
44 /*
45 * send QUIT command
46 */
47 if( ftp_send_command( ftp, str1 ) < 0 ) {
48 DEBUGPRINT1( "command sending error. %s\n", str1 );
49 res = LIBOFTP_ERROR_OS;
50 goto CLOSE;
51 }
52
53 res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
54 if( res == 221 ) { /* 221: Service closing control connection. */
55 res = LIBOFTP_NOERROR;
56 } else {
57 DEBUGPRINT1( "command response error. %d\n", res );
58 if( res >= 0 ) res = LIBOFTP_ERROR_PROTOCOL;
59 }
60
61 /*
62 * close socket.
63 */
64 CLOSE:
65 close( ftp->socket );
66 ftp->socket = -1;
67
68 return res;
69 }

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