X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2523e9b70044baa92a1c63ffdfe179c28ad53536..4954ee50328dc010ec3c934fd6deeab08c4447d6:/src/common/ftp.cpp diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index da7c72171e..27b3e70cdf 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -48,10 +48,6 @@ #include "wx/protocol/protocol.h" #include "wx/protocol/ftp.h" -#if defined(__WXMAC__) - #include "wx/mac/macsock.h" -#endif - #ifndef __MWERKS__ #include #endif @@ -314,7 +310,7 @@ char wxFTP::GetResult() } else // subsequent line of multiline reply { - if ( wxStrncmp(line, code, LEN_CODE) == 0 ) + if ( line.compare(0, LEN_CODE, code) == 0 ) { if ( chMarker == _T(' ') ) { @@ -378,7 +374,7 @@ bool wxFTP::SetTransferMode(TransferMode transferMode) if ( !DoSimpleCommand(_T("TYPE"), mode) ) { - wxLogError(_("Failed to set FTP transfer mode to %s."), (const wxChar*) + wxLogError(_("Failed to set FTP transfer mode to %s."), (transferMode == ASCII ? _("ASCII") : _("binary"))); return false; @@ -687,7 +683,7 @@ wxSocketBase *wxFTP::GetActivePort() // addresses because the addrNew has an IP of "0.0.0.0", so we need the // value in addrLocal wxString port = GetPortCmdArgument(addrLocal, addrNew); - if ( !DoSimpleCommand(_T("PORT "), port) ) + if ( !DoSimpleCommand(_T("PORT"), port) ) { m_lastError = wxPROTO_PROTERR; delete sockSrv; @@ -707,18 +703,20 @@ wxSocketBase *wxFTP::GetPassivePort() return NULL; } - const wxChar *addrStart = wxStrchr(m_lastResult, _T('(')); - const wxChar *addrEnd = addrStart ? wxStrchr(addrStart, _T(')')) : NULL; - if ( !addrEnd ) + size_t addrStart = m_lastResult.find(_T('(')); + size_t addrEnd = (addrStart == wxString::npos) + ? wxString::npos + : m_lastResult.find(_T(')'), addrStart); + + if ( addrEnd == wxString::npos ) { m_lastError = wxPROTO_PROTERR; - return NULL; } // get the port number and address int a[6]; - wxString straddr(addrStart + 1, addrEnd); + wxString straddr(m_lastResult, addrStart + 1, addrEnd - (addrStart + 1)); wxSscanf(straddr, wxT("%d,%d,%d,%d,%d,%d"), &a[2],&a[3],&a[4],&a[5],&a[0],&a[1]);