Error In FTP Program

hello,
I am trying to get done this program Q_21439008.html but im getting too many errors
can someone please tell me what can I do about it ?
thanks
XtryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AxterCommented:
Please post your code, and the errors you're getting wit it.
XtryAuthor Commented:
please check the question.. thanks
itsmeandnobodyelseCommented:
You need to add the ftpclient.lib to the linker input modules.

Goto Project - Settings - Link - Input  and add ftpclient.lib (the import library of your ftpclient.dll) to the 'Object/Libraries Modules'. Most likely you need to add the path to that lib at 'Additional Library Path'.

Regards, Alex
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

AxterCommented:
>>please check the question.. thanks

If you see this as a new question, then it should contain all the required information to answer the question.

If you see this as part of your original question, then you would have to delete this question, since you can not award over 500 points for a single question.
It's against EE policy to award over 500 points to a single question.

Please clarify if this is a new questioin, and if so, please post assoicated information to answer the question.
AxterCommented:
>>please check the question.. thanks
FYI:
Also beaware that your other question is a PAQ (closed awarded question).  That means (Non-Premium Service) experts would have to use up their points to view your PAQ just so they could attempt to answer your new question.
itsmeandnobodyelseCommented:
>>>> include\ftpclient.h(387) : error C2027: use of undefined type 'CFTPClient'
>>>> include\ftpclient.h(384) : see declaration of 'CFTPClient'

Looks like a forward declaration (to the own class) is missing in ftpclient.h. Sometimes VC has problems with class definitions from foreign compilers.

Try to add

       // forward declaration
       class CFTPClient;

at line 382 of ftpclient.h  (above class definition).

>>>> include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifacti...

That are warnings only (cause of a VC6 bug) that you can get rid by including

 #pragma warning ( disable : 4786 )

as very first line to your cpp files.

>>>> log.exe - 110 error(s), 18 warning(s)

Unfortunately, you posted only 2 errors.

Please add the forward declaration and #pragma statement, compile and post all errors still remaining.

FYI: you could make a link to another thread more convenient by prefixing it with http:

      http:Q_21439008.html

Regards, Alex









XtryAuthor Commented:
Nothing I cant get it done =/
XtryAuthor Commented:
here are the errors I am getting...

Deleting intermediate files and output files for project 'log - Win32 Debug'.
--------------------Configuration: log - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
BlockingSocket.cpp


FtpClient.cpp
include\ftpclient.h(387) : error C2027: use of undefined type 'CFTPClient'
include\ftpclient.h(384) : see declaration of 'CFTPClient'
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::const_iterator' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::iterator' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Node' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::const_iterator' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\utility(25) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *
>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::iterator' : identifier was truncated to '255' characters in the debug information
        log\FtpClient.cpp(237) : see reference to class template instantiation 'std::pair<std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::
CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::iterator,bool>' being compiled
log\FtpClient.cpp(303) : error C2039: 'reset' : is not a member of 'auto_ptr<class nsFTP::CRepresentation>'
log\FtpClient.cpp(580) : error C2039: 'push_back' : is not a member of 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
log\FtpClient.cpp(835) : error C2039: 'reset' : is not a member of 'auto_ptr<class nsFTP::CRepresentation>'
FTPFileState.cpp
include\ftpfilestate.h(82) : error C2065: '_T' : undeclared identifier
include\ftpfilestate.h(82) : error C2676: binary '==' : 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a
type acceptable to the predefined operator
include\ftpfilestate.h(82) : error C2676: binary '==' : 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a
type acceptable to the predefined operator
FTPListParse.cpp
include\ftplistparse.h(49) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(50) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(52) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(53) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(55) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(56) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(58) : error C2061: syntax error : identifier 'LPCSTR'
include\ftplistparse.h(59) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(62) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(63) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(64) : error C2061: syntax error : identifier 'LPCTSTR'
include\ftplistparse.h(73) : error C2143: syntax error : missing ';' before '*'
include\ftplistparse.h(73) : error C2501: 'm_Months' : missing storage-class or type specifiers
log\FTPListParse.cpp(51) : error C2143: syntax error : missing ';' before '*'
log\FTPListParse.cpp(51) : error C2501: 'TCHAR' : missing storage-class or type specifiers
log\FTPListParse.cpp(51) : error C2039: 'm_Months' : is not a member of 'CFTPListParse'
include\ftplistparse.h(41) : see declaration of 'CFTPListParse'
log\FTPListParse.cpp(51) : error C2501: 'm_Months' : missing storage-class or type specifiers
log\FTPListParse.cpp(52) : error C2065: '_T' : undeclared identifier
log\FTPListParse.cpp(52) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(52) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(52) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(52) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(52) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(52) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(53) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(53) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(53) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(53) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(53) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(54) : error C2440: 'initializing' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
log\FTPListParse.cpp(71) : error C2065: 'LPCTSTR' : undeclared identifier
log\FTPListParse.cpp(71) : error C2146: syntax error : missing ')' before identifier 'pszBuffer'
log\FTPListParse.cpp(71) : error C2350: 'CFTPListParse::CheckMonth' is not a static member
log\FTPListParse.cpp(71) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
log\FTPListParse.cpp(71) : error C2059: syntax error : ')'
log\FTPListParse.cpp(72) : error C2143: syntax error : missing ';' before '{'
log\FTPListParse.cpp(72) : error C2447: missing function header (old-style formal list?)
log\FTPListParse.cpp(81) : error C2146: syntax error : missing ')' before identifier 'pszBuffer'
log\FTPListParse.cpp(81) : error C2350: 'CFTPListParse::GetMonth' is not a static member
log\FTPListParse.cpp(81) : error C2059: syntax error : ')'
log\FTPListParse.cpp(82) : error C2143: syntax error : missing ';' before '{'
log\FTPListParse.cpp(82) : error C2447: missing function header (old-style formal list?)
log\FTPListParse.cpp(94) : error C2146: syntax error : missing ')' before identifier 'pszLong'
log\FTPListParse.cpp(94) : error C2350: 'CFTPListParse::GetLong' is not a static member
log\FTPListParse.cpp(94) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
log\FTPListParse.cpp(94) : error C2059: syntax error : ')'
log\FTPListParse.cpp(95) : error C2143: syntax error : missing ';' before '{'
log\FTPListParse.cpp(95) : error C2447: missing function header (old-style formal list?)
log\FTPListParse.cpp(234) : error C2146: syntax error : missing ')' before identifier 'pszLine'
log\FTPListParse.cpp(234) : error C2350: 'CFTPListParse::IsEPLS' is not a static member
log\FTPListParse.cpp(234) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
log\FTPListParse.cpp(234) : error C2059: syntax error : ')'
log\FTPListParse.cpp(235) : error C2143: syntax error : missing ';' before '{'
log\FTPListParse.cpp(235) : error C2447: missing function header (old-style formal list?)
log\FTPListParse.cpp(239) : error C2061: syntax error : identifier 'LPCTSTR'
log\FTPListParse.cpp(241) : error C2065: 'pszLine' : undeclared identifier
log\FTPListParse.cpp(246) : error C2065: 'iLength' : undeclared identifier
log\FTPListParse.cpp(248) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(254) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(256) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(258) : error C2051: case expression not constant
log\FTPListParse.cpp(261) : error C2051: case expression not constant
log\FTPListParse.cpp(264) : error C2051: case expression not constant
log\FTPListParse.cpp(266) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(269) : error C2051: case expression not constant
log\FTPListParse.cpp(271) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(275) : error C2051: case expression not constant
log\FTPListParse.cpp(279) : warning C4060: switch statement contains no 'case' or 'default' labels
log\FTPListParse.cpp(306) : error C2146: syntax error : missing ')' before identifier 'pszLine'
log\FTPListParse.cpp(306) : error C2350: 'CFTPListParse::IsUNIXStyleListing' is not a static member
log\FTPListParse.cpp(306) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
log\FTPListParse.cpp(306) : error C2059: syntax error : ')'
log\FTPListParse.cpp(307) : error C2143: syntax error : missing ';' before '{'
log\FTPListParse.cpp(307) : error C2447: missing function header (old-style formal list?)
log\FTPListParse.cpp(325) : error C2061: syntax error : identifier 'LPCTSTR'
log\FTPListParse.cpp(330) : error C2100: illegal indirection
log\FTPListParse.cpp(332) : error C2051: case expression not constant
log\FTPListParse.cpp(333) : error C2051: case expression not constant
log\FTPListParse.cpp(334) : error C2051: case expression not constant
log\FTPListParse.cpp(336) : warning C4060: switch statement contains no 'case' or 'default' labels
log\FTPListParse.cpp(349) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(349) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(360) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(368) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(376) : error C2660: 'GetMonth' : function does not take 2 parameters
log\FTPListParse.cpp(381) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(386) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(390) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(392) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(393) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(398) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(400) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(401) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(408) : error C2660: 'GetLong' : function does not take 3 parameters
log\FTPListParse.cpp(424) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(436) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(444) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(444) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(446) : error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a t
ype acceptable to the predefined operator
log\FTPListParse.cpp(458) : error C2146: syntax error : missing ')' before identifier 'pszLine'
log\FTPListParse.cpp(458) : error C2350: 'CFTPListParse::IsMultiNetListing' is not a static member
log\FTPListParse.cpp(458) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
log\FTPListParse.cpp(458) : error C2059: syntax error : ')'
log\FTPListParse.cpp(459) : error C2143: syntax error : missing ';' before '{'
log\FTPListParse.cpp(459) : error C2447: missing function header (old-style formal list?)
log\FTPListParse.cpp(463) : error C2061: syntax error : identifier 'LPCTSTR'
log\FTPListParse.cpp(469) : error C2109: subscript requires array or pointer type
log\FTPListParse.cpp(476) : error C2065: '_tcsncmp' : undeclared identifier
log\FTPListParse.cpp(476) : fatal error C1003: error count exceeds 100; stopping compilation


log.cpp
include\ftpclient.h(387) : error C2027: use of undefined type 'CFTPClient'
include\ftpclient.h(384) : see declaration of 'CFTPClient'
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::const_iterator' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::iterator' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Node' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
include\xtree(120) : warning C4786: 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>
,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::const_iterator' : identifier was truncated to '255' characters in the debug information
include\set(33) : see reference to class template instantiation 'std::_Tree<nsFTP::CFTPClient::CNotifaction *,nsFTP::CFTPClient::CNotifaction *,std::set<nsFTP::CFTPClient::CNotifaction *,std::les
s<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >::_Kfn,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient::CNotifaction *> >' being compiled
include\ftpclient.h(489) : see reference to class template instantiation 'std::set<nsFTP::CFTPClient::CNotifaction *,std::less<nsFTP::CFTPClient::CNotifaction *>,std::allocator<nsFTP::CFTPClient:
:CNotifaction *> >' being compiled
Generating Code...
Error executing cl.exe.

log.exe - 110 error(s), 18 warning(s)
XtryAuthor Commented:
ok I added the
#pragma warning ( disable : 4786 )

and now im getting log.exe - 110 error(s), 7 warning(s)

but the forward declaration I dont know everytime I put that
I get more errors
itsmeandnobodyelseCommented:
First you need to include stdafx.h as first header in all of your cpp files.

stdafx.h includes all WINAPI and MFC header files. The missing of these includes is responsible for most if not all of the errors above.

If there are erros left, please post them again.

Regards, Alex


XtryAuthor Commented:
thanks itsmeandnobodyelse, but all .cpp files have stdafx.h as first header
XtryAuthor Commented:
so I still have log.exe - 110 error(s), 7 warning(s)
itsmeandnobodyelseCommented:
Could you post stdafx.h ?

Also check 'Precompiled Header' Option in Project - Settings - C++ - Precompiled Header. There is a project settings *and* a settings for each file. If Precompiled Header Option is off, remove stdafx.cpp from your project tree, cause it is needed only for precompiled header file .pch. If Precompiled Header is on, all cpp files need to have 'Use Precompiled Header thru  stdafx.h" with one exception. The file stdafx.cpp needs 'Create Precompiled Header thru stdafx.cpp'.

Is it log.cpp or log.c now?

Did you change the file extension while the project was open?

Could you post the current include list of log.cpp ?

Regards, Alex
XtryAuthor Commented:
StdAfx.h

// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__D98AD3ED_D813_48BC_9E59_BD2D9A35DCA6__INCLUDED_)
#define AFX_STDAFX_H__D98AD3ED_D813_48BC_9E59_BD2D9A35DCA6__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define WIN32_LEAN_AND_MEAN            // Exclude rarely-used stuff from Windows headers

#include <stdio.h>

// TODO: reference additional headers your program requires here

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__D98AD3ED_D813_48BC_9E59_BD2D9A35DCA6__INCLUDED_)
XtryAuthor Commented:
include of log.cpp

#pragma warning ( disable : 4786 )
#include "StdAfx.h"
#include "FTPClient.h"
#include "stdlib.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "winsock.h"
#include "windows.h"
#include "winuser.h"
#include "stdio.h"
#include "string.h"
#pragma comment(lib, "ws2_32.lib")
XtryAuthor Commented:
I removed the file stdafx.cpp from my project tree and this is what I get now!

