Develop and Download Open Source Software

Browse Subversion Repository

Contents of /tags/REL-2.1/ftp_get_descriptor.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (show annotations) (download) (as text)
Sun Mar 8 07:32:44 2009 UTC (15 years ago) by hirohitohigashi
File MIME type: text/x-csrc
File size: 2534 byte(s)
Tag release 2.1
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->flag_passive ) {
43 data_socket = ftp_getready_pasv( ftp, "RETR", fname );
44 } else {
45 data_socket = ftp_getready_active( ftp, "RETR", fname );
46 }
47
48 return data_socket;
49 }
50
51
52
53 /****************************************************************************/
54 /*! ���������������������������������������������������
55 *
56 *@param ftp LIBOFTP���������������������
57 *@param desc ������������������
58 *@retval int ������������������
59 *@note
60 */
61 int ftp_get_descriptor_close( LIBOFTP *ftp, int desc )
62 {
63 int res;
64
65 /*
66 * close socket.
67 */
68 close( desc );
69
70 /*
71 * receive response.
72 */
73 res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
74 if( res != 226 ) { /* 226: Closing data connection. */
75 DEBUGPRINT1( "got illegal response %d\n", res );
76 return res<0? res: LIBOFTP_ERROR_PROTOCOL;
77 }
78
79 return LIBOFTP_NOERROR;
80 }

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