Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /tags/REL-2.1/ftp_put_descriptor.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (hide annotations) (download) (as text)
Sun Mar 8 07:32:44 2009 UTC (15 years, 1 month ago) by hirohitohigashi
File MIME type: text/x-csrc
File size: 3536 byte(s)
Tag release 2.1
1 hirohitohigashi 32 /*
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_put_descriptor( LIBOFTP *ftp, const char *fname )
39     {
40     int data_socket;
41    
42     if( ftp->flag_passive ) {
43     data_socket = ftp_getready_pasv( ftp, "STOR", fname );
44     } else {
45     data_socket = ftp_getready_active( ftp, "STOR", fname );
46     }
47     return data_socket;
48     }
49    
50    
51    
52     /****************************************************************************/
53     /*! ��������������������������������������������� ���������������������
54     *
55     *@param ftp LIBOFTP���������������������
56     *@param fname ������������������������������
57     *@retval int ������������������������������������������������������������
58     *@note
59     */
60     int ftp_append_descriptor( LIBOFTP *ftp, const char *fname )
61     {
62     int data_socket;
63    
64     if( ftp->flag_passive ) {
65     data_socket = ftp_getready_pasv( ftp, "APPE", fname );
66     } else {
67     data_socket = ftp_getready_active( ftp, "APPE", fname );
68     }
69     return data_socket;
70     }
71    
72    
73    
74     /****************************************************************************/
75     /*! ���������������������������������������������������
76     *
77     *@param ftp LIBOFTP���������������������
78     *@param desc ������������������
79     *@retval int ������������������
80     *@note
81     */
82     int ftp_put_descriptor_close( LIBOFTP *ftp, int desc )
83     {
84     int res;
85    
86     /*
87     * close socket.
88     */
89     close( desc );
90    
91     /*
92     * receive response.
93     */
94     res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
95     if( res != 226 ) { /* 226: Closing data connection. */
96     DEBUGPRINT1( "got illegal response %d\n", res );
97     return res < 0? res: LIBOFTP_ERROR_PROTOCOL;
98     }
99    
100     return LIBOFTP_NOERROR;
101     }
102    
103    
104    
105     /****************************************************************************/
106     /*! ��������������������������������������������������� ���������������������
107     *
108     *@param ftp LIBOFTP���������������������
109     *@param desc ������������������
110     *@retval int ������������������
111     *@note
112     */
113     int ftp_append_descriptor_close( LIBOFTP *ftp, int desc )
114     {
115     return ftp_put_descriptor_close( ftp, desc );
116     }

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