Develop and Download Open Source Software

Browse Subversion Repository

Contents of /tags/REL-2.2/ftp_get_descriptor.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: 2632 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 /*! ���������������������������������������������
32 *
33 *@param ftp LIBOFTP���������������������
34 *@param fname ������������������������������
35 *@retval int ������������������������������������������������������������
36 *@note
37 */
38 int ftp_get_descriptor( LIBOFTP *ftp, const char *fname )
39 {
40 int data_socket;
41
42 if( ftp->socket < 0 ) return LIBOFTP_ERROR;
43
44 if( ftp->flag_passive ) {
45 data_socket = ftp_getready_pasv( ftp, "RETR", fname );
46 } else {
47 data_socket = ftp_getready_active( ftp, "RETR", fname );
48 }
49
50 return data_socket;
51 }
52
53
54
55 /****************************************************************************/
56 /*! ���������������������������������������������������
57 *
58 *@param ftp LIBOFTP���������������������
59 *@param desc ������������������
60 *@retval int ������������������
61 *@note
62 */
63 int ftp_get_descriptor_close( LIBOFTP *ftp, int desc )
64 {
65 int res;
66
67 /*
68 * close socket.
69 */
70 close( desc );
71
72 if( ftp->socket < 0 ) return LIBOFTP_ERROR;
73
74 /*
75 * receive response.
76 */
77 res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
78 if( res != 226 ) { /* 226: Closing data connection. */
79 DEBUGPRINT1( "got illegal response %d\n", res );
80 return res<0? res: LIBOFTP_ERROR_PROTOCOL;
81 }
82
83 return LIBOFTP_NOERROR;
84 }

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