MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / ResumeReceiveFilePASV

Method ResumeReceiveFilePASV

UTCP/src/ftp_c.cpp:623–752  ·  view source on GitHub ↗

ResumeReceiveFilePASV Resumes retrieving the specified file from the currently connected FTP site. The file is then saved to the specified destination file. This routine duplicates the ReceiveFile() member, but in this routine the client originates data connections. Client side origination of data connections is preferred for use in firewall controlled

Source from the content-addressed store, hash-verified

621 UTE_CONNECT_TIMEOUT - connection timeout
622****************************************/
623int CUT_FTPClient::ResumeReceiveFilePASV(CUT_DataSource & dest, LPCSTR sourceFile) {
624
625 UINT loop;
626 int rt, error;
627 char responseBuf[100];
628 int port;
629 char ipAddress[20];
630 char *token;
631 OpenMsgType fileType = UTM_OM_WRITING; // by default we will write a file unless it exist
632 // then we will append to it
633
634
635
636 //send the port command
637 Send("PASV\r\n");
638
639 m_wsData.SSLSetReuseSession(SSLGetCurrentSession());
640
641 // we need to get the full IP address and port number from the
642 // PASV return line, so that we can originate the data connection.
643
644 //check for a return of 2??, which indicates success
645 rt = GetResponseCode( this, responseBuf, sizeof(responseBuf) );
646 if(rt < 200 || rt >299)
647 return OnError(UTE_PORT_FAILED);
648
649
650 // find the first '(' in the response and then parse out
651 // the address supplied by the server
652 loop = 0;
653 while ( loop < strlen(responseBuf) ){
654 if ( responseBuf[loop] == '(' )
655 break;
656 loop++;
657 }
658
659 if ( loop == strlen(responseBuf) ) // we hit the end of the buffer
660 return OnError(UTE_RETR_FAILED);
661
662 // token out the ipaddress and port string
663 token = strtok( &responseBuf[loop], "()" );
664
665 // get the four portions of the ip address
666 strcpy(ipAddress, strtok( token, ",)\r\n" ));
667 strcat(ipAddress, ".");
668 strcat(ipAddress, strtok( NULL, ",)\r\n" ));
669 strcat(ipAddress, ".");
670 strcat(ipAddress, strtok( NULL, ",)\r\n" ));
671 strcat(ipAddress, ".");
672 strcat(ipAddress, strtok( NULL, ",)\r\n" ));
673
674 // get the two portions that make up the port number
675 port = atoi( strtok(NULL, ",)\r\n") ) * 256;
676 port += atoi( strtok(NULL, ",)\r\n") );
677
678 // test the results to ensure everything is OK.
679 if ( !IsIPAddress(ipAddress) )
680 return OnError(UTE_SVR_DATA_CONNECT_FAILED);

Callers

nothing calls this directly

Calls 7

SSLSetReuseSessionMethod · 0.80
CloseConnectionMethod · 0.80
ReceiveMethod · 0.80
OpenMethod · 0.45
SeekMethod · 0.45
CloseMethod · 0.45
ConnectMethod · 0.45

Tested by

no test coverage detected