Deleting intermediate files and output files for project 'log - Win32 Debug'.
Build : warning : failed to (or don't know how to) build 'log\Debug\log.pch'
--------------------Configuration: log - Win32 Debug--------------------
Build : warning : failed to (or don't know how to) build 'log\Debug\log.pch'
Compiling...
BlockingSocket.cpp
log\blockingsocket.cpp(9) : fatal error C1083: Cannot open precompiled header file: 'Debug/log.pch': No such file or directory
FtpClient.cpp
log\ftpclient.cpp(32) : fatal error C1083: Cannot open precompiled header file: 'Debug/log.pch': No such file or directory
FTPFileState.cpp
log\ftpfilestate.cpp(16) : fatal error C1083: Cannot open precompiled header file: 'Debug/log.pch': No such file or directory
FTPListParse.cpp
log\ftplistparse.cpp(29) : fatal error C1083: Cannot open precompiled header file: 'Debug/log.pch': No such file or directory
log.cpp
log\log.cpp(2) : fatal error C1083: Cannot open precompiled header file: 'Debug/log.pch': No such file or directory
Generating Code...
Error executing cl.exe.

log.exe - 5 error(s), 1 warning(s)
XtryAuthor Commented:
ok I did everything you told me and here its my final resutls

Deleting intermediate files and output files for project 'log - Win32 Debug'.
--------------------Configuration: log - Win32 Debug--------------------
Compiling...
log.cpp
ftpclient.h(387) : error C2027: use of undefined type 'CFTPClient'
ftpclient.h(384) : see declaration of 'CFTPClient'
Error executing cl.exe.

log.exe - 1 error(s), 0 warning(s)
itsmeandnobodyelseCommented:
blockingsocket.cpp still needs precompiled ehader. You need to switch off Precompiled Header Option for that single file via Project Settings-C++-Precompiled Headers. Note, yo may select that file in project tree and right-click to get the settings for that file only.

Regards
itsmeandnobodyelseCommented:
Sorry, didn't read your last post ...

I now need ftpclient.h. Or you try that forward declaration  thing we had above. You could insert the forward declaration in log.cpp above include of ftpclient.h

// log.cpp
 
  #included "stdafx.h"
  class CFTPClient;   // forward declaration
  #include "FTPClient.h"
   ....
Regards, Alex
XtryAuthor Commented:
ok done, but still getting same error
XtryAuthor Commented:
one sec let me test
XtryAuthor Commented:
this is what I have at the beggining of file log.cpp  Is that ok ?

#pragma warning ( disable : 4786 )
#include "StdAfx.h"
class CFTPClient;   // forward declaration
#include "FTPClient.h"
#include "stdlib.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "winsock.h"
#include "windows.h"
#include "winuser.h"
#include "stdio.h"
#include "string.h"
XtryAuthor Commented:
same errors =/
itsmeandnobodyelseCommented:
I now need ftpclient.h.

In line 387 the error message says CFTPClient is undefined. However, the class definition of CFTPClient seems to begin at line 384. So I need to see why there is an undefined type to detect...

Regards
XtryAuthor Commented:
ok here it is the ftpclient.h.

#ifndef INC_FTPCLIENT_H
#define INC_FTPCLIENT_H

// STL-includes
#include <memory>
#include <set>
#include <queue>
#include <vector>
#include <sstream>

// other includes
#include "BlockingSocket.h"
#include "FTPFileState.h"

// definements for unicode support
#ifdef _UNICODE
   typedef std::wstring tstring;
   typedef std::wostream tostream;
   typedef std::wofstream tofstream;
   typedef std::wostringstream tostringstream;
   typedef std::wistringstream tistringstream;
   typedef std::wstreambuf tstreambuf;

   #define tcin  wcin
   #define tcout wcout
   #define tcerr wcerr
   #define tclog wclog
#else
   typedef std::string tstring;
   typedef std::ostream tostream;
   typedef std::ofstream tofstream;
   typedef std::ostringstream tostringstream;
   typedef std::istringstream tistringstream;
   typedef std::streambuf tstreambuf;

   #define tcin  cin
   #define tcout cout
   #define tcerr cerr
   #define tclog clog
#endif

////////////////////////////////////////////////////////////////////////////////
/// Namespace for all FTP-related classes.
////////////////////////////////////////////////////////////////////////////////
namespace nsFTP
{
   using namespace nsSocket;
   // constants
   const TCHAR ANONYMOUS_USER[] = _T("anonymous");
   enum T_enConstants {
      DEFAULT_FTP_PORT = 21, ///< The default port that an FTP service listens to on a remote host
      FTP_ERROR  = -1,
      FTP_OK     =  0,
      FTP_NOTOK  =  1, };

   /// Data Structure
   class CStructure
   {
   public:
      enum T_enFileStructure { scFile, scRecord, scPage };

      CStructure(const CStructure& structure) :
         m_enStructure(structure.AsEnum()) {};

      bool operator==(const T_enFileStructure& rhs) const { return m_enStructure==rhs; }
      bool operator!=(const T_enFileStructure& rhs) const { return m_enStructure!=rhs; }
      bool operator==(const CStructure& rhs) const { return m_enStructure==rhs.AsEnum(); }
      bool operator!=(const CStructure& rhs) const { return m_enStructure!=rhs.AsEnum(); }

      CStructure& operator=(const CStructure& rhs) { m_enStructure = rhs.AsEnum(); return *this; }

      T_enFileStructure AsEnum() const { return m_enStructure; };

      static const CStructure File()   { return scFile;   };
      static const CStructure Record() { return scRecord; };
      static const CStructure Page()   { return scPage;   };

   private:
      CStructure(T_enFileStructure enStructure) : m_enStructure(enStructure) {};
      T_enFileStructure m_enStructure;
   };

   /// Transmission Modes
   class CTransferMode
   {
   public:
      enum T_enTransferMode { tmStream, tmBlock, tmCompressed };

      CTransferMode(const CTransferMode& transferMode) :
         m_enTransferMode(transferMode.AsEnum()) {};

      bool operator==(const T_enTransferMode& rhs) const { return m_enTransferMode==rhs; }
      bool operator!=(const T_enTransferMode& rhs) const { return m_enTransferMode!=rhs; }
      bool operator==(const CTransferMode& rhs) const { return m_enTransferMode==rhs.AsEnum(); }
      bool operator!=(const CTransferMode& rhs) const { return m_enTransferMode!=rhs.AsEnum(); }

      CTransferMode& operator=(const CTransferMode& rhs) { m_enTransferMode = rhs.AsEnum(); return *this; }

      T_enTransferMode AsEnum() const { return m_enTransferMode; };

      static const CTransferMode Stream()     { return tmStream;     };
      static const CTransferMode Block()      { return tmBlock;      };
      static const CTransferMode Compressed() { return tmCompressed; };

   private:
      CTransferMode(T_enTransferMode enTransferMode) : m_enTransferMode(enTransferMode) {};
      T_enTransferMode m_enTransferMode;
   };

   class CFirewallType;
   typedef std::vector<CFirewallType> TFirewallTypeVector;

   /// Firewall Type
   class CFirewallType
   {
   public:
      // don't change order of enumeration
      enum T_enFirewallType {
         ftNone, ftSiteHostName, ftUserAfterLogon, ftProxyOpen, ftTransparent,
         ftUserWithNoLogon, ftUserFireIDatRemotehost, ftUserRemoteIDatRemoteHostFireID,
         ftUserRemoteIDatFireIDatRemoteHost };

      CFirewallType() : m_enFirewallType(ftNone) {};
      CFirewallType(const CFirewallType& firewallType) :
         m_enFirewallType(firewallType.AsEnum()) {};

      bool operator==(const T_enFirewallType& rhs) const { return m_enFirewallType==rhs; }
      bool operator!=(const T_enFirewallType& rhs) const { return m_enFirewallType!=rhs; }
      bool operator==(const CFirewallType& rhs) const { return m_enFirewallType==rhs.AsEnum(); }
      bool operator!=(const CFirewallType& rhs) const { return m_enFirewallType!=rhs.AsEnum(); }

      CFirewallType& operator=(const CFirewallType& rhs) { m_enFirewallType = rhs.AsEnum(); return *this; }

      T_enFirewallType AsEnum() const { return m_enFirewallType; };

      tstring AsDisplayString() const;
      tstring AsStorageString() const;
      static void GetAllTypes(TFirewallTypeVector& vTypes);

      static const CFirewallType None()                             { return ftNone;                             };
      static const CFirewallType SiteHostName()                     { return ftSiteHostName;                     };
      static const CFirewallType UserAfterLogon()                   { return ftUserAfterLogon;                   };
      static const CFirewallType ProxyOpen()                        { return ftProxyOpen;                        };
      static const CFirewallType Transparent()                      { return ftTransparent;                      };
      static const CFirewallType UserWithNoLogon()                  { return ftUserWithNoLogon;                  };
      static const CFirewallType UserFireIDatRemotehost()           { return ftUserFireIDatRemotehost;           };
      static const CFirewallType UserRemoteIDatRemoteHostFireID()   { return ftUserRemoteIDatRemoteHostFireID;   };
      static const CFirewallType UserRemoteIDatFireIDatRemoteHost() { return ftUserRemoteIDatFireIDatRemoteHost; };

   private:
      CFirewallType(T_enFirewallType enFirewallType) : m_enFirewallType(enFirewallType) {};
      T_enFirewallType m_enFirewallType;
   };

   /// @brief Representation Type - 1st param (see CRepresentation)
   class CType
   {
   public:
      enum T_enType { tyASCII, tyEBCDIC, tyImage, tyLocalByte };

      CType(const CType& type) :
         m_enType(type.AsEnum()) {};

      bool operator==(const T_enType& rhs) const { return m_enType==rhs; }
      bool operator!=(const T_enType& rhs) const { return m_enType!=rhs; }
      bool operator==(const CType& rhs) const { return m_enType==rhs.AsEnum(); }
      bool operator!=(const CType& rhs) const { return m_enType!=rhs.AsEnum(); }

      CType& operator=(const CType& rhs) { m_enType = rhs.AsEnum(); return *this; }

      T_enType AsEnum() const { return m_enType; };

      static const CType ASCII()     { return tyASCII;     };
      static const CType EBCDIC()    { return tyEBCDIC;    };
      static const CType Image()     { return tyImage;     };
      static const CType LocalByte() { return tyLocalByte; };

   private:
      CType(T_enType enType) : m_enType(enType) {};
      T_enType m_enType;
   };

   /// @brief Representation Type - 2nd param (see CRepresentation)
   class CTypeFormat
   {
   public:
      enum T_enTypeFormat { tfNonPrint, tfTelnetFormat, tfCarriageControl };

      CTypeFormat(const CTypeFormat& typeFormat) :
         m_enTypeFormat(typeFormat.AsEnum()) {};

      bool operator==(const T_enTypeFormat& rhs) const { return m_enTypeFormat==rhs; }
      bool operator!=(const T_enTypeFormat& rhs) const { return m_enTypeFormat!=rhs; }
      bool operator==(const CTypeFormat& rhs) const { return m_enTypeFormat==rhs.AsEnum(); }
      bool operator!=(const CTypeFormat& rhs) const { return m_enTypeFormat!=rhs.AsEnum(); }

      CTypeFormat& operator=(const CTypeFormat& rhs) { m_enTypeFormat = rhs.AsEnum(); return *this; }

      T_enTypeFormat AsEnum() const { return m_enTypeFormat; };

      static const CTypeFormat NonPrint()        { return tfNonPrint;        };
      static const CTypeFormat TelnetFormat()    { return tfTelnetFormat;    };
      static const CTypeFormat CarriageControl() { return tfCarriageControl; };

   private:
      CTypeFormat(T_enTypeFormat enTypeFormat) : m_enTypeFormat(enTypeFormat) {};
      T_enTypeFormat m_enTypeFormat;
   };

   /// Representation Type (see also CType and CTypeFormat)
   class CRepresentation
   {
   public:
      /// there is only NonPrint as FormatType supported yet
      CRepresentation(CType Type) : m_Type(Type), m_Format(CTypeFormat::NonPrint()) {};
     
      bool operator!=(const CRepresentation& rep1) const { return rep1.m_Type != m_Type || rep1.m_Format != m_Format; }
      bool operator==(const CRepresentation& rep1) const { return rep1.m_Type == m_Type && rep1.m_Format == m_Format; }
      CRepresentation& operator=(const CRepresentation& rhs)
      {
         m_Type = rhs.m_Type;
         m_Format = rhs.m_Format;
         return *this;
      };

      const CType&       Type()   const { return m_Type; };
      const CTypeFormat& Format() const { return m_Format; };

   private:
      CType       m_Type;
      CTypeFormat m_Format;
   };

   /// @brief Represents ftp-commands that use the data port (usually port 20).
   class CDatachannelCmd
   {
   public:
      enum T_enDatachannelCmd { cmdLIST, cmdNLST, cmdRETR, cmdSTOR, cmdSTOU, cmdAPPE };

      CDatachannelCmd(const CDatachannelCmd& datachannelCmd) :
         m_enDatachannelCmd(datachannelCmd.AsEnum()) {};

      bool operator==(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd==rhs; }
      bool operator!=(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd!=rhs; }

      bool operator==(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd==rhs.AsEnum(); }
      bool operator!=(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd!=rhs.AsEnum(); }

      CDatachannelCmd& operator=(const CDatachannelCmd& rhs)
      {
         m_enDatachannelCmd = rhs.AsEnum();
         return *this;
      }

      T_enDatachannelCmd AsEnum() const { return m_enDatachannelCmd; };

      static const CDatachannelCmd LIST() { return cmdLIST; };
      static const CDatachannelCmd NLST() { return cmdNLST; };
      static const CDatachannelCmd RETR() { return cmdRETR; };
      static const CDatachannelCmd STOR() { return cmdSTOR; };
      static const CDatachannelCmd STOU() { return cmdSTOU; };
      static const CDatachannelCmd APPE() { return cmdAPPE; };

   private:
      CDatachannelCmd(T_enDatachannelCmd enDatachannelCmd) : m_enDatachannelCmd(enDatachannelCmd) {};
      T_enDatachannelCmd m_enDatachannelCmd;
   };

   /// @brief Structure for logon information.
   ///
   /// Holds all necessary parameters for logging on a ftp-server.
   /// Includes also the parameters which are needed for firewall logon.
   class CLogonInfo
   {
   public:
      CLogonInfo();
      CLogonInfo(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                 const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));
      CLogonInfo(const tstring& strHostname, int iHostport, const tstring& strUsername, const tstring& strPassword,
                 const tstring& strAccount, const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                 int iFwPort, const CFirewallType& crFwType);

      void SetHost(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                   const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));

      void SetFirewall(const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                       int iFwPort, const CFirewallType& crFwType);

      void DisableFirewall() { m_FwType = CFirewallType::None(); };

      const tstring&       Hostname()   const  { return m_strHostname;    };
      int                  Hostport()   const  { return m_iHostport;      };
      const tstring&       Username()   const  { return m_strUsername;    };
      const tstring&       Password()   const  { return m_strPassword;    };
      const tstring&       Account()    const  { return m_strAccount;     };
      const tstring&       FwHost()     const  { return m_strFwHostname;  };
      const tstring&       FwUsername() const  { return m_strFwUsername;  };
      const tstring&       FwPassword() const  { return m_strFwPassword;  };
      int                  FwPort()     const  { return m_iFwPort;        };
      const CFirewallType& FwType()     const  { return m_FwType;         };
   
   private:
      tstring        m_strHostname;   ///< name or ip-address of the ftp-server
      int            m_iHostport;     ///< port of the ftp-server
      tstring        m_strUsername;   ///< username for ftp-server
      tstring        m_strPassword;   ///< password for ftp-server
      tstring        m_strAccount;    ///< account mostly needed on ftp-servers running on unix/linux
      tstring        m_strFwHostname; ///< name or ip-address of the firewall
      tstring        m_strFwUsername; ///< username for firewall
      tstring        m_strFwPassword; ///< password for firewall
      int            m_iFwPort;       ///< port of the firewall
      CFirewallType  m_FwType;        ///< type of firewall
   };

   /// @brief calculates elapsed CPU time
   ///
   /// Is useful for calculating transferrates.
   class CTimer
   {
   public:
      CTimer() : m_dfStart(clock()) {};

      /// Restarts the timer
      void Restart() { m_dfStart = clock(); }
   
      /// Get the elapsed time in seconds
      double GetElapsedTime() const
      {
         return (static_cast<double>(clock()) - m_dfStart)/CLOCKS_PER_SEC;
      }

   private:
      double m_dfStart; ///< elapsed CPU time for process (start of measurement)
   };

   typedef std::vector<tstring>           TStringVector;

   /// @brief FTP client class
   ///
   /// Use this class for all the ftp-client stuff such as
   /// - logon server
   /// - send and receive data
   /// - get directory listing
   /// - ...
   ///
   /// There are two functions for upload (UploadFile_C/UploadFile_CPP)and two
   /// for download (DownloadFile_C/DownloadFile_CPP). First i have implemented
   /// the file serialization via STL-streams. After a few tests i recognized
   /// that the performance is not very well. So i decided to implement the file
   /// access with C-routines. For experimental purpose i left the slower version
   /// (STL-streams).
   class CFTPClient
   {
   public:
      class CNotifaction;
      typedef std::set<CFTPClient::CNotifaction*> TObserverSet;

      CFTPClient(unsigned int uiTimeout=10, unsigned int uiBufferSize=2048, bool fUseFastFileAccess=true);
      ~CFTPClient();

      void AttachObserver(CNotifaction* pObserver);
      void DetachObserver(CNotifaction* pObserver);

      bool IsConnected() const;
      bool IsTransferringData() const;
      void SetResumeMode(bool fEnable=true);

      bool Login(const CLogonInfo& loginInfo);
      int  Logout();
      const CLogonInfo& LastLogonInfo() const { return m_LastLogonInfo; };

      bool List(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;

      bool List(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;

      int  Delete(const tstring& strFile) const;
      int  RenameFile(const tstring& strOldName, const tstring& strNewName) const;
      bool DownloadFile(const tstring& strRemoteFile, const tstring& strLocalFile,
                        const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false,
                      const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      int  RemoveDirectory(const tstring& strDirectory) const;
      int  MakeDirectory(const tstring& strDirectory) const;

      int PrintWorkingDirectory() const;
      int ChangeToParentDirectory() const;
      int ChangeWorkingDirectory(const tstring& strDirectory) const;

      int Passive(tstring& strHostIP, UINT& uiPort) const;
      int DataPort(const tstring& strHostIP, const UINT uiPort) const;
      int Abort() const;
      int System() const;
      int Noop() const;
      int RepresentationType(const CRepresentation& repType, DWORD dwSize=0) const;
      int FileStructure(const CStructure& crStructure) const;
      int TransferMode(const CTransferMode& crTransferMode) const;
      int Allocate(int iReserveBytes, const int* piMaxPageOrRecordSize=NULL) const;
      int StructureMount(const tstring& strPath) const;
      int SiteParameters(const tstring& strCmd) const;
      int Status(const tstring& strPath) const;
      int Help(const tstring& strTopic) const;

      int Reinitialize() const;
      int Restart(DWORD dwPosition) const;

      int FileSize(const tstring& strPath, long& lSize) const;
      int FileModificationTime(const tstring& strPath, tm& tmModificationTime) const;
      int FileModificationTime(const tstring& strPath, tstring& strModificationTime) const;

   protected:
      bool ExecuteDatachannelCommand(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, const CRepresentation& representation,
                                     bool fPasv, std::iostream& inputOutputStream, DWORD dwByteOffset=0, FILE* pFile=NULL) const;

      TObserverSet& GetObservers();

   private:
      bool DownloadFile_C(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
      bool DownloadFile_CPP(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
     
      bool UploadFile_C(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile_CPP(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;

      bool TransferData(const CDatachannelCmd& crDatachannelCmd, std::iostream& inputOutputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool OpenActiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool OpenPassiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool SendData(std::istream& inputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool ReceiveData(std::ostream& outputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;

      tstring GetCmdString(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath) const;
      int  SimpleErrorCheck(int iFirstDigitOfReplyCode) const;

      bool SendCommand(const tstring& strOutput) const;
      bool GetResponse(int& iFirstDigitOfReplyCode) const;
      bool GetResponse(tstring& strResponse, int& iFirstDigitOfReplyCode) const;
      bool GetSingleResponseLine(tstring& strResponse, int& iFirstDigitOfReplyCode) const;

      bool OpenControlChannel(const tstring& strServerHost, int iServerPort=DEFAULT_FTP_PORT);
      void CloseControlChannel();

      void ReportError(const tstring& strErrorMsg, const tstring& strFile, DWORD dwLineNr) const;

// data members
   private:
      const unsigned int                     mc_uiTimeout;               ///< timeout for socket-functions
      const tstring                          mc_strEolCharacterSequence; ///< end-of-line sequence of current operating system
      const bool                             mc_fUseFastFileAccess;      ///< if true, C-routines are used for file access; if false, iostream is used

      mutable std::vector<TCHAR>             m_vBuffer;                  ///< buffer for sending and receiving
      mutable std::queue<std::string>        m_qResponseBuffer;          ///< buffer for server-responses
      mutable std::auto_ptr<CRepresentation> m_apCurrentRepresentation;  ///< representation currently set

      CBlockingSocket                        m_sckControlConnection;     ///< socket for connection to ftp-server
      mutable bool                           m_fTransferInProgress;      ///< if true, a file transfer is in progress
      mutable bool                           m_fAbortTransfer;           ///< indicates that a running filetransfer should be canceled
      bool                                   m_fResumeIfPossible;        ///< try to resume download/upload if possible
      TObserverSet                           m_setObserver;              ///< list of observers, which are notified about particular actions
      CLogonInfo                             m_LastLogonInfo;            ///< logon-info, which was used at the last call of login
   };

   /// @brief interface for notification
   ///
   /// Derive your class from this base-class and register this class on CFTPClient.
   /// For example you can use this for logging the sended and received commands.
   class CFTPClient::CNotifaction
   {
   public:
      virtual void OnInternalError(const tstring& /*strErrorMsg*/, const tstring& /*strFileName*/, DWORD /*dwLineNr*/) {};
      virtual void OnPostBytesReceived(long /*lReceivedBytes*/) {};
      virtual void OnPostBytesSend(long /*lSentBytes*/) {};
      virtual void OnPreReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnPreSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnPostReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnPostSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnSendCommand(const tstring& /*strCommand*/) {};
      virtual void OnResponse(const tstring& /*strResponse*/) {};
   };
}

#endif
XtryAuthor Commented:
I had to erase some of the comments since the file was too big
itsmeandnobodyelseCommented:
I got it.

in class CFTPClient there is the following::

   class CFTPClient
   {
   public:
      class CNotifaction;
      typedef std::set<CFTPClient::CNotifaction*> TObserverSet;
      ....

- there is a forward declaration of class CNotification
- then there is a typedef that tries to use CFTPClient::CNotifaction in a template type.

The problem is that VC6 compiler doesn't seem to accept a class scope of a class that isn't defined yet.

Unfortunately, I couldn't compile cause there are some more header files missing. So you need to try yourself.

Save ftpclient.h so that you can go back if somewaht doesn't work.

Goto the error line and remove  CFTPClient::

         typedef std::set<CNotifaction*> TObserverSet;

Try to compile.

If that doesn't work, comment the typedef line and substitute all occurences of 'TObserverSet' by

   std::set<CNotifaction*>

Move the original typedef line at the end of the file above the #endif .

Good luck.

Alex

Need to go offline for an hour...


XtryAuthor Commented:
well I did all the changes you told me and I got 102 Errors. so I replaced my .h file again to have just 1 error like before

Deleting intermediate files and output files for project 'log - Win32 Debug'.
--------------------Configuration: log - Win32 Debug--------------------
Compiling...
log.cpp
ftpclient.h(387) : error C2027: use of undefined type 'CFTPClient'
ftpclient.h(384) : see declaration of 'CFTPClient'
Error executing cl.exe.

log.exe - 1 error(s), 0 warning(s)
itsmeandnobodyelseCommented:
>>>> ftpclient.h(387) : error C2027: use of undefined type 'CFTPClient'

The statement in line 387 doesn't compile with VC6.

Take the file below as ftpclient.h (save the old file using a different name) and make a 'Rebuild All'.

Note, if you get 102 errors, it might be caused by only a small error, e. g. a missing semicolon or bracket. Please post the first error messages then.

Regards, Alex

#ifndef INC_FTPCLIENT_H
#define INC_FTPCLIENT_H

// STL-includes
#include <memory>
#include <set>
#include <queue>
#include <vector>
#include <sstream>

// other includes
#include "BlockingSocket.h"
#include "FTPFileState.h"

// definements for unicode support
#ifdef _UNICODE
   typedef std::wstring tstring;
   typedef std::wostream tostream;
   typedef std::wofstream tofstream;
   typedef std::wostringstream tostringstream;
   typedef std::wistringstream tistringstream;
   typedef std::wstreambuf tstreambuf;

   #define tcin  wcin
   #define tcout wcout
   #define tcerr wcerr
   #define tclog wclog
#else
   typedef std::string tstring;
   typedef std::ostream tostream;
   typedef std::ofstream tofstream;
   typedef std::ostringstream tostringstream;
   typedef std::istringstream tistringstream;
   typedef std::streambuf tstreambuf;

   #define tcin  cin
   #define tcout cout
   #define tcerr cerr
   #define tclog clog
#endif

////////////////////////////////////////////////////////////////////////////////
/// Namespace for all FTP-related classes.
////////////////////////////////////////////////////////////////////////////////
namespace nsFTP
{
   using namespace nsSocket;
   // constants
   const TCHAR ANONYMOUS_USER[] = _T("anonymous");
   enum T_enConstants {
      DEFAULT_FTP_PORT = 21, ///< The default port that an FTP service listens to on a remote host
      FTP_ERROR  = -1,
      FTP_OK     =  0,
      FTP_NOTOK  =  1, };

   /// Data Structure
   class CStructure
   {
   public:
      enum T_enFileStructure { scFile, scRecord, scPage };

      CStructure(const CStructure& structure) :
         m_enStructure(structure.AsEnum()) {};

      bool operator==(const T_enFileStructure& rhs) const { return m_enStructure==rhs; }
      bool operator!=(const T_enFileStructure& rhs) const { return m_enStructure!=rhs; }
      bool operator==(const CStructure& rhs) const { return m_enStructure==rhs.AsEnum(); }
      bool operator!=(const CStructure& rhs) const { return m_enStructure!=rhs.AsEnum(); }

      CStructure& operator=(const CStructure& rhs) { m_enStructure = rhs.AsEnum(); return *this; }

      T_enFileStructure AsEnum() const { return m_enStructure; };

      static const CStructure File()   { return scFile;   };
      static const CStructure Record() { return scRecord; };
      static const CStructure Page()   { return scPage;   };

   private:
      CStructure(T_enFileStructure enStructure) : m_enStructure(enStructure) {};
      T_enFileStructure m_enStructure;
   };

   /// Transmission Modes
   class CTransferMode
   {
   public:
      enum T_enTransferMode { tmStream, tmBlock, tmCompressed };

      CTransferMode(const CTransferMode& transferMode) :
         m_enTransferMode(transferMode.AsEnum()) {};

      bool operator==(const T_enTransferMode& rhs) const { return m_enTransferMode==rhs; }
      bool operator!=(const T_enTransferMode& rhs) const { return m_enTransferMode!=rhs; }
      bool operator==(const CTransferMode& rhs) const { return m_enTransferMode==rhs.AsEnum(); }
      bool operator!=(const CTransferMode& rhs) const { return m_enTransferMode!=rhs.AsEnum(); }

      CTransferMode& operator=(const CTransferMode& rhs) { m_enTransferMode = rhs.AsEnum(); return *this; }

      T_enTransferMode AsEnum() const { return m_enTransferMode; };

      static const CTransferMode Stream()     { return tmStream;     };
      static const CTransferMode Block()      { return tmBlock;      };
      static const CTransferMode Compressed() { return tmCompressed; };

   private:
      CTransferMode(T_enTransferMode enTransferMode) : m_enTransferMode(enTransferMode) {};
      T_enTransferMode m_enTransferMode;
   };

   class CFirewallType;
   typedef std::vector<CFirewallType> TFirewallTypeVector;

   /// Firewall Type
   class CFirewallType
   {
   public:
      // don't change order of enumeration
      enum T_enFirewallType {
         ftNone, ftSiteHostName, ftUserAfterLogon, ftProxyOpen, ftTransparent,
         ftUserWithNoLogon, ftUserFireIDatRemotehost, ftUserRemoteIDatRemoteHostFireID,
         ftUserRemoteIDatFireIDatRemoteHost };

      CFirewallType() : m_enFirewallType(ftNone) {};
      CFirewallType(const CFirewallType& firewallType) :
         m_enFirewallType(firewallType.AsEnum()) {};

      bool operator==(const T_enFirewallType& rhs) const { return m_enFirewallType==rhs; }
      bool operator!=(const T_enFirewallType& rhs) const { return m_enFirewallType!=rhs; }
      bool operator==(const CFirewallType& rhs) const { return m_enFirewallType==rhs.AsEnum(); }
      bool operator!=(const CFirewallType& rhs) const { return m_enFirewallType!=rhs.AsEnum(); }

      CFirewallType& operator=(const CFirewallType& rhs) { m_enFirewallType = rhs.AsEnum(); return *this; }

      T_enFirewallType AsEnum() const { return m_enFirewallType; };

      tstring AsDisplayString() const;
      tstring AsStorageString() const;
      static void GetAllTypes(TFirewallTypeVector& vTypes);

      static const CFirewallType None()                             { return ftNone;                             };
      static const CFirewallType SiteHostName()                     { return ftSiteHostName;                     };
      static const CFirewallType UserAfterLogon()                   { return ftUserAfterLogon;                   };
      static const CFirewallType ProxyOpen()                        { return ftProxyOpen;                        };
      static const CFirewallType Transparent()                      { return ftTransparent;                      };
      static const CFirewallType UserWithNoLogon()                  { return ftUserWithNoLogon;                  };
      static const CFirewallType UserFireIDatRemotehost()           { return ftUserFireIDatRemotehost;           };
      static const CFirewallType UserRemoteIDatRemoteHostFireID()   { return ftUserRemoteIDatRemoteHostFireID;   };
      static const CFirewallType UserRemoteIDatFireIDatRemoteHost() { return ftUserRemoteIDatFireIDatRemoteHost; };

   private:
      CFirewallType(T_enFirewallType enFirewallType) : m_enFirewallType(enFirewallType) {};
      T_enFirewallType m_enFirewallType;
   };

   /// @brief Representation Type - 1st param (see CRepresentation)
   class CType
   {
   public:
      enum T_enType { tyASCII, tyEBCDIC, tyImage, tyLocalByte };

      CType(const CType& type) :
         m_enType(type.AsEnum()) {};

      bool operator==(const T_enType& rhs) const { return m_enType==rhs; }
      bool operator!=(const T_enType& rhs) const { return m_enType!=rhs; }
      bool operator==(const CType& rhs) const { return m_enType==rhs.AsEnum(); }
      bool operator!=(const CType& rhs) const { return m_enType!=rhs.AsEnum(); }

      CType& operator=(const CType& rhs) { m_enType = rhs.AsEnum(); return *this; }

      T_enType AsEnum() const { return m_enType; };

      static const CType ASCII()     { return tyASCII;     };
      static const CType EBCDIC()    { return tyEBCDIC;    };
      static const CType Image()     { return tyImage;     };
      static const CType LocalByte() { return tyLocalByte; };

   private:
      CType(T_enType enType) : m_enType(enType) {};
      T_enType m_enType;
   };

   /// @brief Representation Type - 2nd param (see CRepresentation)
   class CTypeFormat
   {
   public:
      enum T_enTypeFormat { tfNonPrint, tfTelnetFormat, tfCarriageControl };

      CTypeFormat(const CTypeFormat& typeFormat) :
         m_enTypeFormat(typeFormat.AsEnum()) {};

      bool operator==(const T_enTypeFormat& rhs) const { return m_enTypeFormat==rhs; }
      bool operator!=(const T_enTypeFormat& rhs) const { return m_enTypeFormat!=rhs; }
      bool operator==(const CTypeFormat& rhs) const { return m_enTypeFormat==rhs.AsEnum(); }
      bool operator!=(const CTypeFormat& rhs) const { return m_enTypeFormat!=rhs.AsEnum(); }

      CTypeFormat& operator=(const CTypeFormat& rhs) { m_enTypeFormat = rhs.AsEnum(); return *this; }

      T_enTypeFormat AsEnum() const { return m_enTypeFormat; };

      static const CTypeFormat NonPrint()        { return tfNonPrint;        };
      static const CTypeFormat TelnetFormat()    { return tfTelnetFormat;    };
      static const CTypeFormat CarriageControl() { return tfCarriageControl; };

   private:
      CTypeFormat(T_enTypeFormat enTypeFormat) : m_enTypeFormat(enTypeFormat) {};
      T_enTypeFormat m_enTypeFormat;
   };

   /// Representation Type (see also CType and CTypeFormat)
   class CRepresentation
   {
   public:
      /// there is only NonPrint as FormatType supported yet
      CRepresentation(CType Type) : m_Type(Type), m_Format(CTypeFormat::NonPrint()) {};
     
      bool operator!=(const CRepresentation& rep1) const { return rep1.m_Type != m_Type || rep1.m_Format != m_Format; }
      bool operator==(const CRepresentation& rep1) const { return rep1.m_Type == m_Type && rep1.m_Format == m_Format; }
      CRepresentation& operator=(const CRepresentation& rhs)
      {
         m_Type = rhs.m_Type;
         m_Format = rhs.m_Format;
         return *this;
      };

      const CType&       Type()   const { return m_Type; };
      const CTypeFormat& Format() const { return m_Format; };

   private:
      CType       m_Type;
      CTypeFormat m_Format;
   };

   /// @brief Represents ftp-commands that use the data port (usually port 20).
   class CDatachannelCmd
   {
   public:
      enum T_enDatachannelCmd { cmdLIST, cmdNLST, cmdRETR, cmdSTOR, cmdSTOU, cmdAPPE };

      CDatachannelCmd(const CDatachannelCmd& datachannelCmd) :
         m_enDatachannelCmd(datachannelCmd.AsEnum()) {};

      bool operator==(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd==rhs; }
      bool operator!=(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd!=rhs; }

      bool operator==(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd==rhs.AsEnum(); }
      bool operator!=(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd!=rhs.AsEnum(); }

      CDatachannelCmd& operator=(const CDatachannelCmd& rhs)
      {
         m_enDatachannelCmd = rhs.AsEnum();
         return *this;
      }

      T_enDatachannelCmd AsEnum() const { return m_enDatachannelCmd; };

      static const CDatachannelCmd LIST() { return cmdLIST; };
      static const CDatachannelCmd NLST() { return cmdNLST; };
      static const CDatachannelCmd RETR() { return cmdRETR; };
      static const CDatachannelCmd STOR() { return cmdSTOR; };
      static const CDatachannelCmd STOU() { return cmdSTOU; };
      static const CDatachannelCmd APPE() { return cmdAPPE; };

   private:
      CDatachannelCmd(T_enDatachannelCmd enDatachannelCmd) : m_enDatachannelCmd(enDatachannelCmd) {};
      T_enDatachannelCmd m_enDatachannelCmd;
   };

   /// @brief Structure for logon information.
   ///
   /// Holds all necessary parameters for logging on a ftp-server.
   /// Includes also the parameters which are needed for firewall logon.
   class CLogonInfo
   {
   public:
      CLogonInfo();
      CLogonInfo(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                 const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));
      CLogonInfo(const tstring& strHostname, int iHostport, const tstring& strUsername, const tstring& strPassword,
                 const tstring& strAccount, const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                 int iFwPort, const CFirewallType& crFwType);

      void SetHost(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                   const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));

      void SetFirewall(const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                       int iFwPort, const CFirewallType& crFwType);

      void DisableFirewall() { m_FwType = CFirewallType::None(); };

      const tstring&       Hostname()   const  { return m_strHostname;    };
      int                  Hostport()   const  { return m_iHostport;      };
      const tstring&       Username()   const  { return m_strUsername;    };
      const tstring&       Password()   const  { return m_strPassword;    };
      const tstring&       Account()    const  { return m_strAccount;     };
      const tstring&       FwHost()     const  { return m_strFwHostname;  };
      const tstring&       FwUsername() const  { return m_strFwUsername;  };
      const tstring&       FwPassword() const  { return m_strFwPassword;  };
      int                  FwPort()     const  { return m_iFwPort;        };
      const CFirewallType& FwType()     const  { return m_FwType;         };
   
   private:
      tstring        m_strHostname;   ///< name or ip-address of the ftp-server
      int            m_iHostport;     ///< port of the ftp-server
      tstring        m_strUsername;   ///< username for ftp-server
      tstring        m_strPassword;   ///< password for ftp-server
      tstring        m_strAccount;    ///< account mostly needed on ftp-servers running on unix/linux
      tstring        m_strFwHostname; ///< name or ip-address of the firewall
      tstring        m_strFwUsername; ///< username for firewall
      tstring        m_strFwPassword; ///< password for firewall
      int            m_iFwPort;       ///< port of the firewall
      CFirewallType  m_FwType;        ///< type of firewall
   };

   /// @brief calculates elapsed CPU time
   ///
   /// Is useful for calculating transferrates.
   class CTimer
   {
   public:
      CTimer() : m_dfStart(clock()) {};

      /// Restarts the timer
      void Restart() { m_dfStart = clock(); }
   
      /// Get the elapsed time in seconds
      double GetElapsedTime() const
      {
         return (static_cast<double>(clock()) - m_dfStart)/CLOCKS_PER_SEC;
      }

   private:
      double m_dfStart; ///< elapsed CPU time for process (start of measurement)
   };

   typedef std::vector<tstring>           TStringVector;

   /// @brief FTP client class
   ///
   /// Use this class for all the ftp-client stuff such as
   /// - logon server
   /// - send and receive data
   /// - get directory listing
   /// - ...
   ///
   /// There are two functions for upload (UploadFile_C/UploadFile_CPP)and two
   /// for download (DownloadFile_C/DownloadFile_CPP). First i have implemented
   /// the file serialization via STL-streams. After a few tests i recognized
   /// that the performance is not very well. So i decided to implement the file
   /// access with C-routines. For experimental purpose i left the slower version
   /// (STL-streams).
   class CFTPClient
   {
   public:
      class CNotifaction;
      // typedef std::set<CFTPClient::CNotifaction*> TObserverSet;

      CFTPClient(unsigned int uiTimeout=10, unsigned int uiBufferSize=2048, bool fUseFastFileAccess=true);
      ~CFTPClient();

      void AttachObserver(CNotifaction* pObserver);
      void DetachObserver(CNotifaction* pObserver);

      bool IsConnected() const;
      bool IsTransferringData() const;
      void SetResumeMode(bool fEnable=true);

      bool Login(const CLogonInfo& loginInfo);
      int  Logout();
      const CLogonInfo& LastLogonInfo() const { return m_LastLogonInfo; };

      bool List(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;

      bool List(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;

      int  Delete(const tstring& strFile) const;
      int  RenameFile(const tstring& strOldName, const tstring& strNewName) const;
      bool DownloadFile(const tstring& strRemoteFile, const tstring& strLocalFile,
                        const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false,
                      const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      int  RemoveDirectory(const tstring& strDirectory) const;
      int  MakeDirectory(const tstring& strDirectory) const;

      int PrintWorkingDirectory() const;
      int ChangeToParentDirectory() const;
      int ChangeWorkingDirectory(const tstring& strDirectory) const;

      int Passive(tstring& strHostIP, UINT& uiPort) const;
      int DataPort(const tstring& strHostIP, const UINT uiPort) const;
      int Abort() const;
      int System() const;
      int Noop() const;
      int RepresentationType(const CRepresentation& repType, DWORD dwSize=0) const;
      int FileStructure(const CStructure& crStructure) const;
      int TransferMode(const CTransferMode& crTransferMode) const;
      int Allocate(int iReserveBytes, const int* piMaxPageOrRecordSize=NULL) const;
      int StructureMount(const tstring& strPath) const;
      int SiteParameters(const tstring& strCmd) const;
      int Status(const tstring& strPath) const;
      int Help(const tstring& strTopic) const;

      int Reinitialize() const;
      int Restart(DWORD dwPosition) const;

      int FileSize(const tstring& strPath, long& lSize) const;
      int FileModificationTime(const tstring& strPath, tm& tmModificationTime) const;
      int FileModificationTime(const tstring& strPath, tstring& strModificationTime) const;

   protected:
      bool ExecuteDatachannelCommand(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, const CRepresentation& representation,
                                     bool fPasv, std::iostream& inputOutputStream, DWORD dwByteOffset=0, FILE* pFile=NULL) const;

      std::set<CFTPClient::CNotifaction*>& GetObservers();

   private:
      bool DownloadFile_C(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
      bool DownloadFile_CPP(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
     
      bool UploadFile_C(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile_CPP(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;

      bool TransferData(const CDatachannelCmd& crDatachannelCmd, std::iostream& inputOutputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool OpenActiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool OpenPassiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool SendData(std::istream& inputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool ReceiveData(std::ostream& outputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;

      tstring GetCmdString(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath) const;
      int  SimpleErrorCheck(int iFirstDigitOfReplyCode) const;

      bool SendCommand(const tstring& strOutput) const;
      bool GetResponse(int& iFirstDigitOfReplyCode) const;
      bool GetResponse(tstring& strResponse, int& iFirstDigitOfReplyCode) const;
      bool GetSingleResponseLine(tstring& strResponse, int& iFirstDigitOfReplyCode) const;

      bool OpenControlChannel(const tstring& strServerHost, int iServerPort=DEFAULT_FTP_PORT);
      void CloseControlChannel();

      void ReportError(const tstring& strErrorMsg, const tstring& strFile, DWORD dwLineNr) const;

// data members
   private:
      const unsigned int                     mc_uiTimeout;               ///< timeout for socket-functions
      const tstring                          mc_strEolCharacterSequence; ///< end-of-line sequence of current operating system
      const bool                             mc_fUseFastFileAccess;      ///< if true, C-routines are used for file access; if false, iostream is used

      mutable std::vector<TCHAR>             m_vBuffer;                  ///< buffer for sending and receiving
      mutable std::queue<std::string>        m_qResponseBuffer;          ///< buffer for server-responses
      mutable std::auto_ptr<CRepresentation> m_apCurrentRepresentation;  ///< representation currently set

      CBlockingSocket                        m_sckControlConnection;     ///< socket for connection to ftp-server
      mutable bool                           m_fTransferInProgress;      ///< if true, a file transfer is in progress
      mutable bool                           m_fAbortTransfer;           ///< indicates that a running filetransfer should be canceled
      bool                                   m_fResumeIfPossible;        ///< try to resume download/upload if possible
      std::set<CFTPClient::CNotifaction*>    m_setObserver;              ///< list of observers, which are notified about particular actions
      CLogonInfo                             m_LastLogonInfo;            ///< logon-info, which was used at the last call of login
   };

   /// @brief interface for notification
   ///
   /// Derive your class from this base-class and register this class on CFTPClient.
   /// For example you can use this for logging the sended and received commands.
   class CFTPClient::CNotifaction
   {
   public:
      virtual void OnInternalError(const tstring& /*strErrorMsg*/, const tstring& /*strFileName*/, DWORD /*dwLineNr*/) {};
      virtual void OnPostBytesReceived(long /*lReceivedBytes*/) {};
      virtual void OnPostBytesSend(long /*lSentBytes*/) {};
      virtual void OnPreReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnPreSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnPostReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnPostSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
      virtual void OnSendCommand(const tstring& /*strCommand*/) {};
      virtual void OnResponse(const tstring& /*strResponse*/) {};
   };
}

typedef std::set<CFTPClient::CNotifaction*> TObserverSet;

#endif
XtryAuthor Commented:
thank, ok here are some errors

Deleting intermediate files and output files for project 'log - Win32 Debug'.
--------------------Configuration: log - Win32 Debug--------------------
Compiling...
log.cpp
ftpclient.h(416) : error C2027: use of undefined type 'CFTPClient'
ftpclient.h(353) : see declaration of 'CFTPClient'
ftpclient.h(458) : error C2027: use of undefined type 'CFTPClient'
ftpclient.h(353) : see declaration of 'CFTPClient'
ftpclient.h(481) : error C2027: use of undefined type 'CFTPClient'
myprojects\log\log.cpp(3) : see declaration of 'CFTPClient'
ftpclient.h(481) : error C2065: 'CNotifaction' : undeclared identifier
ftpclient.h(481) : error C2059: syntax error : '>'
sys\stat.h(32) : error C2143: syntax error : missing ';' before '{'
Error executing cl.exe.

log.exe - 102 error(s), 0 warning(s)
itsmeandnobodyelseCommented:
You first could try to replace

   CFTPClient::CNotification

by

   CNotification

If that doesn't work, e. g. "use of undefined type 'CNotification' ", try the ftpclient.h below.

If that doesn't work either, post BlockingSocket.h and FTPFileState.h as these missing header files prevent me from compiling it myself.

Regards, Alex


#ifndef INC_FTPCLIENT_H
#define INC_FTPCLIENT_H

// STL-includes
#include <memory>
#include <set>
#include <queue>
#include <vector>
#include <sstream>

// other includes
#include "BlockingSocket.h"
#include "FTPFileState.h"

// definements for unicode support
#ifdef _UNICODE
   typedef std::wstring tstring;
   typedef std::wostream tostream;
   typedef std::wofstream tofstream;
   typedef std::wostringstream tostringstream;
   typedef std::wistringstream tistringstream;
   typedef std::wstreambuf tstreambuf;

   #define tcin  wcin
   #define tcout wcout
   #define tcerr wcerr
   #define tclog wclog
#else
   typedef std::string tstring;
   typedef std::ostream tostream;
   typedef std::ofstream tofstream;
   typedef std::ostringstream tostringstream;
   typedef std::istringstream tistringstream;
   typedef std::streambuf tstreambuf;

   #define tcin  cin
   #define tcout cout
   #define tcerr cerr
   #define tclog clog
#endif

////////////////////////////////////////////////////////////////////////////////
/// Namespace for all FTP-related classes.
////////////////////////////////////////////////////////////////////////////////
namespace nsFTP
{
   using namespace nsSocket;
   // constants
   const TCHAR ANONYMOUS_USER[] = _T("anonymous");
   enum T_enConstants {
      DEFAULT_FTP_PORT = 21, ///< The default port that an FTP service listens to on a remote host
      FTP_ERROR  = -1,
      FTP_OK     =  0,
      FTP_NOTOK  =  1, };

   /// Data Structure
   class CStructure
   {
   public:
      enum T_enFileStructure { scFile, scRecord, scPage };

      CStructure(const CStructure& structure) :
         m_enStructure(structure.AsEnum()) {};

      bool operator==(const T_enFileStructure& rhs) const { return m_enStructure==rhs; }
      bool operator!=(const T_enFileStructure& rhs) const { return m_enStructure!=rhs; }
      bool operator==(const CStructure& rhs) const { return m_enStructure==rhs.AsEnum(); }
      bool operator!=(const CStructure& rhs) const { return m_enStructure!=rhs.AsEnum(); }

      CStructure& operator=(const CStructure& rhs) { m_enStructure = rhs.AsEnum(); return *this; }

      T_enFileStructure AsEnum() const { return m_enStructure; };

      static const CStructure File()   { return scFile;   };
      static const CStructure Record() { return scRecord; };
      static const CStructure Page()   { return scPage;   };

   private:
      CStructure(T_enFileStructure enStructure) : m_enStructure(enStructure) {};
      T_enFileStructure m_enStructure;
   };

   /// Transmission Modes
   class CTransferMode
   {
   public:
      enum T_enTransferMode { tmStream, tmBlock, tmCompressed };

      CTransferMode(const CTransferMode& transferMode) :
         m_enTransferMode(transferMode.AsEnum()) {};

      bool operator==(const T_enTransferMode& rhs) const { return m_enTransferMode==rhs; }
      bool operator!=(const T_enTransferMode& rhs) const { return m_enTransferMode!=rhs; }
      bool operator==(const CTransferMode& rhs) const { return m_enTransferMode==rhs.AsEnum(); }
      bool operator!=(const CTransferMode& rhs) const { return m_enTransferMode!=rhs.AsEnum(); }

      CTransferMode& operator=(const CTransferMode& rhs) { m_enTransferMode = rhs.AsEnum(); return *this; }

      T_enTransferMode AsEnum() const { return m_enTransferMode; };

      static const CTransferMode Stream()     { return tmStream;     };
      static const CTransferMode Block()      { return tmBlock;      };
      static const CTransferMode Compressed() { return tmCompressed; };

   private:
      CTransferMode(T_enTransferMode enTransferMode) : m_enTransferMode(enTransferMode) {};
      T_enTransferMode m_enTransferMode;
   };

   class CFirewallType;
   typedef std::vector<CFirewallType> TFirewallTypeVector;

   /// Firewall Type
   class CFirewallType
   {
   public:
      // don't change order of enumeration
      enum T_enFirewallType {
         ftNone, ftSiteHostName, ftUserAfterLogon, ftProxyOpen, ftTransparent,
         ftUserWithNoLogon, ftUserFireIDatRemotehost, ftUserRemoteIDatRemoteHostFireID,
         ftUserRemoteIDatFireIDatRemoteHost };

      CFirewallType() : m_enFirewallType(ftNone) {};
      CFirewallType(const CFirewallType& firewallType) :
         m_enFirewallType(firewallType.AsEnum()) {};

      bool operator==(const T_enFirewallType& rhs) const { return m_enFirewallType==rhs; }
      bool operator!=(const T_enFirewallType& rhs) const { return m_enFirewallType!=rhs; }
      bool operator==(const CFirewallType& rhs) const { return m_enFirewallType==rhs.AsEnum(); }
      bool operator!=(const CFirewallType& rhs) const { return m_enFirewallType!=rhs.AsEnum(); }

      CFirewallType& operator=(const CFirewallType& rhs) { m_enFirewallType = rhs.AsEnum(); return *this; }

      T_enFirewallType AsEnum() const { return m_enFirewallType; };

      tstring AsDisplayString() const;
      tstring AsStorageString() const;
      static void GetAllTypes(TFirewallTypeVector& vTypes);

      static const CFirewallType None()                             { return ftNone;                             };
      static const CFirewallType SiteHostName()                     { return ftSiteHostName;                     };
      static const CFirewallType UserAfterLogon()                   { return ftUserAfterLogon;                   };
      static const CFirewallType ProxyOpen()                        { return ftProxyOpen;                        };
      static const CFirewallType Transparent()                      { return ftTransparent;                      };
      static const CFirewallType UserWithNoLogon()                  { return ftUserWithNoLogon;                  };
      static const CFirewallType UserFireIDatRemotehost()           { return ftUserFireIDatRemotehost;           };
      static const CFirewallType UserRemoteIDatRemoteHostFireID()   { return ftUserRemoteIDatRemoteHostFireID;   };
      static const CFirewallType UserRemoteIDatFireIDatRemoteHost() { return ftUserRemoteIDatFireIDatRemoteHost; };

   private:
      CFirewallType(T_enFirewallType enFirewallType) : m_enFirewallType(enFirewallType) {};
      T_enFirewallType m_enFirewallType;
   };

   /// @brief Representation Type - 1st param (see CRepresentation)
   class CType
   {
   public:
      enum T_enType { tyASCII, tyEBCDIC, tyImage, tyLocalByte };

      CType(const CType& type) :
         m_enType(type.AsEnum()) {};

      bool operator==(const T_enType& rhs) const { return m_enType==rhs; }
      bool operator!=(const T_enType& rhs) const { return m_enType!=rhs; }
      bool operator==(const CType& rhs) const { return m_enType==rhs.AsEnum(); }
      bool operator!=(const CType& rhs) const { return m_enType!=rhs.AsEnum(); }

      CType& operator=(const CType& rhs) { m_enType = rhs.AsEnum(); return *this; }

      T_enType AsEnum() const { return m_enType; };

      static const CType ASCII()     { return tyASCII;     };
      static const CType EBCDIC()    { return tyEBCDIC;    };
      static const CType Image()     { return tyImage;     };
      static const CType LocalByte() { return tyLocalByte; };

   private:
      CType(T_enType enType) : m_enType(enType) {};
      T_enType m_enType;
   };

   /// @brief Representation Type - 2nd param (see CRepresentation)
   class CTypeFormat
   {
   public:
      enum T_enTypeFormat { tfNonPrint, tfTelnetFormat, tfCarriageControl };

      CTypeFormat(const CTypeFormat& typeFormat) :
         m_enTypeFormat(typeFormat.AsEnum()) {};

      bool operator==(const T_enTypeFormat& rhs) const { return m_enTypeFormat==rhs; }
      bool operator!=(const T_enTypeFormat& rhs) const { return m_enTypeFormat!=rhs; }
      bool operator==(const CTypeFormat& rhs) const { return m_enTypeFormat==rhs.AsEnum(); }
      bool operator!=(const CTypeFormat& rhs) const { return m_enTypeFormat!=rhs.AsEnum(); }

      CTypeFormat& operator=(const CTypeFormat& rhs) { m_enTypeFormat = rhs.AsEnum(); return *this; }

      T_enTypeFormat AsEnum() const { return m_enTypeFormat; };

      static const CTypeFormat NonPrint()        { return tfNonPrint;        };
      static const CTypeFormat TelnetFormat()    { return tfTelnetFormat;    };
      static const CTypeFormat CarriageControl() { return tfCarriageControl; };

   private:
      CTypeFormat(T_enTypeFormat enTypeFormat) : m_enTypeFormat(enTypeFormat) {};
      T_enTypeFormat m_enTypeFormat;
   };

   /// Representation Type (see also CType and CTypeFormat)
   class CRepresentation
   {
   public:
      /// there is only NonPrint as FormatType supported yet
      CRepresentation(CType Type) : m_Type(Type), m_Format(CTypeFormat::NonPrint()) {};
     
      bool operator!=(const CRepresentation& rep1) const { return rep1.m_Type != m_Type || rep1.m_Format != m_Format; }
      bool operator==(const CRepresentation& rep1) const { return rep1.m_Type == m_Type && rep1.m_Format == m_Format; }
      CRepresentation& operator=(const CRepresentation& rhs)
      {
         m_Type = rhs.m_Type;
         m_Format = rhs.m_Format;
         return *this;
      };

      const CType&       Type()   const { return m_Type; };
      const CTypeFormat& Format() const { return m_Format; };

   private:
      CType       m_Type;
      CTypeFormat m_Format;
   };

   /// @brief Represents ftp-commands that use the data port (usually port 20).
   class CDatachannelCmd
   {
   public:
      enum T_enDatachannelCmd { cmdLIST, cmdNLST, cmdRETR, cmdSTOR, cmdSTOU, cmdAPPE };

      CDatachannelCmd(const CDatachannelCmd& datachannelCmd) :
         m_enDatachannelCmd(datachannelCmd.AsEnum()) {};

      bool operator==(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd==rhs; }
      bool operator!=(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd!=rhs; }

      bool operator==(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd==rhs.AsEnum(); }
      bool operator!=(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd!=rhs.AsEnum(); }

      CDatachannelCmd& operator=(const CDatachannelCmd& rhs)
      {
         m_enDatachannelCmd = rhs.AsEnum();
         return *this;
      }

      T_enDatachannelCmd AsEnum() const { return m_enDatachannelCmd; };

      static const CDatachannelCmd LIST() { return cmdLIST; };
      static const CDatachannelCmd NLST() { return cmdNLST; };
      static const CDatachannelCmd RETR() { return cmdRETR; };
      static const CDatachannelCmd STOR() { return cmdSTOR; };
      static const CDatachannelCmd STOU() { return cmdSTOU; };
      static const CDatachannelCmd APPE() { return cmdAPPE; };

   private:
      CDatachannelCmd(T_enDatachannelCmd enDatachannelCmd) : m_enDatachannelCmd(enDatachannelCmd) {};
      T_enDatachannelCmd m_enDatachannelCmd;
   };

   /// @brief Structure for logon information.
   ///
   /// Holds all necessary parameters for logging on a ftp-server.
   /// Includes also the parameters which are needed for firewall logon.
   class CLogonInfo
   {
   public:
      CLogonInfo();
      CLogonInfo(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                 const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));
      CLogonInfo(const tstring& strHostname, int iHostport, const tstring& strUsername, const tstring& strPassword,
                 const tstring& strAccount, const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                 int iFwPort, const CFirewallType& crFwType);

      void SetHost(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                   const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));

      void SetFirewall(const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                       int iFwPort, const CFirewallType& crFwType);

      void DisableFirewall() { m_FwType = CFirewallType::None(); };

      const tstring&       Hostname()   const  { return m_strHostname;    };
      int                  Hostport()   const  { return m_iHostport;      };
      const tstring&       Username()   const  { return m_strUsername;    };
      const tstring&       Password()   const  { return m_strPassword;    };
      const tstring&       Account()    const  { return m_strAccount;     };
      const tstring&       FwHost()     const  { return m_strFwHostname;  };
      const tstring&       FwUsername() const  { return m_strFwUsername;  };
      const tstring&       FwPassword() const  { return m_strFwPassword;  };
      int                  FwPort()     const  { return m_iFwPort;        };
      const CFirewallType& FwType()     const  { return m_FwType;         };
   
   private:
      tstring        m_strHostname;   ///< name or ip-address of the ftp-server
      int            m_iHostport;     ///< port of the ftp-server
      tstring        m_strUsername;   ///< username for ftp-server
      tstring        m_strPassword;   ///< password for ftp-server
      tstring        m_strAccount;    ///< account mostly needed on ftp-servers running on unix/linux
      tstring        m_strFwHostname; ///< name or ip-address of the firewall
      tstring        m_strFwUsername; ///< username for firewall
      tstring        m_strFwPassword; ///< password for firewall
      int            m_iFwPort;       ///< port of the firewall
      CFirewallType  m_FwType;        ///< type of firewall
   };

   /// @brief calculates elapsed CPU time
   ///
   /// Is useful for calculating transferrates.
   class CTimer
   {
   public:
      CTimer() : m_dfStart(clock()) {};

      /// Restarts the timer
      void Restart() { m_dfStart = clock(); }
   
      /// Get the elapsed time in seconds
      double GetElapsedTime() const
      {
         return (static_cast<double>(clock()) - m_dfStart)/CLOCKS_PER_SEC;
      }

   private:
      double m_dfStart; ///< elapsed CPU time for process (start of measurement)
   };

   typedef std::vector<tstring>           TStringVector;

   /// @brief FTP client class
   ///
   /// Use this class for all the ftp-client stuff such as
   /// - logon server
   /// - send and receive data
   /// - get directory listing
   /// - ...
   ///
   /// There are two functions for upload (UploadFile_C/UploadFile_CPP)and two
   /// for download (DownloadFile_C/DownloadFile_CPP). First i have implemented
   /// the file serialization via STL-streams. After a few tests i recognized
   /// that the performance is not very well. So i decided to implement the file
   /// access with C-routines. For experimental purpose i left the slower version
   /// (STL-streams).
   class CFTPClient
   {
   public:
       /// @brief interface for notification
       ///
       /// Derive your class from this base-class and register this class on CFTPClient.
       /// For example you can use this for logging the sended and received commands.
       class CFTPClient::CNotifaction
       {
       public:
          virtual void OnInternalError(const tstring& /*strErrorMsg*/, const tstring& /*strFileName*/, DWORD /*dwLineNr*/) {};
          virtual void OnPostBytesReceived(long /*lReceivedBytes*/) {};
          virtual void OnPostBytesSend(long /*lSentBytes*/) {};
          virtual void OnPreReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPreSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPostReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPostSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnSendCommand(const tstring& /*strCommand*/) {};
          virtual void OnResponse(const tstring& /*strResponse*/) {};
       };
      // class CNotifaction;
      // typedef std::set<CFTPClient::CNotifaction*> TObserverSet;

      CFTPClient(unsigned int uiTimeout=10, unsigned int uiBufferSize=2048, bool fUseFastFileAccess=true);
      ~CFTPClient();

      void AttachObserver(CNotifaction* pObserver);
      void DetachObserver(CNotifaction* pObserver);

      bool IsConnected() const;
      bool IsTransferringData() const;
      void SetResumeMode(bool fEnable=true);

      bool Login(const CLogonInfo& loginInfo);
      int  Logout();
      const CLogonInfo& LastLogonInfo() const { return m_LastLogonInfo; };

      bool List(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;

      bool List(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;

      int  Delete(const tstring& strFile) const;
      int  RenameFile(const tstring& strOldName, const tstring& strNewName) const;
      bool DownloadFile(const tstring& strRemoteFile, const tstring& strLocalFile,
                        const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false,
                      const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      int  RemoveDirectory(const tstring& strDirectory) const;
      int  MakeDirectory(const tstring& strDirectory) const;

      int PrintWorkingDirectory() const;
      int ChangeToParentDirectory() const;
      int ChangeWorkingDirectory(const tstring& strDirectory) const;

      int Passive(tstring& strHostIP, UINT& uiPort) const;
      int DataPort(const tstring& strHostIP, const UINT uiPort) const;
      int Abort() const;
      int System() const;
      int Noop() const;
      int RepresentationType(const CRepresentation& repType, DWORD dwSize=0) const;
      int FileStructure(const CStructure& crStructure) const;
      int TransferMode(const CTransferMode& crTransferMode) const;
      int Allocate(int iReserveBytes, const int* piMaxPageOrRecordSize=NULL) const;
      int StructureMount(const tstring& strPath) const;
      int SiteParameters(const tstring& strCmd) const;
      int Status(const tstring& strPath) const;
      int Help(const tstring& strTopic) const;

      int Reinitialize() const;
      int Restart(DWORD dwPosition) const;

      int FileSize(const tstring& strPath, long& lSize) const;
      int FileModificationTime(const tstring& strPath, tm& tmModificationTime) const;
      int FileModificationTime(const tstring& strPath, tstring& strModificationTime) const;

   protected:
      bool ExecuteDatachannelCommand(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, const CRepresentation& representation,
                                     bool fPasv, std::iostream& inputOutputStream, DWORD dwByteOffset=0, FILE* pFile=NULL) const;

      std::set<CNotifaction*>& GetObservers();

   private:
      bool DownloadFile_C(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
      bool DownloadFile_CPP(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
     
      bool UploadFile_C(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile_CPP(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;

      bool TransferData(const CDatachannelCmd& crDatachannelCmd, std::iostream& inputOutputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool OpenActiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool OpenPassiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool SendData(std::istream& inputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool ReceiveData(std::ostream& outputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;

      tstring GetCmdString(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath) const;
      int  SimpleErrorCheck(int iFirstDigitOfReplyCode) const;

      bool SendCommand(const tstring& strOutput) const;
      bool GetResponse(int& iFirstDigitOfReplyCode) const;
      bool GetResponse(tstring& strResponse, int& iFirstDigitOfReplyCode) const;
      bool GetSingleResponseLine(tstring& strResponse, int& iFirstDigitOfReplyCode) const;

      bool OpenControlChannel(const tstring& strServerHost, int iServerPort=DEFAULT_FTP_PORT);
      void CloseControlChannel();

      void ReportError(const tstring& strErrorMsg, const tstring& strFile, DWORD dwLineNr) const;

// data members
   private:
      const unsigned int                     mc_uiTimeout;               ///< timeout for socket-functions
      const tstring                          mc_strEolCharacterSequence; ///< end-of-line sequence of current operating system
      const bool                             mc_fUseFastFileAccess;      ///< if true, C-routines are used for file access; if false, iostream is used

      mutable std::vector<TCHAR>             m_vBuffer;                  ///< buffer for sending and receiving
      mutable std::queue<std::string>        m_qResponseBuffer;          ///< buffer for server-responses
      mutable std::auto_ptr<CRepresentation> m_apCurrentRepresentation;  ///< representation currently set

      CBlockingSocket                        m_sckControlConnection;     ///< socket for connection to ftp-server
      mutable bool                           m_fTransferInProgress;      ///< if true, a file transfer is in progress
      mutable bool                           m_fAbortTransfer;           ///< indicates that a running filetransfer should be canceled
      bool                                   m_fResumeIfPossible;        ///< try to resume download/upload if possible
      std::set<CNotifaction*>                m_setObserver;              ///< list of observers, which are notified about particular actions
      CLogonInfo                             m_LastLogonInfo;            ///< logon-info, which was used at the last call of login
   };

}

typedef std::set<CFTPClient::CNotifaction*> TObserverSet;

#endif

Regards, Alex
XtryAuthor Commented:
BlockingSocket.h

#include <afxsock.h>
#include <string>

namespace nsSocket
{

typedef const struct sockaddr* LPCSOCKADDR;

///////////////////////////////////////////////////////////////////////////////////////
//***************************** CBlockingSocketException  ***************************//
///////////////////////////////////////////////////////////////////////////////////////
class CBlockingSocketException : public CException
{
public:
   // Constructor
   CBlockingSocketException(LPTSTR pchMessage);
   
public:
   ~CBlockingSocketException() {}
   virtual BOOL GetErrorMessage(LPTSTR lpstrError, UINT nMaxError, PUINT pnHelpContext = NULL);
   virtual std::string GetErrorMessage(PUINT pnHelpContext = NULL);
   
private:
   int         m_nError;
   std::string m_strMessage;
};

///////////////////////////////////////////////////////////////////////////////////////
//*********************************** CSockAddr  ************************************//
///////////////////////////////////////////////////////////////////////////////////////
class CSockAddr : public sockaddr_in
{
public:
   // constructors
   CSockAddr()
   {
      sin_family        = AF_INET; // specifies address family
      sin_port          = 0;       // ip port
      sin_addr.s_addr   = 0;       // ip address
   }
   
   CSockAddr(const SOCKADDR& sa)
            { memcpy(this, &sa, sizeof(SOCKADDR)); }
   
   CSockAddr(const SOCKADDR_IN& sin)
            { memcpy(this, &sin, sizeof(SOCKADDR_IN)); }
   
   CSockAddr(ULONG ulAddr, USHORT ushPort = 0) // parms are host byte ordered
            {
               sin_family      = AF_INET;          // specifies address family
               sin_port        = htons(ushPort);   // ip port
               sin_addr.s_addr = htonl(ulAddr);    // ip address
            }
   
   CSockAddr(LPCTSTR pchIP, USHORT ushPort = 0) // dotted IP addr string
            {
               sin_family = AF_INET;               // specifies address family
               sin_port = htons(ushPort);          // ip port
               sin_addr.s_addr = inet_addr(pchIP); // ip address
            } // already network byte ordered
   
   // Return the address in dotted-decimal format
   std::string DottedDecimal()
            { return inet_ntoa(sin_addr); } // constructs a new CString object
   
   // Get port and address (even though they're public)
   USHORT Port() const
            { return ntohs(sin_port); }
   
   ULONG IPAddr() const
            { return ntohl(sin_addr.s_addr); }
   
   // operators added for efficiency
   CSockAddr& operator=(const SOCKADDR& sa)
            {
               memcpy(this, &sa, sizeof(SOCKADDR));
               return *this;
            }

   CSockAddr& operator=(const SOCKADDR_IN& sin)
            {
               memcpy(this, &sin, sizeof(SOCKADDR_IN));
               return *this;
            }

   operator SOCKADDR()
            { return *((LPSOCKADDR) this); }

   operator LPSOCKADDR()
            { return (LPSOCKADDR) this; }

   operator LPSOCKADDR_IN()
            { return (LPSOCKADDR_IN) this; }
};

///////////////////////////////////////////////////////////////////////////////////////
//********************************* CBlockingSocket  ********************************//
///////////////////////////////////////////////////////////////////////////////////////

// member functions truly block and must not be used in UI threads
// use this class as an alternative to the MFC CSocket class
class CBlockingSocket : public CObject
{
public:
   CBlockingSocket() :
      m_hSocket(NULL) {}

   void Cleanup();
   void Create(int nType = SOCK_STREAM);
   void Close();

   void Bind(LPCSOCKADDR psa) const;
   void Listen() const;
   void Connect(LPCSOCKADDR psa) const;
   bool Accept(CBlockingSocket& s, LPSOCKADDR psa) const;
   int  Send(LPCTSTR pch, int nSize, int nSecs) const;
   int  Write(LPCTSTR pch, int nSize, int nSecs) const;
   int  Receive(LPTSTR pch, int nSize, int nSecs) const;
   int  SendDatagram(LPCTSTR pch, int nSize, LPCSOCKADDR psa, int nSecs) const;
   int  ReceiveDatagram(LPTSTR pch, int nSize, LPSOCKADDR psa, int nSecs) const;
   void GetPeerAddr(LPSOCKADDR psa) const;
   void GetSockAddr(LPSOCKADDR psa) const;

   static CSockAddr   GetHostByName(LPCTSTR pchName, USHORT ushPort = 0);
   static LPCTSTR GetHostByAddr(LPCSOCKADDR psa);

   operator SOCKET() const { return m_hSocket; }

private:
   SOCKET m_hSocket;
};

///////////////////////////////////////////////////////////////////////////////////////
//******************************** CHttpBlockingSocket ******************************//
///////////////////////////////////////////////////////////////////////////////////////
class CHttpBlockingSocket : public CBlockingSocket
{
public:
   enum {nSizeRecv = 1000}; // max receive buffer size (> hdr line length)

   CHttpBlockingSocket();
   ~CHttpBlockingSocket();

   int ReadHttpHeaderLine(LPTSTR pch, int nSize, int nSecs);
   int ReadHttpResponse(LPTSTR pch, int nSize, int nSecs);

private:
   LPTSTR m_pReadBuf; // read buffer
   int    m_nReadBuf; // number of bytes in the read buffer
};

};
XtryAuthor Commented:
FTPFileState.h

#ifndef INC_FTPFILESTATE_H
#define INC_FTPFILESTATE_H

#include <string>
#include <vector>
#include "rc_smart_ptr.h"

namespace nsFTP
{

class CFTPFileStatus;
typedef nsSP::RCIPtr<CFTPFileStatus>   TSpFTPFileStatus;
typedef std::vector<TSpFTPFileStatus>  TSpFTPFileStatusVector;

/// Holds status information about a file on the ftp server.
class CFTPFileStatus
{
public:
   enum T_enSizeType {
      stUnknown,
      stBinary,        ///< size is the number of octets in TYPE I
      stASCII,         ///< size is the number of octets in TYPE A
   };

   /// When a time zone is unknown, it is assumed to be GMT. You may want
   /// to use localtime() for LOCAL times, along with an indication that the
   /// time is correct in the local time zone, and gmtime() for REMOTE* times.
   enum T_enMTimeType {
      mttUnknown,
      mttLocal,        ///< time is correct
      mttRemoteMinute, ///< time zone and secs are unknown
      mttRemoteDay,    ///< time zone and time of day are unknown
   };

   enum T_enIDType {
      idUnknown,
      idFull,          ///< unique identifier for files on this FTP server
   };

   friend class CFTPListParse;

public:
   CFTPFileStatus();
   CFTPFileStatus(const CFTPFileStatus& src);
   ~CFTPFileStatus();

   CFTPFileStatus& operator=(const CFTPFileStatus& rhs);
   bool operator==(const CFTPFileStatus& rhs) const;
   bool operator!=(const CFTPFileStatus& rhs) const;

public:
   void Reset();

   const std::string& Name()           const { return m_strName;                };
   bool               IsCwdPossible()  const { return m_fTryCwd;                };
   bool               IsRetrPossible() const { return m_fTryRetr;               };
   T_enSizeType       SizeType()       const { return m_enSizeType;             };
   long               Size()           const { return m_lSize;                  };
   T_enMTimeType      MTimeType()      const { return m_enModificationTimeType; };
   time_t             MTime()          const { return m_mtime;                  };
   const std::string& Attributes()     const { return m_strAttributes;          };
   const std::string& UID()            const { return m_strUID;                 };
   const std::string& GID()            const { return m_strGID;                 };
   const std::string& Link()           const { return m_strLink;                };
   T_enIDType         IDType()         const { return m_enIDType;               };
   const std::string& ID()             const { return m_strID;                  };
   bool               IsDot()          const { return m_strName==_T(".") || m_strName==_T(".."); };

private:
   std::string    m_strName;
   bool           m_fTryCwd;                 ///< false if cwd is definitely pointless, true otherwise
   bool           m_fTryRetr;                ///< false if RETR is definitely pointless, true otherwise
   T_enSizeType   m_enSizeType;
   long           m_lSize;                   ///< number of octets
   T_enMTimeType  m_enModificationTimeType;
   time_t         m_mtime;                   ///< modification time
   std::string    m_strAttributes;           ///< file attributes
   std::string    m_strUID;                  ///< user identifier (owner of file)
   std::string    m_strGID;                  ///< group identifier
   std::string    m_strLink;                 ///< number of links to file
   T_enIDType     m_enIDType;                ///< identifier type
   std::string    m_strID;                   ///< identifier
#ifdef _DEBUG
   std::string    m_strMTime;                ///< for debug only
#endif
};

/// Function object for sorting the filelists
class CFTPFileStatusContainerSort
{
   /// Baseclass for functionobjects
   class CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const = 0;
   };

   const CSortCriteria& m_rSortBase;  ///< sortkey
   const bool           m_fAscending; ///< sort order
   const bool           m_fDirFirst;  ///< if true, then directories are before the files
                                      ///< if false, directories and files are mixed up

public:
   CFTPFileStatusContainerSort(const CSortCriteria& rSortBase, bool fAscending, bool fDirFirst) :
      m_rSortBase(rSortBase),
      m_fAscending(fAscending),
      m_fDirFirst(fDirFirst)
   {};

   /// entry function for STL sort algorithm
   bool operator()(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
   {
      if( m_fDirFirst && x->IsCwdPossible() != y->IsCwdPossible() )
      {
         if( x->IsCwdPossible() && !y->IsCwdPossible() )
            return true;
         return false;
      }

      if( m_fAscending )
         return !m_rSortBase.Compare(x, y);
      else
         return m_rSortBase.Compare(x, y);
   }

   /// Order by name.
   class CName : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Name() > y->Name();
      }
   };

   /// Order by size.
   class CSize : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Size() > y->Size();
      }
   };

   /// Order by modification date.
   class CMTime : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->MTime() > y->MTime();
      }
   };

   /// Order by attributes.
   class CAttributes : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Attributes() > y->Attributes();
      }
   };

   /// Order by user id.
   class CUID : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->UID() > y->UID();
      }
   };

   /// Order by group id.
   class CGID : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->GID() > y->GID();
      }
   };

   /// Order by link.
   class CLink : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Link() > y->Link();
      }
   };

   /// Order by id.
   class CID : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->ID() > y->ID();
      }
   };
};

}
#endif // INC_FTPFILESTATE_H
itsmeandnobodyelseCommented:
Now need rc_smart_ptr.h included by ftpfilestate.h
XtryAuthor Commented:
rc_smart_ptr.h

#ifndef INC_RC_SMART_PTR_H
#define INC_RC_SMART_PTR_H

namespace nsSP
{
// base class for reference-counted objects
class RCObject
{
public:                                
   void AddReference() { ++m_iRefCount; }
   void RemoveReference()
   {
      if (--m_iRefCount == 0)
         delete this;
   }

   void MarkUnshareable() { m_fShareable = false; }
   bool IsShareable() const { return m_fShareable; }
   bool IsShared() const { return m_iRefCount > 1; }

protected:
   RCObject() : m_iRefCount(0), m_fShareable(true) {}
   RCObject(const RCObject& /*rhs*/) : m_iRefCount(0), m_fShareable(true) {}
   RCObject& operator=(const RCObject& /*rhs*/) { return *this; }

   virtual ~RCObject() {}

private:
   int  m_iRefCount;
   bool m_fShareable;
};

/******************************************************************************
*                 Template Class RCPtr
******************************************************************************/
// template class for smart pointers-to-T objects; T must support the RCObject interface
template<class T>
class RCPtr
{
public:
   RCPtr(T* realPtr = 0) : m_Pointee(realPtr) { Init(); }
   RCPtr(const RCPtr& rhs) : m_Pointee(rhs.m_Pointee) { Init(); }
   ~RCPtr() { if (m_Pointee) m_Pointee->RemoveReference(); }
   RCPtr& operator=(const RCPtr& rhs)
   {
      if (m_Pointee != rhs.m_Pointee)
      {
         T* pOldPointee = m_Pointee;
         m_Pointee = rhs.m_Pointee;
         Init();

         if (pOldPointee)
            pOldPointee->RemoveReference();                
      }

      return *this;
   }
   T* operator->() const { return m_Pointee; };
   T& operator*() const { return *m_Pointee; };

   bool IsNull() const  { return m_Pointee==NULL; }
   bool IsValid() const { return m_Pointee!=NULL; }

private:
   T* m_Pointee;

   void Init()
   {
      if (m_Pointee == 0)
         return;

      if (m_Pointee->IsShareable() == false)
         m_Pointee = new T(*m_Pointee);
   
      m_Pointee->AddReference();
   }
};


template<class T>
class RCIPtr
{
public:
   RCIPtr(T* realPtr = 0) :
      m_pCounter(new CountHolder)
   {
      m_pCounter->m_Pointee = realPtr;
      Init();
   }

   RCIPtr(const RCIPtr& rhs) : m_pCounter(rhs.m_pCounter) { Init(); }
   ~RCIPtr() { m_pCounter->RemoveReference(); }
   RCIPtr& operator=(const RCIPtr& rhs)
   {
      if (m_pCounter != rhs.m_pCounter)
      {
         m_pCounter->RemoveReference();    
         m_pCounter = rhs.m_pCounter;
         Init();
      }
      return *this;
   }

   T* operator->() const { return m_pCounter->m_Pointee; }
   T& operator*() const { return *(m_pCounter->m_Pointee); }

   RCObject& GetRCObject() { return *m_pCounter; }

   bool IsNull() const  { return m_pCounter==NULL?true:m_pCounter->m_Pointee==NULL; }
   bool IsValid() const { return m_pCounter==NULL?false:m_pCounter->m_Pointee!=NULL; }

private:
   struct CountHolder: public RCObject
   {
      ~CountHolder()
      {
         delete m_Pointee;
      }
      T* m_Pointee;
   };

   CountHolder* m_pCounter;
   void Init()
   {
      if (m_pCounter->IsShareable() == false)
      {
         T* pOldValue = m_pCounter->m_Pointee;
         m_pCounter = new CountHolder;
         m_pCounter->m_Pointee = new T(*pOldValue);
      }
      m_pCounter->AddReference();
   }
};

};
#endif // INC_RC_SMART_PTR_H
itsmeandnobodyelseCommented:
Got it. Need to change ftpclient.h and ftpfilestate.h.

Good luck.
Alex



#ifndef INC_FTPFILESTATE_H
#define INC_FTPFILESTATE_H

#include <string>
#include <vector>
#include "rc_smart_ptr.h"

class CFTPFileStatus;

namespace nsFTP
{


/// Holds status information about a file on the ftp server.
class CFTPFileStatus
{
public:
   enum T_enSizeType {
      stUnknown,
      stBinary,        ///< size is the number of octets in TYPE I
      stASCII,         ///< size is the number of octets in TYPE A
   };

   /// When a time zone is unknown, it is assumed to be GMT. You may want
   /// to use localtime() for LOCAL times, along with an indication that the
   /// time is correct in the local time zone, and gmtime() for REMOTE* times.
   enum T_enMTimeType {
      mttUnknown,
      mttLocal,        ///< time is correct
      mttRemoteMinute, ///< time zone and secs are unknown
      mttRemoteDay,    ///< time zone and time of day are unknown
   };

   enum T_enIDType {
      idUnknown,
      idFull,          ///< unique identifier for files on this FTP server
   };

   friend class CFTPListParse;

public:
   CFTPFileStatus();
   CFTPFileStatus(const CFTPFileStatus& src);
   ~CFTPFileStatus();

   CFTPFileStatus& operator=(const CFTPFileStatus& rhs);
   bool operator==(const CFTPFileStatus& rhs) const;
   bool operator!=(const CFTPFileStatus& rhs) const;

public:
   void Reset();

   const std::string& Name()           const { return m_strName;                };
   bool               IsCwdPossible()  const { return m_fTryCwd;                };
   bool               IsRetrPossible() const { return m_fTryRetr;               };
   T_enSizeType       SizeType()       const { return m_enSizeType;             };
   long               Size()           const { return m_lSize;                  };
   T_enMTimeType      MTimeType()      const { return m_enModificationTimeType; };
   time_t             MTime()          const { return m_mtime;                  };
   const std::string& Attributes()     const { return m_strAttributes;          };
   const std::string& UID()            const { return m_strUID;                 };
   const std::string& GID()            const { return m_strGID;                 };
   const std::string& Link()           const { return m_strLink;                };
   T_enIDType         IDType()         const { return m_enIDType;               };
   const std::string& ID()             const { return m_strID;                  };
   bool               IsDot()          const { return m_strName==_T(".") || m_strName==_T(".."); };

private:
   std::string    m_strName;
   bool           m_fTryCwd;                 ///< false if cwd is definitely pointless, true otherwise
   bool           m_fTryRetr;                ///< false if RETR is definitely pointless, true otherwise
   T_enSizeType   m_enSizeType;
   long           m_lSize;                   ///< number of octets
   T_enMTimeType  m_enModificationTimeType;
   time_t         m_mtime;                   ///< modification time
   std::string    m_strAttributes;           ///< file attributes
   std::string    m_strUID;                  ///< user identifier (owner of file)
   std::string    m_strGID;                  ///< group identifier
   std::string    m_strLink;                 ///< number of links to file
   T_enIDType     m_enIDType;                ///< identifier type
   std::string    m_strID;                   ///< identifier
#ifdef _DEBUG
   std::string    m_strMTime;                ///< for debug only
#endif
};

typedef nsSP::RCIPtr<CFTPFileStatus>   TSpFTPFileStatus;
typedef std::vector<TSpFTPFileStatus>  TSpFTPFileStatusVector;

/// Function object for sorting the filelists
class CFTPFileStatusContainerSort
{
   /// Baseclass for functionobjects
   class CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const = 0;
   };

   const CSortCriteria& m_rSortBase;  ///< sortkey
   const bool           m_fAscending; ///< sort order
   const bool           m_fDirFirst;  ///< if true, then directories are before the files
                                      ///< if false, directories and files are mixed up

public:
   CFTPFileStatusContainerSort(const CSortCriteria& rSortBase, bool fAscending, bool fDirFirst) :
      m_rSortBase(rSortBase),
      m_fAscending(fAscending),
      m_fDirFirst(fDirFirst)
   {};

   /// entry function for STL sort algorithm
   bool operator()(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
   {
      if( m_fDirFirst && x->IsCwdPossible() != y->IsCwdPossible() )
      {
         if( x->IsCwdPossible() && !y->IsCwdPossible() )
            return true;
         return false;
      }

      if( m_fAscending )
         return !m_rSortBase.Compare(x, y);
      else
         return m_rSortBase.Compare(x, y);
   }

   /// Order by name.
   class CName : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Name() > y->Name();
      }
   };

   /// Order by size.
   class CSize : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Size() > y->Size();
      }
   };

   /// Order by modification date.
   class CMTime : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->MTime() > y->MTime();
      }
   };

   /// Order by attributes.
   class CAttributes : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Attributes() > y->Attributes();
      }
   };

   /// Order by user id.
   class CUID : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->UID() > y->UID();
      }
   };

   /// Order by group id.
   class CGID : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->GID() > y->GID();
      }
   };

   /// Order by link.
   class CLink : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->Link() > y->Link();
      }
   };

   /// Order by id.
   class CID : public CSortCriteria
   {
   public:
      virtual bool Compare(const TSpFTPFileStatus& x, const TSpFTPFileStatus& y) const
      {
         return x->ID() > y->ID();
      }
   };
};

}
#endif // INC_FTPFILESTATE_H

