Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/ftp_open.c

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

revision 29 by hirohitohigashi, Sat Feb 28 12:48:31 2009 UTC revision 50 by hirohitohigashi, Wed Dec 2 15:13:30 2009 UTC
# Line 65  static const char * my_hstrerror( int no Line 65  static const char * my_hstrerror( int no
65  int ftp_initialize( LIBOFTP *ftp )  int ftp_initialize( LIBOFTP *ftp )
66  {  {
67      memset( ftp, 0, sizeof( LIBOFTP ) );      memset( ftp, 0, sizeof( LIBOFTP ) );
68        ftp->socket = -1;
69      ftp->timeout_sec = 10;                      /* default timeout */      ftp->timeout_sec = 10;                      /* default timeout */
70    
71      return LIBOFTP_NOERROR;      return LIBOFTP_NOERROR;
# Line 87  int ftp_open( LIBOFTP *ftp, const char * Line 88  int ftp_open( LIBOFTP *ftp, const char *
88      struct hostent *p_hostent;      struct hostent *p_hostent;
89      int res;      int res;
90    
91        if( ftp->socket >= 0 ) return LIBOFTP_ERROR;
92      if( port == 0 ) port = 21;      if( port == 0 ) port = 21;
93    
94      /*      /*
# Line 109  int ftp_open( LIBOFTP *ftp, const char * Line 111  int ftp_open( LIBOFTP *ftp, const char *
111      if( ftp->socket < 0 ) {      if( ftp->socket < 0 ) {
112          DEBUGPRINT1( "can't create socket. %s\n", strerror(errno) );          DEBUGPRINT1( "can't create socket. %s\n", strerror(errno) );
113          copy_strerror();          copy_strerror();
114          ftp->socket = 0;          ftp->socket = -1;
115          return LIBOFTP_ERROR_OS;          return LIBOFTP_ERROR_OS;
116      }      }
117    
# Line 117  int ftp_open( LIBOFTP *ftp, const char * Line 119  int ftp_open( LIBOFTP *ftp, const char *
119          DEBUGPRINT1( "can't connect socket. %s\n", strerror(errno) );          DEBUGPRINT1( "can't connect socket. %s\n", strerror(errno) );
120          copy_strerror();          copy_strerror();
121          close( ftp->socket );          close( ftp->socket );
122          ftp->socket = 0;          ftp->socket = -1;
123          return LIBOFTP_ERROR_OS;          return LIBOFTP_ERROR_OS;
124      }      }
125    
126      res = ftp_timeout( ftp, ftp->timeout_sec );      res = ftp_timeout( ftp, ftp->timeout_sec );
127      if( res < 0 ) {      if( res < 0 ) {
128          close( ftp->socket );          close( ftp->socket );
129          ftp->socket = 0;          ftp->socket = -1;
130          return res;          return res;
131      }      }
132    
# Line 135  int ftp_open( LIBOFTP *ftp, const char * Line 137  int ftp_open( LIBOFTP *ftp, const char *
137      if( res != 220 ) {                                          /* 220: Service ready for new user. */      if( res != 220 ) {                                          /* 220: Service ready for new user. */
138          DEBUGPRINT1( "Illegal response. %d\n", res );          DEBUGPRINT1( "Illegal response. %d\n", res );
139          close( ftp->socket );          close( ftp->socket );
140          ftp->socket = 0;          ftp->socket = -1;
141          return res < 0? res: LIBOFTP_ERROR_PROTOCOL;          return res < 0? res: LIBOFTP_ERROR_PROTOCOL;
142      }      }
143    

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

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