![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cClientFTP.h>
Public Member Functions | |
cClientFTP (cFTPFactory *pFactory, IUnkObject *pServerConnection, cStreamInput *pStreamInp, cStreamOutput *pStreamOut) | |
virtual | ~cClientFTP () |
cFTPFactory * | get_FTPFactory () const |
virtual HRESULT | DisposeThis (void) override |
void | Data_ConnectComplete (cClientFTPData *pClient, bool bPasv) |
HRESULT | Data_ConnectOpen () |
bool | Data_IsPASV () const |
HTTPRET_TYPE | MakeFilePath (const char *pszName, FTP_PRIV_TYPE_ wPrivReq, cFileFindEntry *pfd=nullptr) |
const char * | DoCommandCheck (const char *pszCmdBuffer) |
void | DoControlCmd (const char *pszCmdBuffer) |
virtual HRESULT | ProcessStreamPacket () override |
bool | OnException () |
StrLen_t _cdecl | ReplyF (HTTPRET_TYPE eReplyCode, const char *pReplyString,...) |
int | Reply_OK (HTTPRET_TYPE eReplyCode=HTTPRET_OK_DATA) |
int | Reply_BadPath (HTTPRET_TYPE eReplyCode=HTTPRET_ER_550) |
int | Reply_SysError (HTTPRET_TYPE eReplyCode, const char *pszText, HRESULT hRes) |
int | Reply_SysErrorLast (HTTPRET_TYPE eReplyCode, const char *pszText=nullptr) |
int | Reply_ParameterNotImplemented (const char *pText) |
int | Reply_DataTransferError (const char *pError, HRESULT hRes) |
int | Reply_DataTransferAbort (HRESULT hRes) |
int | Reply_DataTransferComplete (void) |
void | Cmd_Allo (const char *pszParam) |
void | Cmd_Auth (const char *pszParam) |
void | Cmd_Appe (const char *pszParam) |
void | Cmd_Pwd (const char *pszParam) |
void | Cmd_Cwd (const char *pszParam) |
void | Cmd_Cdup (const char *pszParam) |
void | Cmd_Mkd (const char *pszParam) |
void | Cmd_Opts (const char *pszParam) |
void | Cmd_Rest (const char *pszParam) |
void | Cmd_Rmd (const char *pszParam) |
void | Cmd_Retr (const char *pszParam) |
void | Cmd_Stor_Base (const char *pszParam, bool bAppend) |
void | Cmd_Stor (const char *pszParam) |
void | Cmd_Dele (const char *pszParam) |
void | Cmd_Epsv (const char *pszParam) |
void | Cmd_Help_Base (const CFTPCmd *pCmds, const char *pszType, const char *pszParam) |
void | Cmd_Help (const char *pszParam) |
void | Cmd_List_Base (const char *pszParam, bool bVerbose) |
void | Cmd_Mdtm (const char *pszParam) |
void | Cmd_List (const char *pszParam) |
void | Cmd_Nlst (const char *pszParam) |
void | Cmd_User (const char *pszParam) |
void | Cmd_Pass (const char *pszParam) |
void | Cmd_Pasv (const char *pszParam) |
void | Cmd_Noop (const char *pszParam) |
void | Cmd_Quit (const char *pszParam) |
void | Cmd_Port (const char *pszParam) |
void | Cmd_Syst (const char *pszParam) |
void | Cmd_Abor (const char *pszParam) |
void | Cmd_Mode (const char *pszParam) |
void | Cmd_Struct (const char *pszParam) |
void | Cmd_Stat (const char *pszParam) |
void | Cmd_Size (const char *pszParam) |
void | Cmd_Type (const char *pszParam) |
void | Cmd_Feat (const char *pszParam) |
void | Cmd_Rnfr (const char *pszParam) |
void | Cmd_Rnto (const char *pszParam) |
void | Cmd_UTF8 (const char *pszParam) |
void | Cmd_Site (const char *pszParam) |
void | Cmd_Site_Help (const char *pszParam) |
StrLen_t _cdecl | LogEventF (LOG_ATTR_MASK_t dwAttrMask, const LOGCHAR_t *pszFormat,...) |
![]() | |
cClientFTPBase (IProtocolFactory *pFactory, IUnkObject *pServerConnection, cStreamInput *pStreamInp, cStreamOutput *pStreamOut) | |
virtual | ~cClientFTPBase () |
HASHCODE_t | get_HashCode () const noexcept |
cNetServerConnection * | get_NetStream () const |
IUNKNOWN_DISAMBIG (cRefBase) | |
![]() | |
cRefBase (int iRefCount=0) noexcept | |
virtual | ~cRefBase () |
int | get_RefCount () const noexcept |
HASHCODE_t | get_HashCode () const noexcept |
STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept | |
virtual void | onFinalRelease () |
bool | isValidObj () const noexcept |
STDMETHOD_ (ULONG, AddRef)(void) override | |
STDMETHOD_ (ULONG, Release)(void) override | |
STDMETHOD() | QueryInterface (const IID &riid, void __RPC_FAR *__RPC_FAR *ppvObject) override |
void | IncRefCount () |
void | DecRefCount () |
bool | isStaticConstruct () const noexcept |
void | StaticConstruct () |
void | StaticDestruct () |
bool | isDestructing () noexcept |
void | SetDestructing () |
![]() | |
cProtocolStream (IProtocolFactory *pProtocolFactory, IUnkObject *pServerConnection, cStreamInput *pStreamInp, cStreamOutput *pStreamOut) | |
virtual | ~cProtocolStream () |
HASHCODE_t | get_HashCode () const noexcept |
STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept override | |
STDMETHOD_ (cString, get_Name)() const override | |
STDMETHOD_ (cStringA, get_SymName)() const override | |
bool | isConnected () const |
cStreamInput * | get_StreamInp () const |
cStreamOutput * | get_StreamOut () const |
virtual size_t | get_ProtocolMaxMessageSize () const |
virtual HRESULT | OnTickStream () |
Static Public Member Functions | |
static bool | IsRoot (const char *pStr) |
Public Attributes | |
cNetAddrName | m_AddrPeer |
DNS lookup of my peer name. get_NetStream()->m_addrPeer. More... | |
cNetAddrTrackPtr | m_pAddrTrack |
Duplicates m_AddrPeer ?? More... | |
cSSLServerStreamPtr | m_pAuthSSL |
We used the AUTH command or are implicit SSL/TLS connection. More... | |
char | m_szCmdBuffer [_MAX_PATH] |
current command + path. More... | |
const CFTPCmd * | m_pCmd |
Current Command. More... | |
cStringA | m_sUserName |
Might be the anon users email. More... | |
cFTPAccountPtr | m_pAccount |
Account we are trying to log in with. May not yet be logged in. More... | |
bool | m_bAccountLogin |
m_pAccount is logged in (may be anon) More... | |
bool | m_bUTF8 |
STREAM_POS_t | m_nDataRestoreOffset |
restore offset, for file transfers. set via Cmd_Rest More... | |
cNetAddress | m_DAddr |
data address (can be changed w/ Port command) for (non pasv) outgoing data connections. More... | |
cNetServerPortPtr | m_pDPasv |
an expected/waiting/incoming Pasv/EPSV data connection. (can only have one at a time) More... | |
cFTPDataParamsPtr | m_pDataParams |
Set up params for the next data connection. More... | |
cArrayRef< cClientFTPData > | m_aConnectData |
open data connections for this control connection. More... | |
FTP_TTYPE_TYPE | m_TransferType |
FTP_TMODE_TYPE | m_TransferMode |
FTP_TSTRUCT_TYPE | m_TransferStruct |
cStringA | m_sCWD |
Current working user path directory or file. (in Unix form) More... | |
cStringA | m_sActiveUserPath |
file/path (in Unix form) More... | |
FILECHAR_t | m_tActiveFilePath [_MAX_PATH] |
current valid (user checked) full real system path/file. More... | |
![]() | |
TIMESYS_t | m_timeLast |
time of last command/action. More... | |
![]() | |
IProtocolFactory *const | m_pProtocolFactory |
What IProtocolFactory produced this? More... | |
IUnkObject *const | m_pServerConnection |
the cNetServerConnection or other top level parent for this protocol. More... | |
HASHCODE_t const | m_nHashCode |
the m_pClient->get_HashCode() id for this client connection/stream. More... | |
Protected Member Functions | |
void | Cmd_Pasv_Start (const char *pszParam, bool bExt) |
Static Protected Member Functions | |
static const CFTPCmd * | FindCmd (const CFTPCmd *pCmds, const char *pszCmd) |
Additional Inherited Members | |
![]() | |
cStreamInput * | m_pStreamInp |
for use with ProcessStreamPacket() More... | |
cStreamOutput * | m_pStreamOut |
TX responses back to the remote client go here. (e.g. cNetServerConnection->cNetStream) More... | |
cString | m_sName |
a user readable name. Usually the IP address or reverse DNS lookup. can be upgraded as lookup or login becomes avail. m_pClient->get_Name() More... | |
A FTP command client SOCKET that connects to this FTP server. Single IP/Account can have multiple data connections open at the same time.
GrayFTP::cClientFTP::cClientFTP | ( | cFTPFactory * | pFactory, |
IUnkObject * | pServerConnection, | ||
cStreamInput * | pStreamInp, | ||
cStreamOutput * | pStreamOut | ||
) |
create FTP command connection. Say Welcome.
|
virtual |
void GrayFTP::cClientFTP::Cmd_Abor | ( | const char * | pszParam | ) |
ABOR command. kill the data transfer.
void GrayFTP::cClientFTP::Cmd_Allo | ( | const char * | pszParam | ) |
Set the (total file) allocation size for transfers. This command shall be followed by a STORe or APPEnd command. The ALLO command should be treated as a __noop (no operation) by those servers which do not require that the maximum size of the file be declared beforehand,
void GrayFTP::cClientFTP::Cmd_Appe | ( | const char * | pszParam | ) |
Append to existing file.
void GrayFTP::cClientFTP::Cmd_Auth | ( | const char * | pszParam | ) |
void GrayFTP::cClientFTP::Cmd_Cdup | ( | const char * | pszParam | ) |
CDUP command
void GrayFTP::cClientFTP::Cmd_Cwd | ( | const char * | pszParam | ) |
CWD command Set the current directory to something legal. NOTE: IE does this -> pszParam=="169 CATEGORY.DAT"
void GrayFTP::cClientFTP::Cmd_Dele | ( | const char * | pszParam | ) |
DELE command
void GrayFTP::cClientFTP::Cmd_Epsv | ( | const char * | pszParam | ) |
extended passive mode. port only. http://www.apps.ietf.org/rfc/rfc2428.html mostly ignore this command. it means EPRT wont be used. EPSV ALL -
void GrayFTP::cClientFTP::Cmd_Feat | ( | const char * | pszParam | ) |
Feat 211-Extended features supported: LANG EN* UTF8 AUTH TLS;TLS-C;SSL;TLS-P; PBSZ PROT C;P; CCC HOST SIZE MDTM REST STREAM 211 END
void GrayFTP::cClientFTP::Cmd_Help | ( | const char * | pszParam | ) |
HELP command. NOTE: None of these should start with numbers.
void GrayFTP::cClientFTP::Cmd_Help_Base | ( | const CFTPCmd * | pCmds, |
const char * | pszType, | ||
const char * | pszParam | ||
) |
void GrayFTP::cClientFTP::Cmd_List | ( | const char * | pszParam | ) |
LIST command
void GrayFTP::cClientFTP::Cmd_List_Base | ( | const char * | pszParam, |
bool | bVerbose | ||
) |
Get a directory listing.
void GrayFTP::cClientFTP::Cmd_Mdtm | ( | const char * | pszParam | ) |
MDTM command. Returns the last modified time of the given file Can be used to set the last mod time ?
void GrayFTP::cClientFTP::Cmd_Mkd | ( | const char * | pszParam | ) |
MKD, XMKD commands
void GrayFTP::cClientFTP::Cmd_Mode | ( | const char * | pszParam | ) |
MODE command
void GrayFTP::cClientFTP::Cmd_Nlst | ( | const char * | pszParam | ) |
NLST command just list names and no other info.
void GrayFTP::cClientFTP::Cmd_Noop | ( | const char * | pszParam | ) |
__noop command
void GrayFTP::cClientFTP::Cmd_Opts | ( | const char * | pszParam | ) |
opts utf8 on
void GrayFTP::cClientFTP::Cmd_Pass | ( | const char * | pszParam | ) |
PASS command Attempt to login.
void GrayFTP::cClientFTP::Cmd_Pasv | ( | const char * | pszParam | ) |
PASV Set into passive mode for data connection. remote/client side will connect to us. we should tell them where to go.
|
protected |
Request params for making a PASV or EPSV connection.
void GrayFTP::cClientFTP::Cmd_Port | ( | const char * | pszParam | ) |
PORT command, IPv4 Request the NOT PASV data connection address!
void GrayFTP::cClientFTP::Cmd_Pwd | ( | const char * | pszParam | ) |
PWD, XPWD commands Just tell me what the current directory is.
void GrayFTP::cClientFTP::Cmd_Quit | ( | const char * | pszParam | ) |
QUIT command
void GrayFTP::cClientFTP::Cmd_Rest | ( | const char * | pszParam | ) |
REST Valid responses: 500, 501, 502, 421, 530, 350
void GrayFTP::cClientFTP::Cmd_Retr | ( | const char * | pszParam | ) |
RETR command Client wants the server to send this file. Requesting a directory is the same as List() POSSIBLE REPLIES: 125, 150 (110) 226, 250 425, 426, 451 450, 550 500, 501, 421, 530
void GrayFTP::cClientFTP::Cmd_Rmd | ( | const char * | pszParam | ) |
RMD, XRMD commands
void GrayFTP::cClientFTP::Cmd_Rnfr | ( | const char * | pszParam | ) |
Rename from. must be followed by RNTO
void GrayFTP::cClientFTP::Cmd_Rnto | ( | const char * | pszParam | ) |
RNTO command. Rename to. or move
void GrayFTP::cClientFTP::Cmd_Site | ( | const char * | pszParam | ) |
SITE commands
CHMOD = set permissions CHOWN = set owner ? Help QUOTA = user view his quota information RETRBUFSIZE = let a user tune the desired TCP window size for transfers STORBUFSIZE SYMLINK = equivalent to /bin/ln -s; UMASK = UTIME = similar to touch command. set the modification time and access time
CEMON
void GrayFTP::cClientFTP::Cmd_Site_Help | ( | const char * | pszParam | ) |
void GrayFTP::cClientFTP::Cmd_Size | ( | const char * | pszParam | ) |
Does the file exist ? Get its size.
void GrayFTP::cClientFTP::Cmd_Stat | ( | const char * | pszParam | ) |
NOTE: This may be the status of a transfer as well ?
void GrayFTP::cClientFTP::Cmd_Stor | ( | const char * | pszParam | ) |
void GrayFTP::cClientFTP::Cmd_Stor_Base | ( | const char * | pszParam, |
bool | bAppend | ||
) |
STOR command
void GrayFTP::cClientFTP::Cmd_Struct | ( | const char * | pszParam | ) |
STRU command
void GrayFTP::cClientFTP::Cmd_Syst | ( | const char * | pszParam | ) |
SYST command
void GrayFTP::cClientFTP::Cmd_Type | ( | const char * | pszParam | ) |
TYPE command
void GrayFTP::cClientFTP::Cmd_User | ( | const char * | pszParam | ) |
USER command
void GrayFTP::cClientFTP::Cmd_UTF8 | ( | const char * | pszParam | ) |
void GrayFTP::cClientFTP::Data_ConnectComplete | ( | cClientFTPData * | pClient, |
bool | bPasv | ||
) |
Client is connecting data socket into me in PASV mode.
HRESULT GrayFTP::cClientFTP::Data_ConnectOpen | ( | ) |
Control command that wants a Data connection.
|
inline |
No valid outgoing data address means the server is PASV. the client will connect to us. (Default)
|
overridevirtual |
Reimplemented from GrayLib::cProtocolStream.
const char * GrayFTP::cClientFTP::DoCommandCheck | ( | const char * | pszCmdBuffer | ) |
Perform some command and parameter validation
void GrayFTP::cClientFTP::DoControlCmd | ( | const char * | pszCmdBuffer | ) |
Find the command handler. Save the command name
|
staticprotected |
cFTPFactory * GrayFTP::cClientFTP::get_FTPFactory | ( | ) | const |
|
inlinestatic |
StrLen_t _cdecl GrayFTP::cClientFTP::LogEventF | ( | LOG_ATTR_MASK_t | dwAttrMask, |
const LOGCHAR_t * | pszFormat, | ||
... | |||
) |
HTTPRET_TYPE GrayFTP::cClientFTP::MakeFilePath | ( | const char * | pszName, |
FTP_PRIV_TYPE_ | wPrivReq, | ||
cFileFindEntry * | pfd = nullptr |
||
) |
Get a file or directory name from the user. set in m_tActiveFilePath. May be relative to CWD or to Root. Convert User File name space to Real File Name. Check for security access. parse a directory pathname with embedded '.' and '\' characters. Check for valid chars in the name ?
bool GrayFTP::cClientFTP::OnException | ( | ) |
Control or Data. Did connect() fail?
|
overridevirtual |
cProtocolStream server is receiving data from the client. the client is sending me data. deal with it.
Reimplemented from GrayLib::cProtocolStream.
int GrayFTP::cClientFTP::Reply_BadPath | ( | HTTPRET_TYPE | eReplyCode = HTTPRET_ER_550 | ) |
int GrayFTP::cClientFTP::Reply_DataTransferAbort | ( | HRESULT | hRes | ) |
int GrayFTP::cClientFTP::Reply_DataTransferComplete | ( | void | ) |
int GrayFTP::cClientFTP::Reply_DataTransferError | ( | const char * | pError, |
HRESULT | hRes | ||
) |
int GrayFTP::cClientFTP::Reply_OK | ( | HTTPRET_TYPE | eReplyCode = HTTPRET_OK_DATA | ) |
HTTPRET_OK, HTTPRET_250, HTTPRET_OK_DATA
int GrayFTP::cClientFTP::Reply_ParameterNotImplemented | ( | const char * | pText | ) |
int GrayFTP::cClientFTP::Reply_SysError | ( | HTTPRET_TYPE | eReplyCode, |
const char * | pszText, | ||
HRESULT | hRes | ||
) |
550 = Requested action not taken file unavailable (e.g. file not found, no access)
int GrayFTP::cClientFTP::Reply_SysErrorLast | ( | HTTPRET_TYPE | eReplyCode, |
const char * | pszText = nullptr |
||
) |
StrLen_t _cdecl GrayFTP::cClientFTP::ReplyF | ( | HTTPRET_TYPE | eReplyCode, |
const char * | pReplyString, | ||
... | |||
) |
eReplyCode = result type description. ABC = 3 digit result code. see RFC765 for details. A =
cArrayRef<cClientFTPData> GrayFTP::cClientFTP::m_aConnectData |
open data connections for this control connection.
cNetAddrName GrayFTP::cClientFTP::m_AddrPeer |
DNS lookup of my peer name. get_NetStream()->m_addrPeer.
bool GrayFTP::cClientFTP::m_bAccountLogin |
m_pAccount is logged in (may be anon)
bool GrayFTP::cClientFTP::m_bUTF8 |
cNetAddress GrayFTP::cClientFTP::m_DAddr |
data address (can be changed w/ Port command) for (non pasv) outgoing data connections.
STREAM_POS_t GrayFTP::cClientFTP::m_nDataRestoreOffset |
restore offset, for file transfers. set via Cmd_Rest
cFTPAccountPtr GrayFTP::cClientFTP::m_pAccount |
Account we are trying to log in with. May not yet be logged in.
cNetAddrTrackPtr GrayFTP::cClientFTP::m_pAddrTrack |
Duplicates m_AddrPeer ??
cSSLServerStreamPtr GrayFTP::cClientFTP::m_pAuthSSL |
We used the AUTH command or are implicit SSL/TLS connection.
const CFTPCmd* GrayFTP::cClientFTP::m_pCmd |
Current Command.
cFTPDataParamsPtr GrayFTP::cClientFTP::m_pDataParams |
Set up params for the next data connection.
cNetServerPortPtr GrayFTP::cClientFTP::m_pDPasv |
an expected/waiting/incoming Pasv/EPSV data connection. (can only have one at a time)
cStringA GrayFTP::cClientFTP::m_sActiveUserPath |
file/path (in Unix form)
cStringA GrayFTP::cClientFTP::m_sCWD |
Current working user path directory or file. (in Unix form)
cStringA GrayFTP::cClientFTP::m_sUserName |
Might be the anon users email.
char GrayFTP::cClientFTP::m_szCmdBuffer[_MAX_PATH] |
current command + path.
FILECHAR_t GrayFTP::cClientFTP::m_tActiveFilePath[_MAX_PATH] |
current valid (user checked) full real system path/file.
FTP_TMODE_TYPE GrayFTP::cClientFTP::m_TransferMode |
FTP_TSTRUCT_TYPE GrayFTP::cClientFTP::m_TransferStruct |
FTP_TTYPE_TYPE GrayFTP::cClientFTP::m_TransferType |