#ifndef INC_FTPCLIENT_H
#define INC_FTPCLIENT_H

// STL-includes
#include <memory>
#include <set>
#include <queue>
#include <vector>
#include <sstream>

// other includes
#include "BlockingSocket.h"
#include "FTPFileState.h"

// definements for unicode support
#ifdef _UNICODE
   typedef std::wstring tstring;
   typedef std::wostream tostream;
   typedef std::wofstream tofstream;
   typedef std::wostringstream tostringstream;
   typedef std::wistringstream tistringstream;
   typedef std::wstreambuf tstreambuf;

   #define tcin  wcin
   #define tcout wcout
   #define tcerr wcerr
   #define tclog wclog
#else
   typedef std::string tstring;
   typedef std::ostream tostream;
   typedef std::ofstream tofstream;
   typedef std::ostringstream tostringstream;
   typedef std::istringstream tistringstream;
   typedef std::streambuf tstreambuf;

   #define tcin  cin
   #define tcout cout
   #define tcerr cerr
   #define tclog clog
#endif

////////////////////////////////////////////////////////////////////////////////
/// Namespace for all FTP-related classes.
////////////////////////////////////////////////////////////////////////////////
namespace nsFTP
{
   using namespace nsSocket;
   // constants
   const TCHAR ANONYMOUS_USER[] = _T("anonymous");
   enum T_enConstants {
      DEFAULT_FTP_PORT = 21, ///< The default port that an FTP service listens to on a remote host
      FTP_ERROR  = -1,
      FTP_OK     =  0,
      FTP_NOTOK  =  1, };

