Modified libretroshare to compile on Cygwin / MinGW.

* removed exceptions from serialiser (had troubles previously on win32).
 * Modified code in startup (enable CRYPTO structure) and rsdir.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1189 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2009-05-07 21:36:17 +00:00
parent deea89cbd0
commit 20593c9de2
7 changed files with 57 additions and 33 deletions

View File

@ -1406,7 +1406,9 @@ class CRYPTPROTECT_PROMPTSTRUCT;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef A_VIRER
#ifdef WINDOWS_SYS
typedef struct _CRYPTPROTECT_PROMPTSTRUCT {
DWORD cbSize;
DWORD dwPromptFlags;
@ -1414,6 +1416,7 @@ typedef struct _CRYPTPROTECT_PROMPTSTRUCT {
LPCWSTR szPrompt;
} CRYPTPROTECT_PROMPTSTRUCT,
*PCRYPTPROTECT_PROMPTSTRUCT;
#endif
/* definitions for the two functions */

View File

@ -14,14 +14,25 @@ PQI_USE_XPGP = 1
###########################################################################
ALT_SRC_ROOT=/cygdrive/c/RetroShareBuild/src
SRC_ROOT=/cygdrive/c/RetroShareBuild/src
#### DrBobs Versions.... Please Don't Delete.
### Comment out if needed.
# These never change.
PTHREADS_DIR=$(ALT_SRC_ROOT)/pthreads-w32-2-8-0-release
ZLIB_DIR=$(ALT_SRC_ROOT)/zlib-1.2.3
ALT_SRC_ROOT=/cygdrive/c/home/rmfern/prog/MinGW
SRC_ROOT=../../../..
PTHREADS_DIR=$(ALT_SRC_ROOT)/pthreads/pthreads.2
###################
#ALT_SRC_ROOT=/cygdrive/c/RetroShareBuild/src
#SRC_ROOT=/cygdrive/c/RetroShareBuild/src
#PTHREADS_DIR=$(ALT_SRC_ROOT)/pthreads-w32-2-8-0-release
###################
# pretty stable...
ZLIB_DIR=$(ALT_SRC_ROOT)/zlib-1.2.3
SSL_DIR=$(SRC_ROOT)/openssl-0.9.7g-xpgp-0.1c
UPNPC_DIR=$(SRC_ROOT)/miniupnpc-1.0

View File

@ -97,8 +97,6 @@ RsItem *RsChatSerialiser::deserialise(void *data, uint32_t *pktsize)
return NULL; /* wrong type */
}
try
{
switch(getRsItemSubType(rstype))
{
case RS_PKT_SUBTYPE_DEFAULT: return new RsChatMsgItem(data,*pktsize) ;
@ -108,12 +106,6 @@ RsItem *RsChatSerialiser::deserialise(void *data, uint32_t *pktsize)
return NULL ;
}
}
catch(std::exception& e)
{
std::cerr << "Exception raised: " << e.what() << std::endl ;
return NULL ;
}
}
uint32_t RsChatMsgItem::serial_size()
{
@ -231,9 +223,9 @@ RsChatMsgItem::RsChatMsgItem(void *data,uint32_t size)
std::cerr << "Building new chat msg item." << std::endl ;
#endif
if (offset != rssize)
throw std::runtime_error("Size error while deserializing.") ;
std::cerr << "Size error while deserializing." << std::endl ;
if (!ok)
throw std::runtime_error("Unknown error while deserializing.") ;
std::cerr << "Unknown error while deserializing." << std::endl ;
}
RsChatStatusItem::RsChatStatusItem(void *data,uint32_t size)
@ -250,9 +242,9 @@ RsChatStatusItem::RsChatStatusItem(void *data,uint32_t size)
ok &= GetTlvString(data, rssize, &offset,TLV_TYPE_STR_MSG, status_string);
if (offset != rssize)
throw std::runtime_error("Size error while deserializing.") ;
std::cerr << "Size error while deserializing." << std::endl ;
if (!ok)
throw std::runtime_error("Unknown error while deserializing.") ;
std::cerr << "Unknown error while deserializing." << std::endl ;
}
/*************************************************************************/

View File

