projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Had missed one LPSTR.
[wxWidgets.git]
/
src
/
common
/
ftp.cpp
diff --git
a/src/common/ftp.cpp
b/src/common/ftp.cpp
index d0b2a80211366cb6a46014c6f99d8231fa83a051..090138b5d7a1cb472402f93fb175f19a65c6ef18 100644
(file)
--- a/
src/common/ftp.cpp
+++ b/
src/common/ftp.cpp
@@
-20,6
+20,8
@@
#pragma hdrstop
#endif
#pragma hdrstop
#endif
+#if wxUSE_SOCKETS
+
#ifndef __MWERKS__
#include <memory.h>
#endif
#ifndef __MWERKS__
#include <memory.h>
#endif
@@
-48,7
+50,7
@@
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxFTP, wxProtocol)
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxFTP, wxProtocol)
-IMPLEMENT_PROTOCOL(wxFTP,
"ftp", "ftp"
, TRUE)
+IMPLEMENT_PROTOCOL(wxFTP,
_T("ftp"), _T("ftp")
, TRUE)
#endif
////////////////////////////////////////////////////////////////
#endif
////////////////////////////////////////////////////////////////
@@
-58,16
+60,13
@@
IMPLEMENT_PROTOCOL(wxFTP, "ftp", "ftp", TRUE)
wxFTP::wxFTP()
: wxProtocol()
{
wxFTP::wxFTP()
: wxProtocol()
{
- char tmp[256];
-
m_lastError = wxPROTO_NOERR;
m_streaming = FALSE;
m_lastError = wxPROTO_NOERR;
m_streaming = FALSE;
- m_user = "anonymous";
- wxGetUserName(tmp, 256);
- m_passwd.sprintf("%s@",tmp);
- wxGetHostName(tmp, 256);
- m_passwd += tmp;
+ m_user = _T("anonymous");
+ m_passwd = wxGetUserId();
+ m_passwd += '@';
+ m_passwd += wxGetHostName();
SetNotify(0);
}
SetNotify(0);
}
@@
-104,13
+103,13
@@
bool wxFTP::Connect(wxSockAddress& addr, bool WXUNUSED(wait))
return FALSE;
}
return FALSE;
}
- command.sprintf(
"USER %s", (const c
har *)m_user);
+ command.sprintf(
_T("USER %s"), (const wxC
har *)m_user);
if (!SendCommand(command, '3')) {
Close();
return FALSE;
}
if (!SendCommand(command, '3')) {
Close();
return FALSE;
}
- command.sprintf(
"PASS %s", (const c
har *)m_passwd);
+ command.sprintf(
_T("PASS %s"), (const wxC
har *)m_passwd);
if (!SendCommand(command, '2')) {
Close();
return FALSE;
if (!SendCommand(command, '2')) {
Close();
return FALSE;
@@
-125,7
+124,7
@@
bool wxFTP::Connect(const wxString& host)
wxString my_host = host;
addr.Hostname(my_host);
wxString my_host = host;
addr.Hostname(my_host);
- addr.Service(
"ftp"
);
+ addr.Service(
_T("ftp")
);
return Connect(addr);
}
return Connect(addr);
}
@@
-137,7
+136,7
@@
bool wxFTP::Close()
return FALSE;
}
if (m_connected)
return FALSE;
}
if (m_connected)
- SendCommand(wxString(
"QUIT"
), '2');
+ SendCommand(wxString(
_T("QUIT")
), '2');
return wxSocketClient::Close();
}
return wxSocketClient::Close();
}
@@
-152,8
+151,9
@@
bool wxFTP::SendCommand(const wxString& command, char exp_ret)
m_lastError = wxPROTO_STREAMING;
return FALSE;
}
m_lastError = wxPROTO_STREAMING;
return FALSE;
}
- tmp_str = command + "\r\n";
- if (Write((char *)tmp_str.GetData(), tmp_str.Length()).Error()) {
+ tmp_str = command + _T("\r\n");
+ const wxWX2MBbuf tmp_buf = tmp_str.mb_str();
+ if (Write(MBSTRINGCAST tmp_buf, strlen(tmp_buf)).Error()) {
m_lastError = wxPROTO_NETERR;
return FALSE;
}
m_lastError = wxPROTO_NETERR;
return FALSE;
}
@@
-172,7
+172,7
@@
bool wxFTP::GetResult(char exp)
if (m_lastResult.GetChar(3) == '-') {
wxString key = m_lastResult.Left((size_t)3);
if (m_lastResult.GetChar(3) == '-') {
wxString key = m_lastResult.Left((size_t)3);
- key +=
' '
;
+ key +=
_T(' ')
;
while (m_lastResult.Index(key) != 0) {
if ((m_lastError = GetLine(this, m_lastResult)))
while (m_lastResult.Index(key) != 0) {
if ((m_lastError = GetLine(this, m_lastResult)))
@@
-189,14
+189,14
@@
bool wxFTP::ChDir(const wxString& dir)
{
wxString str = dir;
{
wxString str = dir;
- str.Prepend(
"CWD "
);
+ str.Prepend(
_T("CWD ")
);
return SendCommand(str, '2');
}
bool wxFTP::MkDir(const wxString& dir)
{
wxString str = dir;
return SendCommand(str, '2');
}
bool wxFTP::MkDir(const wxString& dir)
{
wxString str = dir;
- str.Prepend(
"MKD "
);
+ str.Prepend(
_T("MKD ")
);
return SendCommand(str, '2');
}
return SendCommand(str, '2');
}
@@
-204,7
+204,7
@@
bool wxFTP::RmDir(const wxString& dir)
{
wxString str = dir;
{
wxString str = dir;
- str.Prepend(
"PWD "
);
+ str.Prepend(
_T("PWD ")
);
return SendCommand(str, '2');
}
return SendCommand(str, '2');
}
@@
-212,11
+212,11
@@
wxString wxFTP::Pwd()
{
int beg, end;
{
int beg, end;
- if (!SendCommand(
"PWD"
, '2'))
+ if (!SendCommand(
_T("PWD")
, '2'))
return wxString((char *)NULL);
return wxString((char *)NULL);
- beg = m_lastResult.Find(
'\"'
,FALSE);
- end = m_lastResult.Find(
'\"'
,TRUE);
+ beg = m_lastResult.Find(
_T('\"')
,FALSE);
+ end = m_lastResult.Find(
_T('\"')
,TRUE);
return wxString(beg+1, end);
}
return wxString(beg+1, end);
}
@@
-225,11
+225,11
@@
bool wxFTP::Rename(const wxString& src, const wxString& dst)
{
wxString str;
{
wxString str;
- str =
"RNFR "
+ src;
+ str =
_T("RNFR ")
+ src;
if (!SendCommand(str, '3'))
return FALSE;
if (!SendCommand(str, '3'))
return FALSE;
- str =
"RNTO "
+ dst;
+ str =
_T("RNTO ")
+ dst;
return SendCommand(str, '2');
}
return SendCommand(str, '2');
}
@@
-237,7
+237,7
@@
bool wxFTP::RmFile(const wxString& path)
{
wxString str;
{
wxString str;
- str =
"DELE "
;
+ str =
_T("DELE ")
;
str += path;
return SendCommand(str, '2');
}
str += path;
return SendCommand(str, '2');
}
@@
-253,7
+253,7
@@
public:
wxInputFTPStream(wxFTP *ftp_clt, wxSocketBase *sock)
: wxSocketInputStream(*sock), m_ftp(ftp_clt) {}
wxInputFTPStream(wxFTP *ftp_clt, wxSocketBase *sock)
: wxSocketInputStream(*sock), m_ftp(ftp_clt) {}
- size_t StreamSize() { return m_ftpsize; }
+ size_t StreamSize()
const
{ return m_ftpsize; }
virtual ~wxInputFTPStream(void)
{
if (LastError() != wxStream_NOERROR)
virtual ~wxInputFTPStream(void)
{
if (LastError() != wxStream_NOERROR)
@@
-289,17
+289,17
@@
wxSocketClient *wxFTP::GetPort()
wxString straddr;
int addr_pos;
wxString straddr;
int addr_pos;
- if (!SendCommand(
"PASV"
, '2'))
+ if (!SendCommand(
_T("PASV")
, '2'))
return NULL;
sin.sa_family = AF_INET;
return NULL;
sin.sa_family = AF_INET;
- addr_pos = m_lastResult.Find(
'('
);
+ addr_pos = m_lastResult.Find(
_T('(')
);
if (addr_pos == -1) {
m_lastError = wxPROTO_PROTERR;
return NULL;
}
straddr = m_lastResult(addr_pos+1, m_lastResult.Length());
if (addr_pos == -1) {
m_lastError = wxPROTO_PROTERR;
return NULL;
}
straddr = m_lastResult(addr_pos+1, m_lastResult.Length());
-
sscanf((const char *)straddr,"%d,%d,%d,%d,%d,%d"
,&a[2],&a[3],&a[4],&a[5],&a[0],&a[1]);
+
wxSscanf((const wxChar *)straddr,_T("%d,%d,%d,%d,%d,%d")
,&a[2],&a[3],&a[4],&a[5],&a[0],&a[1]);
sin.sa_data[2] = (char)a[2];
sin.sa_data[3] = (char)a[3];
sin.sa_data[4] = (char)a[4];
sin.sa_data[2] = (char)a[2];
sin.sa_data[3] = (char)a[3];
sin.sa_data[4] = (char)a[4];
@@
-322,7
+322,7
@@
wxSocketClient *wxFTP::GetPort()
bool wxFTP::Abort(void)
{
m_streaming = FALSE;
bool wxFTP::Abort(void)
{
m_streaming = FALSE;
- if (!SendCommand(
"ABOR"
, '4'))
+ if (!SendCommand(
_T("ABOR")
, '4'))
return FALSE;
return GetResult('2');
}
return FALSE;
return GetResult('2');
}
@@
-333,7
+333,7
@@
wxInputStream *wxFTP::GetInputStream(const wxString& path)
int pos_size;
wxInputFTPStream *in_stream;
int pos_size;
wxInputFTPStream *in_stream;
- if (!SendCommand(
"TYPE I"
, '2'))
+ if (!SendCommand(
_T("TYPE I")
, '2'))
return NULL;
wxSocketClient *sock = GetPort();
return NULL;
wxSocketClient *sock = GetPort();
@@
-343,18
+343,19
@@
wxInputStream *wxFTP::GetInputStream(const wxString& path)
return NULL;
}
return NULL;
}
- tmp_str =
"RETR "
+ path;
+ tmp_str =
_T("RETR ")
+ path;
if (!SendCommand(tmp_str, '1'))
return NULL;
in_stream = new wxInputFTPStream(this, sock);
if (!SendCommand(tmp_str, '1'))
return NULL;
in_stream = new wxInputFTPStream(this, sock);
- pos_size = m_lastResult.Index(
'('
);
+ pos_size = m_lastResult.Index(
_T('(')
);
if (pos_size != wxNOT_FOUND) {
if (pos_size != wxNOT_FOUND) {
- wxString str_size = m_lastResult(pos_size
, m_lastResult.Index(')')
);
+ wxString str_size = m_lastResult(pos_size
+1, m_lastResult.Index(_T(')'))-1
);
- in_stream->m_ftpsize =
a
toi(WXSTRINGCAST str_size);
+ in_stream->m_ftpsize =
wxA
toi(WXSTRINGCAST str_size);
}
}
+ sock->SetFlags(WAITALL);
return in_stream;
}
return in_stream;
}
@@
-363,12
+364,12
@@
wxOutputStream *wxFTP::GetOutputStream(const wxString& path)
{
wxString tmp_str;
{
wxString tmp_str;
- if (!SendCommand(
"TYPE I"
, '2'))
+ if (!SendCommand(
_T("TYPE I")
, '2'))
return NULL;
wxSocketClient *sock = GetPort();
return NULL;
wxSocketClient *sock = GetPort();
- tmp_str =
"STOR "
+ path;
+ tmp_str =
_T("STOR ")
+ path;
if (!SendCommand(tmp_str, '1'))
return FALSE;
if (!SendCommand(tmp_str, '1'))
return FALSE;
@@
-379,7
+380,7
@@
wxList *wxFTP::GetList(const wxString& wildcard)
{
wxList *file_list = new wxList;
wxSocketBase *sock = GetPort();
{
wxList *file_list = new wxList;
wxSocketBase *sock = GetPort();
- wxString tmp_str =
"NLST"
;
+ wxString tmp_str =
_T("NLST")
;
if (!wildcard.IsNull())
tmp_str += wildcard;
if (!wildcard.IsNull())
tmp_str += wildcard;
@@
-403,3
+404,5
@@
wxList *wxFTP::GetList(const wxString& wildcard)
return file_list;
}
return file_list;
}
+#endif
+ // wxUSE_SOCKETS