   /// Data Structure
   class CStructure
   {
   public:
      enum T_enFileStructure { scFile, scRecord, scPage };

      CStructure(const CStructure& structure) :
         m_enStructure(structure.AsEnum()) {};

      bool operator==(const T_enFileStructure& rhs) const { return m_enStructure==rhs; }
      bool operator!=(const T_enFileStructure& rhs) const { return m_enStructure!=rhs; }
      bool operator==(const CStructure& rhs) const { return m_enStructure==rhs.AsEnum(); }
      bool operator!=(const CStructure& rhs) const { return m_enStructure!=rhs.AsEnum(); }

      CStructure& operator=(const CStructure& rhs) { m_enStructure = rhs.AsEnum(); return *this; }

      T_enFileStructure AsEnum() const { return m_enStructure; };

      static const CStructure File()   { return scFile;   };
      static const CStructure Record() { return scRecord; };
      static const CStructure Page()   { return scPage;   };

   private:
      CStructure(T_enFileStructure enStructure) : m_enStructure(enStructure) {};
      T_enFileStructure m_enStructure;
   };

   /// Transmission Modes
   class CTransferMode
   {
   public:
      enum T_enTransferMode { tmStream, tmBlock, tmCompressed };

      CTransferMode(const CTransferMode& transferMode) :
         m_enTransferMode(transferMode.AsEnum()) {};