@ -821,6 +821,17 @@ RsItem *RsTurtleSerialiser::deserialise(void *data, uint32_t *size)
return NULL; /* wrong type */
}
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
switch(getRsItemSubType(rstype))
{
case RS_TURTLE_SUBTYPE_SEARCH_REQUEST: return new RsTurtleSearchRequestItem(data,*size) ;
case RS_TURTLE_SUBTYPE_SEARCH_RESULT: return new RsTurtleSearchResultItem(data,*size) ;
default:
std::cerr << "Unknown packet type in RsTurtle!" << std::endl ;
return NULL ;
}
#else
try
{
switch(getRsItemSubType(rstype))
@ -840,6 +851,8 @@ RsItem *RsTurtleSerialiser::deserialise(void *data, uint32_t *size)
std::cerr << "Exception raised: " << e.what() << std::endl ;
return NULL ;
}
#endif
}
bool RsTurtleSearchRequestItem::serialize(void *data,uint32_t& pktsize)
@ -890,10 +903,13 @@ RsTurtleSearchRequestItem::RsTurtleSearchRequestItem(void *data,uint32_t pktsize
ok &= getRawUInt32(data, pktsize, &offset, &request_id);
ok &= getRawUInt16(data, pktsize, &offset, &depth);
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
#else
if (offset != rssize)
throw std::runtime_error("Size error while deserializing.") ;
if (!ok)
throw std::runtime_error("Unknown error while deserializing.") ;
#endif
}
bool RsTurtleSearchResultItem::serialize(void *data,uint32_t& pktsize)
@ -970,10 +986,13 @@ RsTurtleSearchResultItem::RsTurtleSearchResultItem(void *data,uint32_t pktsize)
result.push_back(f) ;
}
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
#else
if (offset != rssize)
throw std::runtime_error("Size error while deserializing.") ;
if (!ok)
throw std::runtime_error("Unknown error while deserializing.") ;
#endif
}
bool RsTurtleOpenTunnelItem::serialize(void *data,uint32_t& pktsize)
@ -1031,10 +1050,13 @@ RsTurtleOpenTunnelItem::RsTurtleOpenTunnelItem(void *data,uint32_t pktsize)
std::cerr << " request_id=" << (void*)request_id << ", partial_id=" << (void*)partial_tunnel_id << ", depth=" << depth << ", hash=" << file_hash << std::endl ;
#endif
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
#else
if (offset != rssize)
throw std::runtime_error("RsTurtleOpenTunnelItem::() error while deserializing.") ;
if (!ok)
throw std::runtime_error("RsTurtleOpenTunnelItem::() unknown error while deserializing.") ;
#endif
}
bool RsTurtleTunnelOkItem::serialize(void *data,uint32_t& pktsize)
@ -1088,10 +1110,13 @@ RsTurtleTunnelOkItem::RsTurtleTunnelOkItem(void *data,uint32_t pktsize)
std::cerr << " request_id=" << (void*)request_id << ", tunnel_id=" << (void*)tunnel_id << std::endl ;
#endif
#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs).
#else
if (offset != rssize)
throw std::runtime_error("RsTurtleTunnelOkItem::() error while deserializing.") ;
if (!ok)
throw std::runtime_error("RsTurtleTunnelOkItem::() unknown error while deserializing.") ;
#endif
}
// -----------------------------------------------------------------------------------//

View File

@ -7,7 +7,7 @@ RS_TOP_DIR = ..
include $(RS_TOP_DIR)/scripts/config.mk
###############################################################
RSOBJ = rsthreads.o rsdir.o rsprint.o rsnet.o rsdebug.o
RSOBJ = rsthreads.o rsprint.o rsnet.o rsdebug.o rsdir.o
TESTOBJ = dirtest.o dir2test.o

View File

@ -391,14 +391,7 @@ bool RsDirUtil::renameFile(const std::string& from, const std::string& to)
int loops = 0;
#if defined(WIN32) || defined(MINGW) || defined(__CYGWIN__)
#if defined(MINGW) || defined(__CYGWIN__)
std::string f(from),t(to) ;
#else
std::wstring f,t ;
for(std::string::const_iterator it = from.begin(); it!=from.end();++it) f += *it;
for(std::string::const_iterator it = to .begin(); it!=to .end();++it) t += *it;
#endif
while (!MoveFileEx(f.c_str(), t.c_str(), MOVEFILE_REPLACE_EXISTING))
#else
while (rename(from.c_str(), to.c_str()) < 0)