From 1f29685803fdd5f00ebc4d61f2cd2e15b12448c2 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 31 Dec 2010 21:00:25 +0000 Subject: [PATCH] - bugfixes for ftp server to work on windows, silly M$ compiler has issues with mixing C / C++ code so I had to make these changes --- mk/windoze/shared_lib.vcproj | 108 +++++++++++++++++- .../shared_lib/include/feathery_ftp/ftpIfc.h | 1 + .../include/feathery_ftp/ftpTypes.h | 19 ++- .../include/platform/posix/miniftpserver.h | 1 - .../sources/feathery_ftp/ftpRuntime.c | 6 +- .../sources/platform/posix/miniftpserver.cpp | 8 +- 6 files changed, 129 insertions(+), 14 deletions(-) diff --git a/mk/windoze/shared_lib.vcproj b/mk/windoze/shared_lib.vcproj index 473aa179f..327c999f2 100755 --- a/mk/windoze/shared_lib.vcproj +++ b/mk/windoze/shared_lib.vcproj @@ -251,38 +251,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -921,10 +1013,22 @@ RelativePath="..\..\source\shared_lib\sources\platform\posix\ircclient.cpp" > + + + + + + @@ -957,10 +1061,6 @@ RelativePath="..\..\source\shared_lib\include\platform\sdl\thread.h" > - - diff --git a/source/shared_lib/include/feathery_ftp/ftpIfc.h b/source/shared_lib/include/feathery_ftp/ftpIfc.h index 4a1c51cd2..7371b2d1e 100644 --- a/source/shared_lib/include/feathery_ftp/ftpIfc.h +++ b/source/shared_lib/include/feathery_ftp/ftpIfc.h @@ -38,6 +38,7 @@ extern "C" { #endif +void ftpInit(ftpFindExternalFTPServerIpType cb1, ftpAddUPNPPortForwardType cb2, ftpRemoveUPNPPortForwardType cb3); int ftpCreateAccount(const char* name, const char* passw, const char* root, int accRights); int ftpStart(int portNumber); int ftpShutdown(void); diff --git a/source/shared_lib/include/feathery_ftp/ftpTypes.h b/source/shared_lib/include/feathery_ftp/ftpTypes.h index 0da9d1c6b..ea3a10088 100755 --- a/source/shared_lib/include/feathery_ftp/ftpTypes.h +++ b/source/shared_lib/include/feathery_ftp/ftpTypes.h @@ -60,9 +60,22 @@ typedef uint16_t port_t; #define TRUE 1 #endif -ip_t (*ftpFindExternalFTPServerIp)(ip_t clientIp); -void (*ftpAddUPNPPortForward)(int internalPort, int externalPort); -void (*ftpRemoveUPNPPortForward)(int internalPort, int externalPort); +#ifdef __cplusplus +extern "C" { +#endif + int VERBOSE_MODE_ENABLED; + +typedef ip_t (*ftpFindExternalFTPServerIpType)(ip_t clientIp); +typedef void (*ftpAddUPNPPortForwardType)(int internalPort, int externalPort); +typedef void (*ftpRemoveUPNPPortForwardType)(int internalPort, int externalPort); + +ftpFindExternalFTPServerIpType ftpFindExternalFTPServerIp; +ftpAddUPNPPortForwardType ftpAddUPNPPortForward; +ftpRemoveUPNPPortForwardType ftpRemoveUPNPPortForward; + +#ifdef __cplusplus +} +#endif #endif diff --git a/source/shared_lib/include/platform/posix/miniftpserver.h b/source/shared_lib/include/platform/posix/miniftpserver.h index 1da0d0287..b650721b8 100644 --- a/source/shared_lib/include/platform/posix/miniftpserver.h +++ b/source/shared_lib/include/platform/posix/miniftpserver.h @@ -26,7 +26,6 @@ namespace Shared { namespace PlatformCommon { // ===================================================== // class FTPServerThread // ===================================================== -uint32 FindExternalFTPServerIp(uint32 clientIp); class FTPServerThread : public BaseThread { diff --git a/source/shared_lib/sources/feathery_ftp/ftpRuntime.c b/source/shared_lib/sources/feathery_ftp/ftpRuntime.c index 749687099..c2a7eba47 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpRuntime.c +++ b/source/shared_lib/sources/feathery_ftp/ftpRuntime.c @@ -36,6 +36,11 @@ */ LOCAL socket_t server; +void ftpInit(ftpFindExternalFTPServerIpType cb1, ftpAddUPNPPortForwardType cb2, ftpRemoveUPNPPortForwardType cb3) { + ftpFindExternalFTPServerIp = cb1; + ftpAddUPNPPortForward = cb2; + ftpRemoveUPNPPortForward = cb3; +} /** * @brief Initializes and starts the server @@ -48,7 +53,6 @@ int ftpStart(int portNumber) { server = -1; // set server socket to invalid value - if(VERBOSE_MODE_ENABLED) printf("Feathery FTP-Server\n"); ftpArchInit(); diff --git a/source/shared_lib/sources/platform/posix/miniftpserver.cpp b/source/shared_lib/sources/platform/posix/miniftpserver.cpp index d3db0d970..125fd052a 100644 --- a/source/shared_lib/sources/platform/posix/miniftpserver.cpp +++ b/source/shared_lib/sources/platform/posix/miniftpserver.cpp @@ -28,8 +28,8 @@ namespace Shared { namespace PlatformCommon { static std::map clientToFTPServerList; -uint32 FindExternalFTPServerIp(uint32 clientIp) { - uint32 result = clientToFTPServerList[clientIp]; +ip_t FindExternalFTPServerIp(ip_t clientIp) { + ip_t result = clientToFTPServerList[clientIp]; if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread clientIp = %u, result = %u\n",clientIp,result); @@ -40,9 +40,7 @@ FTPServerThread::FTPServerThread(std::pair mapsPath,int portNumbe this->mapsPath = mapsPath; this->portNumber = portNumber; - ftpAddUPNPPortForward = &UPNP_Tools::AddUPNPPortForward; - ftpRemoveUPNPPortForward = &UPNP_Tools::RemoveUPNPPortForward; - ftpFindExternalFTPServerIp = &FindExternalFTPServerIp; + ftpInit(&FindExternalFTPServerIp,&UPNP_Tools::AddUPNPPortForward,&UPNP_Tools::RemoveUPNPPortForward); VERBOSE_MODE_ENABLED = SystemFlags::VERBOSE_MODE_ENABLED; }