      bool operator==(const T_enTransferMode& rhs) const { return m_enTransferMode==rhs; }
      bool operator!=(const T_enTransferMode& rhs) const { return m_enTransferMode!=rhs; }
      bool operator==(const CTransferMode& rhs) const { return m_enTransferMode==rhs.AsEnum(); }
      bool operator!=(const CTransferMode& rhs) const { return m_enTransferMode!=rhs.AsEnum(); }

      CTransferMode& operator=(const CTransferMode& rhs) { m_enTransferMode = rhs.AsEnum(); return *this; }

      T_enTransferMode AsEnum() const { return m_enTransferMode; };

      static const CTransferMode Stream()     { return tmStream;     };
      static const CTransferMode Block()      { return tmBlock;      };
      static const CTransferMode Compressed() { return tmCompressed; };

   private:
      CTransferMode(T_enTransferMode enTransferMode) : m_enTransferMode(enTransferMode) {};
      T_enTransferMode m_enTransferMode;
   };

   class CFirewallType;
   typedef std::vector<CFirewallType> TFirewallTypeVector;

   /// Firewall Type
   class CFirewallType
   {
   public:
      // don't change order of enumeration
      enum T_enFirewallType {
         ftNone, ftSiteHostName, ftUserAfterLogon, ftProxyOpen, ftTransparent,
         ftUserWithNoLogon, ftUserFireIDatRemotehost, ftUserRemoteIDatRemoteHostFireID,
         ftUserRemoteIDatFireIDatRemoteHost };

