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 28 by hirohitohigashi, Sat Feb 28 04:14:38 2009 UTC revision 50 by hirohitohigashi, Wed Dec 2 15:13:30 2009 UTC
# Line 40  Line 40 
40   *@param        bufsiz  バッファサイズ   *@param        bufsiz  バッファサイズ
41   *@param        fname   サーバ上のファイル名   *@param        fname   サーバ上のファイル名
42   *@param        cmd     送信するFTPコマンド   *@param        cmd     送信するFTPコマンド
43   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.   *@retval       int     エラーコード
44   *@note   *@note
45   */   */
46  static int ftp_put_buffer_main( LIBOFTP *ftp, char *buf, int bufsiz, const char *fname, const char *cmd )  static int ftp_put_buffer_main( LIBOFTP *ftp, const char *buf, int bufsiz, const char *fname, const char *cmd )
47  {  {
48      int data_socket;      int data_socket;
49      char *p = buf;      const char *p = buf;
50      int n;      int n, res;
51    
52        if( ftp->socket < 0 ) return LIBOFTP_ERROR;
53    
54      /*      /*
55       * 送信準備       * 送信準備
# Line 72  static int ftp_put_buffer_main( LIBOFTP Line 74  static int ftp_put_buffer_main( LIBOFTP
74          n = sendn( data_socket, p, len, 0 );          n = sendn( data_socket, p, len, 0 );
75          DEBUGPRINT1( "SEND: n=%d\n", n );          DEBUGPRINT1( "SEND: n=%d\n", n );
76          if( n < 0 ) {          if( n < 0 ) {
77                DEBUGPRINT1( "recv error. %s\n", strerror(errno) );
78                copy_strerror();
79              close( data_socket );              close( data_socket );
80              return -1;              return LIBOFTP_ERROR_OS;
81          }          }
82    
83          p += n;          p += n;
# Line 87  static int ftp_put_buffer_main( LIBOFTP Line 91  static int ftp_put_buffer_main( LIBOFTP
91      /*      /*
92       * receive response.       * receive response.
93       */       */
94      if( ftp_receive_response( ftp, 0, 0 ) != 226 ) {    /* 226: Closing data connection. */      res = ftp_receive_response( ftp, ftp->error_message, sizeof(ftp->error_message)-1 );
95          return -2;      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 0;      return LIBOFTP_NOERROR;
101  }  }
102    
103    
# Line 105  static int ftp_put_buffer_main( LIBOFTP Line 111  static int ftp_put_buffer_main( LIBOFTP
111   *@param        buf     バッファへのポインタ   *@param        buf     バッファへのポインタ
112   *@param        bufsiz  バッファサイズ   *@param        bufsiz  バッファサイズ
113   *@param        fname   サーバ上のファイル名   *@param        fname   サーバ上のファイル名
114   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.   *@retval       int     エラーコード
115   *@note   *@note
116   */   */
117  int ftp_put_buffer( LIBOFTP *ftp, char *buf, int bufsiz, const char *fname )  int ftp_put_buffer( LIBOFTP *ftp, const char *buf, int bufsiz, const char *fname )
118  {  {
119      return ftp_put_buffer_main( ftp, buf, bufsiz, fname, "STOR" );      return ftp_put_buffer_main( ftp, buf, bufsiz, fname, "STOR" );
120  }  }
# Line 122  int ftp_put_buffer( LIBOFTP *ftp, char * Line 128  int ftp_put_buffer( LIBOFTP *ftp, char *
128   *@param        buf     バッファへのポインタ   *@param        buf     バッファへのポインタ
129   *@param        bufsiz  バッファサイズ   *@param        bufsiz  バッファサイズ
130   *@param        fname   サーバ上のファイル名   *@param        fname   サーバ上のファイル名
131   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.   *@retval       int     エラーコード
132   *@note   *@note
133   */   */
134  int ftp_append_buffer( LIBOFTP *ftp, char *buf, int bufsiz, const char *fname )  int ftp_append_buffer( LIBOFTP *ftp, const char *buf, int bufsiz, const char *fname )
135  {  {
136      return ftp_put_buffer_main( ftp, buf, bufsiz, fname, "APPE" );      return ftp_put_buffer_main( ftp, buf, bufsiz, fname, "APPE" );
137  }  }

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

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