Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/ftp_put_buffer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 26 by hirohitohigashi, Sat Feb 28 02:04:32 2009 UTC revision 28 by hirohitohigashi, Sat Feb 28 04:14:38 2009 UTC
# Line 30  Line 30 
30  /***** Global variables *****************************************************/  /***** Global variables *****************************************************/
31  /***** Signal catching functions ********************************************/  /***** Signal catching functions ********************************************/
32  /***** Local functions ******************************************************/  /***** Local functions ******************************************************/
 /***** Global functions *****************************************************/  
33    
34    
35  /****************************************************************************/  /****************************************************************************/
36  /*! バッファからファイル送信  /*! バッファからファイル送信
37   *   *
38   *@param        ftp     LIBOFTPへのポインタ。   *@param        ftp     LIBOFTPへのポインタ。
  *@param        fname   サーバ上のファイル名  
39   *@param        buf     バッファへのポインタ   *@param        buf     バッファへのポインタ
40   *@param        bufsiz  バッファサイズ   *@param        bufsiz  バッファサイズ
41     *@param        fname   サーバ上のファイル名
42     *@param        cmd     送信するFTPコマンド
43   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.
44   *@note   *@note
45   */   */
46  int ftp_put_buffer( LIBOFTP *ftp, const char *fname, char *buf, int bufsiz )  static int ftp_put_buffer_main( LIBOFTP *ftp, char *buf, int bufsiz, const char *fname, const char *cmd )
47  {  {
48      int data_socket;      int data_socket;
49      char *p = buf;      char *p = buf;
# Line 53  int ftp_put_buffer( LIBOFTP *ftp, const Line 53  int ftp_put_buffer( LIBOFTP *ftp, const
53       * 送信準備       * 送信準備
54       */       */
55      if( ftp->flag_passive ) {      if( ftp->flag_passive ) {
56          data_socket = ftp_getready_pasv( ftp, "STOR", fname );          data_socket = ftp_getready_pasv( ftp, cmd, fname );
57      } else {      } else {
58          data_socket = ftp_getready_active( ftp, "STOR", fname );          data_socket = ftp_getready_active( ftp, cmd, fname );
59      }      }
60      if( data_socket < 0 ) {      if( data_socket < 0 ) {
61          return data_socket;          return data_socket;
# Line 75  int ftp_put_buffer( LIBOFTP *ftp, const Line 75  int ftp_put_buffer( LIBOFTP *ftp, const
75              close( data_socket );              close( data_socket );
76              return -1;              return -1;
77          }          }
78          if( n == 0 ) {  
             break;  
         }  
79          p += n;          p += n;
80          bufsiz -= n;          bufsiz -= n;
81          if( bufsiz <= 0 ) {          if( bufsiz <= 0 ) {
# Line 95  int ftp_put_buffer( LIBOFTP *ftp, const Line 93  int ftp_put_buffer( LIBOFTP *ftp, const
93    
94      return 0;      return 0;
95  }  }
96    
97    
98    
99    /***** Global functions *****************************************************/
100    
101    /****************************************************************************/
102    /*! バッファからファイル送信
103     *
104     *@param        ftp     LIBOFTPへのポインタ。
105     *@param        buf     バッファへのポインタ
106     *@param        bufsiz  バッファサイズ
107     *@param        fname   サーバ上のファイル名
108     *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.
109     *@note
110     */
111    int ftp_put_buffer( LIBOFTP *ftp, char *buf, int bufsiz, const char *fname )
112    {
113        return ftp_put_buffer_main( ftp, buf, bufsiz, fname, "STOR" );
114    }
115    
116    
117    
118    /****************************************************************************/
119    /*! バッファからファイル送信 アペンドモード
120     *
121     *@param        ftp     LIBOFTPへのポインタ。
122     *@param        buf     バッファへのポインタ
123     *@param        bufsiz  バッファサイズ
124     *@param        fname   サーバ上のファイル名
125     *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.
126     *@note
127     */
128    int ftp_append_buffer( LIBOFTP *ftp, char *buf, int bufsiz, const char *fname )
129    {
130        return ftp_put_buffer_main( ftp, buf, bufsiz, fname, "APPE" );
131    }

Legend:
Removed from v.26  
changed lines
  Added in v.28

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