      CFirewallType() : m_enFirewallType(ftNone) {};
      CFirewallType(const CFirewallType& firewallType) :
         m_enFirewallType(firewallType.AsEnum()) {};

      bool operator==(const T_enFirewallType& rhs) const { return m_enFirewallType==rhs; }
      bool operator!=(const T_enFirewallType& rhs) const { return m_enFirewallType!=rhs; }
      bool operator==(const CFirewallType& rhs) const { return m_enFirewallType==rhs.AsEnum(); }
      bool operator!=(const CFirewallType& rhs) const { return m_enFirewallType!=rhs.AsEnum(); }

      CFirewallType& operator=(const CFirewallType& rhs) { m_enFirewallType = rhs.AsEnum(); return *this; }

      T_enFirewallType AsEnum() const { return m_enFirewallType; };

      tstring AsDisplayString() const;
      tstring AsStorageString() const;
      static void GetAllTypes(TFirewallTypeVector& vTypes);

      static const CFirewallType None()                             { return ftNone;                             };
      static const CFirewallType SiteHostName()                     { return ftSiteHostName;                     };
      static const CFirewallType UserAfterLogon()                   { return ftUserAfterLogon;                   };
      static const CFirewallType ProxyOpen()                        { return ftProxyOpen;                        };
      static const CFirewallType Transparent()                      { return ftTransparent;                      };
      static const CFirewallType UserWithNoLogon()                  { return ftUserWithNoLogon;                  };
      static const CFirewallType UserFireIDatRemotehost()           { return ftUserFireIDatRemotehost;           };
      static const CFirewallType UserRemoteIDatRemoteHostFireID()   { return ftUserRemoteIDatRemoteHostFireID;   };
      static const CFirewallType UserRemoteIDatFireIDatRemoteHost() { return ftUserRemoteIDatFireIDatRemoteHost; };

