Skip to content
Snippets Groups Projects
ftp.c 29.4 KiB
Newer Older
  • Learn to ignore specific revisions
  • Daniel Stenberg's avatar
    Daniel Stenberg committed
          failf(data, "%s", buf+4);
          return URG_FTP_COULDNT_RETR_FILE;
        }
    	
      }
      /* end of transfer */
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
      ProgressEnd(data);
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
      /* shut down the socket to inform the server we're done */
      sclose(data->secondarysocket);
      data->secondarysocket = -1;
        
      /* now let's see what the server says about the transfer we
         just performed: */
      nread = GetLastResponse(data->firstsocket, buf, data);
    
      /* 226 Transfer complete */
      if(strncmp(buf, "226", 3)) {
        failf(data, "%s", buf+4);
        return URG_FTP_WRITE_ERROR;
      }
    
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
      /* Send any post-transfer QUOTE strings? */
      if(data->postquote) {
        qitem = data->postquote;
        /* Send all QUOTE strings in same order as on command-line */
        while (qitem) {
          /* Send string */
          if (qitem->data) {
            sendf(data->firstsocket, data, "%s\r\n", qitem->data);
    
            nread = GetLastResponse(data->firstsocket, buf, data);
    
            if (buf[0] != '2') {
              failf(data, "QUOT string not accepted: %s",
                    qitem->data);
              return URG_FTP_QUOTE_ERROR;
            }
          }
          qitem = qitem->next;
        }
      }
    
    
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
      return URG_OK;
    }
    
    /* -- deal with the ftp server!  -- */
    
    UrgError ftp(struct UrlData *data,
                 long *bytecountp,
                 char *ftpuser,
                 char *ftppasswd,
                 char *urlpath)
    {
      char *realpath;
      UrgError retcode;
    
    #if 0
      realpath = URLfix(urlpath);
    #else
      realpath = curl_unescape(urlpath);
    #endif
      if(realpath) {
        retcode = _ftp(data, bytecountp, ftpuser, ftppasswd, realpath);
        free(realpath);
      }
      else
        /* then we try the original path */
        retcode = _ftp(data, bytecountp, ftpuser, ftppasswd, urlpath);
    
      return retcode;
    }