Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/ftp_put_descriptor.c

Parent Directory Parent Directory | Revision Log Revision Log


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

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