   private:
      CFirewallType(T_enFirewallType enFirewallType) : m_enFirewallType(enFirewallType) {};
      T_enFirewallType m_enFirewallType;
   };

   /// @brief Representation Type - 1st param (see CRepresentation)
   class CType
   {
   public:
      enum T_enType { tyASCII, tyEBCDIC, tyImage, tyLocalByte };

      CType(const CType& type) :
         m_enType(type.AsEnum()) {};

      bool operator==(const T_enType& rhs) const { return m_enType==rhs; }
      bool operator!=(const T_enType& rhs) const { return m_enType!=rhs; }
      bool operator==(const CType& rhs) const { return m_enType==rhs.AsEnum(); }
      bool operator!=(const CType& rhs) const { return m_enType!=rhs.AsEnum(); }

      CType& operator=(const CType& rhs) { m_enType = rhs.AsEnum(); return *this; }

      T_enType AsEnum() const { return m_enType; };

      static const CType ASCII()     { return tyASCII;     };
      static const CType EBCDIC()    { return tyEBCDIC;    };
      static const CType Image()     { return tyImage;     };
      static const CType LocalByte() { return tyLocalByte; };

   private:
      CType(T_enType enType) : m_enType(enType) {};
      T_enType m_enType;
   };

   /// @brief Representation Type - 2nd param (see CRepresentation)
   class CTypeFormat
   {
   public:
      enum T_enTypeFormat { tfNonPrint, tfTelnetFormat, tfCarriageControl };

      CTypeFormat(const CTypeFormat& typeFormat) :
         m_enTypeFormat(typeFormat.AsEnum()) {};

      bool operator==(const T_enTypeFormat& rhs) const { return m_enTypeFormat==rhs; }
      bool operator!=(const T_enTypeFormat& rhs) const { return m_enTypeFormat!=rhs; }
      bool operator==(const CTypeFormat& rhs) const { return m_enTypeFormat==rhs.AsEnum(); }
      bool operator!=(const CTypeFormat& rhs) const { return m_enTypeFormat!=rhs.AsEnum(); }

      CTypeFormat& operator=(const CTypeFormat& rhs) { m_enTypeFormat = rhs.AsEnum(); return *this; }

      T_enTypeFormat AsEnum() const { return m_enTypeFormat; };

      static const CTypeFormat NonPrint()        { return tfNonPrint;        };
      static const CTypeFormat TelnetFormat()    { return tfTelnetFormat;    };
      static const CTypeFormat CarriageControl() { return tfCarriageControl; };

   private:
      CTypeFormat(T_enTypeFormat enTypeFormat) : m_enTypeFormat(enTypeFormat) {};
      T_enTypeFormat m_enTypeFormat;
   };

   /// Representation Type (see also CType and CTypeFormat)
   class CRepresentation
   {
   public:
      /// there is only NonPrint as FormatType supported yet
      CRepresentation(CType Type) : m_Type(Type), m_Format(CTypeFormat::NonPrint()) {};
     
      bool operator!=(const CRepresentation& rep1) const { return rep1.m_Type != m_Type || rep1.m_Format != m_Format; }
      bool operator==(const CRepresentation& rep1) const { return rep1.m_Type == m_Type && rep1.m_Format == m_Format; }
      CRepresentation& operator=(const CRepresentation& rhs)
      {
         m_Type = rhs.m_Type;
         m_Format = rhs.m_Format;
         return *this;
      };

      const CType&       Type()   const { return m_Type; };
      const CTypeFormat& Format() const { return m_Format; };

   private:
      CType       m_Type;
      CTypeFormat m_Format;
   };

   /// @brief Represents ftp-commands that use the data port (usually port 20).
   class CDatachannelCmd
   {
   public:
      enum T_enDatachannelCmd { cmdLIST, cmdNLST, cmdRETR, cmdSTOR, cmdSTOU, cmdAPPE };

      CDatachannelCmd(const CDatachannelCmd& datachannelCmd) :
         m_enDatachannelCmd(datachannelCmd.AsEnum()) {};

      bool operator==(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd==rhs; }
      bool operator!=(T_enDatachannelCmd rhs) const { return m_enDatachannelCmd!=rhs; }

      bool operator==(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd==rhs.AsEnum(); }
      bool operator!=(const CDatachannelCmd& rhs) const { return m_enDatachannelCmd!=rhs.AsEnum(); }

      CDatachannelCmd& operator=(const CDatachannelCmd& rhs)
      {
         m_enDatachannelCmd = rhs.AsEnum();
         return *this;
      }

      T_enDatachannelCmd AsEnum() const { return m_enDatachannelCmd; };

      static const CDatachannelCmd LIST() { return cmdLIST; };
      static const CDatachannelCmd NLST() { return cmdNLST; };
      static const CDatachannelCmd RETR() { return cmdRETR; };
      static const CDatachannelCmd STOR() { return cmdSTOR; };
      static const CDatachannelCmd STOU() { return cmdSTOU; };
      static const CDatachannelCmd APPE() { return cmdAPPE; };

   private:
      CDatachannelCmd(T_enDatachannelCmd enDatachannelCmd) : m_enDatachannelCmd(enDatachannelCmd) {};
      T_enDatachannelCmd m_enDatachannelCmd;
   };

   /// @brief Structure for logon information.
   ///
   /// Holds all necessary parameters for logging on a ftp-server.
   /// Includes also the parameters which are needed for firewall logon.
   class CLogonInfo
   {
   public:
      CLogonInfo();
      CLogonInfo(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                 const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));
      CLogonInfo(const tstring& strHostname, int iHostport, const tstring& strUsername, const tstring& strPassword,
                 const tstring& strAccount, const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                 int iFwPort, const CFirewallType& crFwType);

      void SetHost(const tstring& strHostname, int iHostport=DEFAULT_FTP_PORT, const tstring& strUsername=ANONYMOUS_USER,
                   const tstring& strPassword=_T("anonymous@user.com"), const tstring& strAccount=_T(""));

      void SetFirewall(const tstring& strFwHostname, const tstring& strFwUsername, const tstring& strFwPassword,
                       int iFwPort, const CFirewallType& crFwType);

      void DisableFirewall() { m_FwType = CFirewallType::None(); };

      const tstring&       Hostname()   const  { return m_strHostname;    };
      int                  Hostport()   const  { return m_iHostport;      };
      const tstring&       Username()   const  { return m_strUsername;    };
      const tstring&       Password()   const  { return m_strPassword;    };
      const tstring&       Account()    const  { return m_strAccount;     };
      const tstring&       FwHost()     const  { return m_strFwHostname;  };
      const tstring&       FwUsername() const  { return m_strFwUsername;  };
      const tstring&       FwPassword() const  { return m_strFwPassword;  };
      int                  FwPort()     const  { return m_iFwPort;        };
      const CFirewallType& FwType()     const  { return m_FwType;         };
   
