Logs on to a FTP server. @param[in] logonInfo Structure with logon information.
| 448 | /// Logs on to a FTP server. |
| 449 | /// @param[in] logonInfo Structure with logon information. |
| 450 | bool CFTPClient::Login(const CLogonInfo& logonInfo) |
| 451 | { |
| 452 | m_LastLogonInfo = logonInfo; |
| 453 | |
| 454 | enum {LO=-2, ///< Logged On |
| 455 | ER=-1, ///< Error |
| 456 | NUMLOGIN=9, ///< currently supports 9 different login sequences |
| 457 | }; |
| 458 | |
| 459 | int iLogonSeq[NUMLOGIN][18] = { |
| 460 | // this array stores all of the logon sequences for the various firewalls |
| 461 | // in blocks of 3 nums. |
| 462 | // 1st num is command to send, |
| 463 | // 2nd num is next point in logon sequence array if 200 series response |
| 464 | // is rec'd from server as the result of the command, |
| 465 | // 3rd num is next point in logon sequence if 300 series rec'd |
| 466 | { 0,LO,3, 1,LO, 6, 2,LO,ER }, // no firewall |
| 467 | { 3, 6,3, 4, 6,ER, 5,ER, 9, 0,LO,12, 1,LO,15, 2,LO,ER }, // SITE hostname |
| 468 | { 3, 6,3, 4, 6,ER, 6,LO, 9, 1,LO,12, 2,LO,ER }, // USER after logon |
| 469 | { 7, 3,3, 0,LO, 6, 1,LO, 9, 2,LO,ER }, // proxy OPEN |
| 470 | { 3, 6,3, 4, 6,ER, 0,LO, 9, 1,LO,12, 2,LO,ER }, // Transparent |
| 471 | { 6,LO,3, 1,LO, 6, 2,LO,ER }, // USER with no logon |
| 472 | { 8, 6,3, 4, 6,ER, 0,LO, 9, 1,LO,12, 2,LO,ER }, // USER fireID@remotehost |
| 473 | { 9,ER,3, 1,LO, 6, 2,LO,ER }, // USER remoteID@remotehost fireID |
| 474 | {10,LO,3, 11,LO, 6, 2,LO,ER } // USER remoteID@fireID@remotehost |
| 475 | }; |
| 476 | |
| 477 | // are we connecting directly to the host (logon type 0) or via a firewall? (logon type>0) |
| 478 | tstring strTemp; |
| 479 | USHORT ushPort=0; |
| 480 | |
| 481 | if( logonInfo.FwType() == CFirewallType::None()) |
| 482 | { |
| 483 | strTemp = logonInfo.Hostname(); |
| 484 | ushPort = logonInfo.Hostport(); |
| 485 | } |
| 486 | else |
| 487 | { |
| 488 | strTemp = logonInfo.FwHost(); |
| 489 | ushPort = logonInfo.FwPort(); |
| 490 | } |
| 491 | |
| 492 | tstring strHostnamePort(logonInfo.Hostname()); |
| 493 | if( logonInfo.Hostport()!=DEFAULT_FTP_PORT ) |
| 494 | strHostnamePort = CMakeString() << logonInfo.Hostname() << _T(":") << logonInfo.Hostport(); // add port to hostname (only if port is not 21) |
| 495 | |
| 496 | if( IsConnected() ) |
| 497 | Logout(); |
| 498 | |
| 499 | if( !OpenControlChannel(strTemp, ushPort) ) |
| 500 | return false; |
| 501 | |
| 502 | // get initial connect msg off server |
| 503 | CReply Reply; |
| 504 | if( !GetResponse(Reply) || !Reply.Code().IsPositiveCompletionReply() ) |
| 505 | return false; |
| 506 | |
| 507 | int iLogonPoint=0; |
no test coverage detected