Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/ftp_put_file.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 30 by hirohitohigashi, Sat Feb 28 13:03:02 2009 UTC
# Line 41  Line 41 
41   *@param        local_fname     ローカルファイル名   *@param        local_fname     ローカルファイル名
42   *@param        fname   サーバ上のファイル名   *@param        fname   サーバ上のファイル名
43   *@param        cmd     送信するFTPコマンド   *@param        cmd     送信するFTPコマンド
44   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.   *@retval       int     エラーコード
45   *@note   *@note
46   */   */
47  static int ftp_put_file_main( LIBOFTP *ftp, const char *local_fname, const char *fname, const char *cmd )  static int ftp_put_file_main( LIBOFTP *ftp, const char *local_fname, const char *fname, const char *cmd )
# Line 49  static int ftp_put_file_main( LIBOFTP *f Line 49  static int ftp_put_file_main( LIBOFTP *f
49      int data_socket;      int data_socket;
50      int fd;      int fd;
51      char buf[TRANSFER_SEGMENT_SIZE];      char buf[TRANSFER_SEGMENT_SIZE];
52        int res;
53    
54      /*      /*
55       * ローカルファイルオープン       * ローカルファイルオープン
56       */       */
57      fd = open( local_fname, O_RDONLY );      fd = open( local_fname, O_RDONLY );
58      if( fd < 0 ) {      if( fd < 0 ) {
59          DEBUGPRINT1( "put_file: local file open error. %s\n", strerror(errno) );          DEBUGPRINT1( "local file open error. %s\n", strerror(errno) );
60          return -1;          return LIBOFTP_ERROR_OS;
61      }      }
62                    
63      /*      /*
# Line 83  static int ftp_put_file_main( LIBOFTP *f Line 84  static int ftp_put_file_main( LIBOFTP *f
84          if( n_rd < 0 ) {          if( n_rd < 0 ) {
85              if( errno == EINTR ) continue;              if( errno == EINTR ) continue;
86    
87              DEBUGPRINT1( "put_file: local file read error. %s\n", strerror(errno) );              DEBUGPRINT1( "local file read error. %s\n", strerror(errno) );
88                copy_strerror();
89              close( data_socket );              close( data_socket );
90              return -1;              return LIBOFTP_ERROR_OS;
91          }          }
92    
93          n_wr = sendn( data_socket, buf, n_rd, 0 );          n_wr = sendn( data_socket, buf, n_rd, 0 );
94          DEBUGPRINT1( "SEND: n=%d\n", n_wr );          DEBUGPRINT1( "SEND: n=%d\n", n_wr );
95          if( n_wr < 0 ) {          if( n_wr < 0 ) {
96                copy_strerror();
97              close( data_socket );              close( data_socket );
98              return -1;              return LIBOFTP_ERROR_OS;
99          }          }
100      }      }
101      close( fd );      close( fd );
# Line 101  static int ftp_put_file_main( LIBOFTP *f Line 104  static int ftp_put_file_main( LIBOFTP *f
104      /*      /*
105       * receive response.       * receive response.
106       */       */
107      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 );
108          return -2;      if( res != 226 ) {                                          /* 226: Closing data connection. */
109            DEBUGPRINT1( "got illegal response %d\n", res );
110            return res<0? res: LIBOFTP_ERROR_PROTOCOL;
111      }      }
112    
113      return 0;      return LIBOFTP_NOERROR;
114  }  }
115    
116    
117    
   
   
   
118  /***** Global functions *****************************************************/  /***** Global functions *****************************************************/
119    
120  /****************************************************************************/  /****************************************************************************/
# Line 121  static int ftp_put_file_main( LIBOFTP *f Line 123  static int ftp_put_file_main( LIBOFTP *f
123   *@param        ftp     LIBOFTPへのポインタ。   *@param        ftp     LIBOFTPへのポインタ。
124   *@param        local_fname     ローカルファイル名   *@param        local_fname     ローカルファイル名
125   *@param        fname   サーバ上のファイル名   *@param        fname   サーバ上のファイル名
126   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.   *@retval       int     エラーコード
127   *@note   *@note
128   */   */
129  int ftp_put_file( LIBOFTP *ftp, const char *local_fname, const char *fname )  int ftp_put_file( LIBOFTP *ftp, const char *local_fname, const char *fname )
# Line 137  int ftp_put_file( LIBOFTP *ftp, const ch Line 139  int ftp_put_file( LIBOFTP *ftp, const ch
139   *@param        ftp     LIBOFTPへのポインタ。   *@param        ftp     LIBOFTPへのポインタ。
140   *@param        local_fname     ローカルファイル名   *@param        local_fname     ローカルファイル名
141   *@param        fname   サーバ上のファイル名   *@param        fname   サーバ上のファイル名
142   *@retval       int     0: no error. -1: OS level error. -2: ftp protocol error. -3: buffer too small.   *@retval       int     エラーコード
143   *@note   *@note
144   */   */
145  int ftp_append_file( LIBOFTP *ftp, const char *local_fname, const char *fname )  int ftp_append_file( LIBOFTP *ftp, const char *local_fname, const char *fname )

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

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