   private:
      tstring        m_strHostname;   ///< name or ip-address of the ftp-server
      int            m_iHostport;     ///< port of the ftp-server
      tstring        m_strUsername;   ///< username for ftp-server
      tstring        m_strPassword;   ///< password for ftp-server
      tstring        m_strAccount;    ///< account mostly needed on ftp-servers running on unix/linux
      tstring        m_strFwHostname; ///< name or ip-address of the firewall
      tstring        m_strFwUsername; ///< username for firewall
      tstring        m_strFwPassword; ///< password for firewall
      int            m_iFwPort;       ///< port of the firewall
      CFirewallType  m_FwType;        ///< type of firewall
   };

   /// @brief calculates elapsed CPU time
   ///
   /// Is useful for calculating transferrates.
   class CTimer
   {
   public:
      CTimer() : m_dfStart(clock()) {};

      /// Restarts the timer
      void Restart() { m_dfStart = clock(); }
   
      /// Get the elapsed time in seconds
      double GetElapsedTime() const
      {
         return (static_cast<double>(clock()) - m_dfStart)/CLOCKS_PER_SEC;
      }

   private:
      double m_dfStart; ///< elapsed CPU time for process (start of measurement)
   };

   typedef std::vector<tstring>           TStringVector;

   /// @brief FTP client class
   ///
   /// Use this class for all the ftp-client stuff such as
   /// - logon server
   /// - send and receive data
   /// - get directory listing
   /// - ...
   ///
   /// There are two functions for upload (UploadFile_C/UploadFile_CPP)and two
   /// for download (DownloadFile_C/DownloadFile_CPP). First i have implemented
   /// the file serialization via STL-streams. After a few tests i recognized
   /// that the performance is not very well. So i decided to implement the file
   /// access with C-routines. For experimental purpose i left the slower version
   /// (STL-streams).
   class CFTPClient
   {
   public:
       /// @brief interface for notification
       ///
       /// Derive your class from this base-class and register this class on CFTPClient.
       /// For example you can use this for logging the sended and received commands.
       class CNotifaction
       {
       public:
          virtual void OnInternalError(const tstring& /*strErrorMsg*/, const tstring& /*strFileName*/, DWORD /*dwLineNr*/) {};
          virtual void OnPostBytesReceived(long /*lReceivedBytes*/) {};
          virtual void OnPostBytesSend(long /*lSentBytes*/) {};
          virtual void OnPreReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPreSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPostReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPostSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnSendCommand(const tstring& /*strCommand*/) {};
          virtual void OnResponse(const tstring& /*strResponse*/) {};
       };
      // class CNotifaction;
      // typedef std::set<CFTPClient::CNotifaction*> TObserverSet;

      CFTPClient(unsigned int uiTimeout=10, unsigned int uiBufferSize=2048, bool fUseFastFileAccess=true);
      ~CFTPClient();

      void AttachObserver(CNotifaction* pObserver);
      void DetachObserver(CNotifaction* pObserver);

      bool IsConnected() const;
      bool IsTransferringData() const;
      void SetResumeMode(bool fEnable=true);

      bool Login(const CLogonInfo& loginInfo);
      int  Logout();
      const CLogonInfo& LastLogonInfo() const { return m_LastLogonInfo; };

      bool List(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TStringVector& vstrFileList, bool fPasv=false) const;

      bool List(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;
      bool NameList(const tstring& strPath, TSpFTPFileStatusVector& vFileList, bool fPasv=false) const;

      int  Delete(const tstring& strFile) const;
      int  RenameFile(const tstring& strOldName, const tstring& strNewName) const;
      bool DownloadFile(const tstring& strRemoteFile, const tstring& strLocalFile,
                        const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false,
                      const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      int  RemoveDirectory(const tstring& strDirectory) const;
      int  MakeDirectory(const tstring& strDirectory) const;

      int PrintWorkingDirectory() const;
      int ChangeToParentDirectory() const;
      int ChangeWorkingDirectory(const tstring& strDirectory) const;

      int Passive(tstring& strHostIP, UINT& uiPort) const;
      int DataPort(const tstring& strHostIP, const UINT uiPort) const;
      int Abort() const;
      int System() const;
      int Noop() const;
      int RepresentationType(const CRepresentation& repType, DWORD dwSize=0) const;
      int FileStructure(const CStructure& crStructure) const;
      int TransferMode(const CTransferMode& crTransferMode) const;
      int Allocate(int iReserveBytes, const int* piMaxPageOrRecordSize=NULL) const;
      int StructureMount(const tstring& strPath) const;
      int SiteParameters(const tstring& strCmd) const;
      int Status(const tstring& strPath) const;
      int Help(const tstring& strTopic) const;

      int Reinitialize() const;
      int Restart(DWORD dwPosition) const;

      int FileSize(const tstring& strPath, long& lSize) const;
      int FileModificationTime(const tstring& strPath, tm& tmModificationTime) const;
      int FileModificationTime(const tstring& strPath, tstring& strModificationTime) const;

   protected:
      bool ExecuteDatachannelCommand(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, const CRepresentation& representation,
                                     bool fPasv, std::iostream& inputOutputStream, DWORD dwByteOffset=0, FILE* pFile=NULL) const;

      std::set<CNotifaction*>& GetObservers();

   private:
      bool DownloadFile_C(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
      bool DownloadFile_CPP(const tstring& strRemoteFile, const tstring& strLocalFile, const CRepresentation& repType, bool fPasv) const;
     
      bool UploadFile_C(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;
      bool UploadFile_CPP(const tstring& strLocalFile, const tstring& strRemoteFile, bool fStoreUnique=false, const CRepresentation& repType=CRepresentation(CType::Image()), bool fPasv=false) const;

      bool TransferData(const CDatachannelCmd& crDatachannelCmd, std::iostream& inputOutputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool OpenActiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool OpenPassiveDataConnection(CBlockingSocket& sckDataConnection, const CDatachannelCmd& crDatachannelCmd, const tstring& strPath, DWORD dwByteOffset) const;
      bool SendData(std::istream& inputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;
      bool ReceiveData(std::ostream& outputStream, CBlockingSocket& sckDataConnection, FILE* pFile=NULL) const;

      tstring GetCmdString(const CDatachannelCmd& crDatachannelCmd, const tstring& strPath) const;
      int  SimpleErrorCheck(int iFirstDigitOfReplyCode) const;

      bool SendCommand(const tstring& strOutput) const;
      bool GetResponse(int& iFirstDigitOfReplyCode) const;
      bool GetResponse(tstring& strResponse, int& iFirstDigitOfReplyCode) const;
      bool GetSingleResponseLine(tstring& strResponse, int& iFirstDigitOfReplyCode) const;

      bool OpenControlChannel(const tstring& strServerHost, int iServerPort=DEFAULT_FTP_PORT);
      void CloseControlChannel();

      void ReportError(const tstring& strErrorMsg, const tstring& strFile, DWORD dwLineNr) const;

// data members
   private:
      const unsigned int                     mc_uiTimeout;               ///< timeout for socket-functions
      const tstring                          mc_strEolCharacterSequence; ///< end-of-line sequence of current operating system
      const bool                             mc_fUseFastFileAccess;      ///< if true, C-routines are used for file access; if false, iostream is used

      mutable std::vector<TCHAR>             m_vBuffer;                  ///< buffer for sending and receiving
      mutable std::queue<std::string>        m_qResponseBuffer;          ///< buffer for server-responses
      mutable std::auto_ptr<CRepresentation> m_apCurrentRepresentation;  ///< representation currently set

      CBlockingSocket                        m_sckControlConnection;     ///< socket for connection to ftp-server
      mutable bool                           m_fTransferInProgress;      ///< if true, a file transfer is in progress
      mutable bool                           m_fAbortTransfer;           ///< indicates that a running filetransfer should be canceled
      bool                                   m_fResumeIfPossible;        ///< try to resume download/upload if possible
      std::set<CNotifaction*>                m_setObserver;              ///< list of observers, which are notified about particular actions
      CLogonInfo                             m_LastLogonInfo;            ///< logon-info, which was used at the last call of login
   };

   typedef std::set<CFTPClient::CNotifaction*> TObserverSet;
}

#endif  // INC_FTPCLIENT_H


XtryAuthor Commented:
thank for helping, this is the errors as of today

Deleting intermediate files and output files for project 'log - Win32 Debug'.
--------------------Configuration: log - Win32 Debug--------------------
Compiling...
log.cpp
log.cpp(27) : warning C4101: 'buffer1' : unreferenced local variable
log.cpp(29) : warning C4101: 'data' : unreferenced local variable
log.cpp(24) : warning C4101: 'res' : unreferenced local variable
log.cpp(30) : warning C4101: 'add' : unreferenced local variable
log.cpp(27) : warning C4101: 'buffer' : unreferenced local variable
log.cpp(31) : warning C4101: 'sock' : unreferenced local variable
Compiling...
BlockingSocket.cpp
FtpClient.cpp
FtpClient.cpp(249) : error C2039: 'TObserverSet' : is not a member of 'CFTPClient'
ftpclient.h(353) : see declaration of 'CFTPClient'
FtpClient.cpp(303) : error C2039: 'reset' : is not a member of 'auto_ptr<class nsFTP::CRepresentation>'
FtpClient.cpp(580) : error C2039: 'push_back' : is not a member of 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
FtpClient.cpp(835) : error C2039: 'reset' : is not a member of 'auto_ptr<class nsFTP::CRepresentation>'
FTPFileState.cpp
StdAfx.cpp
Generating Code...
Error executing cl.exe.

log.exe - 184 error(s), 15 warning(s)
itsmeandnobodyelseCommented:
>>>> FtpClient.cpp(249) : error C2039: 'TObserverSet' : is not a member of 'CFTPClient'

we now have errors regarding cpp files ..

In ftpclient.h below class CNotifaction,  you need to add the typedef of TObserverSet

       class CNotifaction
       {
       public:
          virtual void OnInternalError(const tstring& /*strErrorMsg*/, const tstring& /*strFileName*/, DWORD /*dwLineNr*/) {};
          virtual void OnPostBytesReceived(long /*lReceivedBytes*/) {};
          virtual void OnPostBytesSend(long /*lSentBytes*/) {};
          virtual void OnPreReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPreSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPostReceiveFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
          virtual void OnPostSendFile(const tstring& /*strSourceFile*/, const tstring& /*strTargetFile*/, long /*lFileSize*/) {};
           virtual void OnSendCommand(const tstring& /*strCommand*/) {};
          virtual void OnResponse(const tstring& /*strResponse*/) {};
       };
      // class CNotifaction;
      // typedef std::set<CFTPClient::CNotifaction*> TObserverSet;
      typedef std::set<CNotifaction*> TObserverSet;

Then remove

        typedef std::set<CFTPClient::CNotifaction*> TObserverSet;

at end of file.

The problem was that ftpclient.cpp uses CFTPClient::TObserverSet (and not only TObserverSet), so the typedef needs to be defined within class scope of CFTPClient.

Regards, Alex


XtryAuthor Commented:
Deleting intermediate files and output files for project 'log - Win32 Debug'.
--------------------Configuration: log - Win32 Debug--------------------
Compiling...
log.cpp
log.cpp(27) : warning C4101: 'buffer1' : unreferenced local variable
log.cpp(29) : warning C4101: 'data' : unreferenced local variable
log.cpp(24) : warning C4101: 'res' : unreferenced local variable
log.cpp(30) : warning C4101: 'add' : unreferenced local variable
log.cpp(27) : warning C4101: 'buffer' : unreferenced local variable
log.cpp(31) : warning C4101: 'sock' : unreferenced local variable
Compiling...
BlockingSocket.cpp
FtpClient.cpp
FtpClient.cpp(303) : error C2039: 'reset' : is not a member of 'auto_ptr<class nsFTP::CRepresentation>'
FtpClient.cpp(580) : error C2039: 'push_back' : is not a member of 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
FtpClient.cpp(835) : error C2039: 'reset' : is not a member of 'auto_ptr<class nsFTP::CRepresentation>'
FTPFileState.cpp
ftpfilestate.h(66) : error C2065: '_T' : undeclared identifier
ftpfilestate.h(66) : error C2676: binary '==' : 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a
type acceptable to the predefined operator
ftpfilestate.h(66) : error C2676: binary '==' : 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a
type acceptable to the predefined operator
FTPFileState.cpp(27) : error C2872: 'CFTPFileStatus' : ambiguous symbol
FTPFileState.cpp(27) : error C2027: use of undefined type 'CFTPFileStatus'
ftpfilestate.h(8) : see declaration of 'CFTPFileStatus'
FTPFileState.cpp(27) : error C2872: 'CFTPFileStatus' : ambiguous symbol
FTPFileState.cpp(30) : error C2065: 'stUnknown' : undeclared identifier
FTPFileState.cpp(32) : error C2065: 'mttUnknown' : undeclared identifier
FTPFileState.cpp(34) : error C2065: 'idUnknown' : undeclared identifier
FTPFileState.cpp(35) : error C2550: 'CFTPFileStatus' : constructor initializer lists are only allowed on constructor definitions
FTPFileState.cpp(36) : warning C4508: 'CFTPFileStatus' : function should return a value; 'void' return type assumed
FTPFileState.cpp(38) : error C2872: 'CFTPFileStatus' : ambiguous symbol
FTPFileState.cpp(38) : error C2027: use of undefined type 'CFTPFileStatus'
ftpfilestate.h(8) : see declaration of 'CFTPFileStatus'
FTPFileState.cpp(38) : error C2872: 'CFTPFileStatus' : ambiguous symbol
FTPFileState.cpp(38) : error C2872: 'CFTPFileStatus' : ambiguous symbol
FTPFileState.cpp(38) : error C2143: syntax error : missing ',' before '&'
StdAfx.cpp
Generating Code...
Error executing cl.exe.

log.exe - 183 error(s), 15 warning(s)
itsmeandnobodyelseCommented:
Now it is going to get critically...

>>>> FtpClient.cpp(303) : error C2039: 'reset' : is not a member of 'auto_ptr<class nsFTP::CRepresentation>'

CFTPClient uses a newer version of STL. In VC6 std::auto_ptr::reset isn't defined, hence the error. My problem now is, that I don't know what the auto_ptr::reset function does. I'll will check it at home at my VC7 installation and maybe know more tomorrow.

>>>> FtpClient.cpp(580) : error C2039: 'push_back' : is not a member of 'basic_string

Here is the same. std::string has no push_back function. But I know what push_back should do. So, we could change it in cpp file (you need to post ftpclient.cpp file).


>>>> ftpfilestate.h(66) : error C2065: '_T' : undeclared identifier
>>>> ftpfilestate.h(66) : error C2676: binary '==' : 'const class std::basic_string

Seems as you would need to include windows.h prior to ftpclient.h. _T is a macro defined in winuser.h that was included by windows.h.

>>>> FTPFileState.cpp(27) : error C2872: 'CFTPFileStatus' : ambiguous symbol

I need probably ftpfilestate.cpp to solve that. Looks like a namespace problem.

Xtry, the ftpclient project probably was made for VC7 or any other newer C++ compiler. Unfortunately, the author meant to use any new feature available (only) at these environments. Don't worry about the number of errors. I am confidential that I could get it compiled tomorrow though I am not at home but at business. Have to leave now in 10 minutes (back after 12 hours).

Regards, Alex











Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
XtryAuthor Commented:
thank you so much itsmeandnobodyelse!!! this is so much trouble... I only want to make this because I want to have an application that can record all keystrokes in my computer and after it riches the file size it uploads the file.log to my ftp,
so it works like this in command prompt I type "<file> <file.log> <size> <ftpserver> <port> <user> <pass>"
or whatever its easier to make. I just dont want to keep doing this over and over for 1000 errors I get and waster your time. I really appreciate what you have done and for helping me all this time.
itsmeandnobodyelseCommented:
>>>> ... for 1000 errors I get and waster your time

Don't mind number of errors and my time ;-)

I'll tell you if we have to raise the hands ;-)

>>>> reset error

OK, I read the specs of auto_ptr::reset and it is no problem to replace that by old code.


  auto_ptr<int> pi = new int(10);

  pi.reset(new int(20));     // reset deletes old pointer and set the new pointer

We get the same if we

  delete pi.release();   // get the old pointer, set member to NULL
  pi = new int(20);      // set new pointer

You should get rid of the _T error by including windows.h in ftpfilestate.h.

Could you post both ftpclient.cpp and ftpfilestate.cpp?

Regards, Alex


XtryAuthor Commented:
do you know visual basic ?
itsmeandnobodyelseCommented:
>>>> do you know visual basic ?

I can read VB code but hardly write.

Tomorrow, I have my home day, where I could download ftpclient. I wonder, if I'll get it compiled...

Regards, Alex
XtryAuthor Commented:
wow, thanks man
itsmeandnobodyelseCommented:
I got it:

These were the steps:

  - downloaded ftpclient zip file
  - extracted it to a new projects directory
  - started VC6
  - new Project - Win32 Application - ftpclient - empty project
  - added all cpp/h-files to project
  - compiled: stdafx.h was missing
      - replaced all stdafx.h by afx.h
  - compiled: cillions of C4786
      - added #pragma warning(disable:4786) to all cpp files
  - compiled: errors in blockingsocket.h
      - added
               #include <winsock2.h>
         after afx.h
  - compiled: ftpclient.h CFTPClient::CNotifaction - unknown type
      - moved class CNotifaction up before typedef and removed CFTPClient:: both from
        class name and template argument (CFTPClient:: wasn't allowed in class CFTPClient class).
  - compiled: error in ftpclient.cpp : reset
      - replaced      
               m_apCurrentRepresentation.reset(NULL);
        by
               delete m_apCurrentRepresentation.release();
  - compiled:   error in ftpclient.cpp    strPathTemp.push_back(_T('/'));
     - replaced
                   strPathTemp.push_back(_T('/'));
       by
                   strPathTemp += (_T('/'));
  - compiled:   error in ftpclient.cpp    m_apCurrentRepresentation.reset
     - replaced
             m_apCurrentRepresentation.reset(new CRepresentation(CType::ASCII()));
        by
             {
                  delete m_apCurrentRepresentation.release();
                  m_apCurrentRepresentation = std::auto_ptr<CRepresentation>(new CRepresentation(CType::ASCII()));
             }
  - compiled: ok.
    Linker: errors unresolved externals: socket functions
         - added wsock32.lib to linker input modules (both Debug and Release Settings)
  - build:
    Linker: errors unresolved externals: thread functions
         - changed code generation in C++ settings to multithreaded debugging (Debug) and multithreaded (Release)
  - rebuild all: ok

Voilà.

Regards, Alex


       
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.