mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added serialisation methods for SSLId and time_t
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6969 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
98847c60b1
commit
da1b6ac845
@ -256,7 +256,38 @@ bool setRawSha1(void *data,uint32_t size,uint32_t *offset,const Sha1CheckSum& cs
|
||||
|
||||
return true ;
|
||||
}
|
||||
bool getRawSSLId(void *data,uint32_t size,uint32_t *offset,SSLIdType& cs)
|
||||
{
|
||||
uint32_t len = 16 ; // SSL id type
|
||||
|
||||
/* check there is space for string */
|
||||
if (size < *offset + len)
|
||||
{
|
||||
std::cerr << "getRawSha1() not enough size" << std::endl;
|
||||
return false;
|
||||
}
|
||||
bool ok = true ;
|
||||
|
||||
cs = SSLIdType(&((uint8_t*)data)[*offset]) ;
|
||||
*offset += 16 ;
|
||||
|
||||
return ok ;
|
||||
}
|
||||
bool setRawSSLId(void *data,uint32_t size,uint32_t *offset,const SSLIdType& cs)
|
||||
{
|
||||
uint32_t len = 16 ; // SHA1 length in bytes
|
||||
|
||||
if (size < *offset + len)
|
||||
{
|
||||
std::cerr << "setRawSha1() Not enough size" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy((void *) &(((uint8_t *) data)[*offset]), cs.toByteArray(), 16);
|
||||
*offset += 16 ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
bool getRawString(void *data, uint32_t size, uint32_t *offset, std::string &outStr)
|
||||
{
|
||||
uint32_t len = 0;
|
||||
@ -309,3 +340,15 @@ bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getRawTimeT(void *data,uint32_t size,uint32_t *offset,time_t& t)
|
||||
{
|
||||
uint64_t T ;
|
||||
bool res = getRawUInt64(data,size,offset,&T) ;
|
||||
t = T ;
|
||||
|
||||
return res ;
|
||||
}
|
||||
bool setRawTimeT(void *data,uint32_t size,uint32_t *offset,const time_t& t)
|
||||
{
|
||||
return setRawUInt64(data,size,offset,t) ;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <util/rsid.h>
|
||||
|
||||
/*******************************************************************
|
||||
* This is at the lowlevel packing routines. They are usually
|
||||
@ -70,5 +71,11 @@ bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string
|
||||
bool getRawSha1(void *data, uint32_t size, uint32_t *offset, Sha1CheckSum& outStr);
|
||||
bool setRawSha1(void *data, uint32_t size, uint32_t *offset, const Sha1CheckSum& inStr);
|
||||
|
||||
bool setRawSSLId(void *data, uint32_t size, uint32_t *offset, const SSLIdType& inStr);
|
||||
bool getRawSSLId(void *data, uint32_t size, uint32_t *offset, SSLIdType& outStr);
|
||||
|
||||
bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const time_t& inStr);
|
||||
bool getRawTimeT(void *data, uint32_t size, uint32_t *offset, time_t& outStr);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user