Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/ftp_type.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 20 - (hide annotations) (download) (as text)
Fri Feb 27 11:30:10 2009 UTC (15 years, 1 month ago) by hirohitohigashi
File MIME type: text/x-csrc
File size: 2551 byte(s)
supported active mode. 

1 hirohitohigashi 17 /*
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 <stdio.h>
13     #include <string.h>
14    
15    
16    
17     /***** Local headers ********************************************************/
18     #include "liboftp.h"
19     #include "sub.h"
20    
21    
22     /***** Constat values *******************************************************/
23     /***** Macros ***************************************************************/
24     /***** Typedefs *************************************************************/
25     /***** Function prototypes **************************************************/
26     /***** Local variables ******************************************************/
27     /***** Global variables *****************************************************/
28     /***** Signal catching functions ********************************************/
29     /***** Local functions ******************************************************/
30     /***** Global functions *****************************************************/
31    
32     /****************************************************************************/
33     /*! ���������������������
34     *
35     *@param ftp LIBOFTP���������������������
36     *@param type {ascii|binary|image}
37     *@retval int ������������������������������
38     *@note
39     * FTP���TYPE������������������������������������������������������������������������������������
40     * CR => CRLF ������������������������������������������������������
41     */
42     int ftp_type( LIBOFTP *ftp, const char *type )
43     {
44     char str1[256];
45     int ret;
46    
47     if( strcmp( type, "ascii" ) == 0 ) {
48     snprintf( str1, sizeof(str1)-1, "TYPE A\r\n" );
49     ftp->data_type = ASCII;
50    
51     } else if( strcmp( type, "binary" ) == 0 ) {
52     snprintf( str1, sizeof(str1)-1, "TYPE I\r\n" );
53     ftp->data_type = IMAGE;
54    
55     } else if( strcmp( type, "image" ) == 0 ) {
56     snprintf( str1, sizeof(str1)-1, "TYPE I\r\n" );
57     ftp->data_type = IMAGE;
58    
59     } else {
60     DEBUGPRINT1( "type: argument error. %s\n", type );
61     return -1;
62     }
63    
64     /*
65     * send TYPE command
66     */
67 hirohitohigashi 20 if( ftp_send_command( ftp, str1 ) < 0 ) {
68 hirohitohigashi 17 DEBUGPRINT1( "type: command sending error.%s\n", "" );
69     return -1;
70     }
71    
72     if( (ret = ftp_receive_response( ftp, 0, 0 )) != 200 ) { /* 200: Command okay. */
73     DEBUGPRINT1( "type: command response error. %d\n", ret );
74     return -2;
75     }
76    
77     return 0;
78     }

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