projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ignore mouse wheel events which are coming too fast to be processed (#9057)
[wxWidgets.git]
/
src
/
common
/
ftp.cpp
diff --git
a/src/common/ftp.cpp
b/src/common/ftp.cpp
index 0a470ca93f1ba41d2f087c4a0362500e76c0b11a..27b3e70cdf3af1bd18a02b4d5065f03205cd28f1 100644
(file)
--- a/
src/common/ftp.cpp
+++ b/
src/common/ftp.cpp
@@
-19,10
+19,6
@@
// declarations
// ============================================================================
// declarations
// ============================================================================
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "ftp.h"
-#endif
-
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
@@
-42,6
+38,7
@@
#include "wx/utils.h"
#include "wx/log.h"
#include "wx/intl.h"
#include "wx/utils.h"
#include "wx/log.h"
#include "wx/intl.h"
+ #include "wx/wxcrtvararg.h"
#endif // WX_PRECOMP
#include "wx/sckaddr.h"
#endif // WX_PRECOMP
#include "wx/sckaddr.h"
@@
-51,10
+48,6
@@
#include "wx/protocol/protocol.h"
#include "wx/protocol/ftp.h"
#include "wx/protocol/protocol.h"
#include "wx/protocol/ftp.h"
-#if defined(__WXMAC__)
- #include "wx/mac/macsock.h"
-#endif
-
#ifndef __MWERKS__
#include <memory.h>
#endif
#ifndef __MWERKS__
#include <memory.h>
#endif
@@
-91,7
+84,7
@@
wxFTP::wxFTP()
m_passwd << wxGetUserId() << wxT('@') << wxGetFullHostName();
SetNotify(0);
m_passwd << wxGetUserId() << wxT('@') << wxGetFullHostName();
SetNotify(0);
- SetFlags(wxSOCKET_NO
NE
);
+ SetFlags(wxSOCKET_NO
WAIT
);
m_bPassive = true;
SetDefaultTimeout(60); // Default is Sixty Seconds
m_bEncounteredError = false;
m_bPassive = true;
SetDefaultTimeout(60); // Default is Sixty Seconds
m_bEncounteredError = false;
@@
-317,7
+310,7
@@
char wxFTP::GetResult()
}
else // subsequent line of multiline reply
{
}
else // subsequent line of multiline reply
{
- if (
wxStrncmp(line, code, LEN_CODE
) == 0 )
+ if (
line.compare(0, LEN_CODE, code
) == 0 )
{
if ( chMarker == _T(' ') )
{
{
if ( chMarker == _T(' ') )
{
@@
-348,7
+341,7
@@
char wxFTP::GetResult()
}
// if we got here we must have a non empty code string
}
// if we got here we must have a non empty code string
- return code[0u];
+ return
(char)
code[0u];
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
@@
-381,13
+374,13
@@
bool wxFTP::SetTransferMode(TransferMode transferMode)
if ( !DoSimpleCommand(_T("TYPE"), mode) )
{
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;
}
(transferMode == ASCII ? _("ASCII") : _("binary")));
return false;
}
- // If we get here the operation has been succesfully completed
+ // If we get here the operation has been succes
s
fully completed
// Set the status-member
m_currentTransfermode = transferMode;
// Set the status-member
m_currentTransfermode = transferMode;
@@
-438,19
+431,20
@@
wxString wxFTP::Pwd()
if ( CheckCommand(wxT("PWD"), '2') )
{
// the result is at least that long if CheckCommand() succeeded
if ( CheckCommand(wxT("PWD"), '2') )
{
// the result is at least that long if CheckCommand() succeeded
-
const wxChar *p = m_lastResult.c_str
() + LEN_CODE + 1;
+
wxString::const_iterator p = m_lastResult.begin
() + LEN_CODE + 1;
if ( *p != _T('"') )
{
if ( *p != _T('"') )
{
- wxLogDebug(_T("Missing starting quote in reply for PWD: %s"), p);
+ wxLogDebug(_T("Missing starting quote in reply for PWD: %s"),
+ wxString(p, m_lastResult.end()));
}
else
{
}
else
{
- for (
p++; *p; p++ )
+ for (
++p; (bool)*p; ++p ) // FIXME-DMARS
{
if ( *p == _T('"') )
{
// check if the quote is doubled
{
if ( *p == _T('"') )
{
// check if the quote is doubled
-
p++
;
+
++p
;
if ( !*p || *p != _T('"') )
{
// no, this is the end
if ( !*p || *p != _T('"') )
{
// no, this is the end
@@
-645,8
+639,8
@@
wxSocketBase *wxFTP::AcceptIfActive(wxSocketBase *sock)
return sock;
}
return sock;
}
-wxString wxFTP::GetPortCmdArgument(
wxIPV4address
addrLocal,
-
wxIPV4address
addrNew)
+wxString wxFTP::GetPortCmdArgument(
const wxIPV4address&
addrLocal,
+
const wxIPV4address&
addrNew)
{
// Just fills in the return value with the local IP
// address of the current socket. Also it fill in the
{
// Just fills in the return value with the local IP
// address of the current socket. Also it fill in the
@@
-689,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);
// 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;
{
m_lastError = wxPROTO_PROTERR;
delete sockSrv;
@@
-709,18
+703,20
@@
wxSocketBase *wxFTP::GetPassivePort()
return NULL;
}
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;
{
m_lastError = wxPROTO_PROTERR;
-
return NULL;
}
// get the port number and address
int a[6];
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]);
wxSscanf(straddr, wxT("%d,%d,%d,%d,%d,%d"),
&a[2],&a[3],&a[4],&a[5],&a[0],&a[1]);
@@
-824,7
+820,7
@@
bool wxFTP::GetList(wxArrayString& files,
// - Windows : like "dir" command
// - others : ?
wxString line(details ? _T("LIST") : _T("NLST"));
// - Windows : like "dir" command
// - others : ?
wxString line(details ? _T("LIST") : _T("NLST"));
- if ( !wildcard.
IsE
mpty() )
+ if ( !wildcard.
e
mpty() )
{
line << _T(' ') << wildcard;
}
{
line << _T(' ') << wildcard;
}
@@
-865,7
+861,7
@@
bool wxFTP::FileExists(const wxString& fileName)
if ( GetList(fileList, fileName, false) )
{
// Some ftp-servers (Ipswitch WS_FTP Server 1.0.5 does this)
if ( GetList(fileList, fileName, false) )
{
// Some ftp-servers (Ipswitch WS_FTP Server 1.0.5 does this)
- // displays this behaviour when queried on a non
-existing
file:
+ // displays this behaviour when queried on a non
existent
file:
// NLST this_file_does_not_exist
// 150 Opening ASCII data connection for directory listing
// (no data transferred)
// NLST this_file_does_not_exist
// 150 Opening ASCII data connection for directory listing
// (no data transferred)
@@
-954,7
+950,7
@@
int wxFTP::GetFileSize(const wxString& fileName)
bool foundIt = false;
size_t i;
bool foundIt = false;
size_t i;
- for ( i = 0; !foundIt && i < fileList.Count(); i++ )
+ for ( i = 0; !foundIt && i < fileList.
Get
Count(); i++ )
{
foundIt = fileList[i].Upper().Contains(fileName.Upper());
}
{
foundIt = fileList[i].Upper().Contains(fileName.Upper());
}