mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Removed some std::ostringstream.
To be continued. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5107 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d52904e7c6
commit
b2ea453804
@ -571,14 +571,12 @@ void p3disc::sendOwnVersion(std::string to)
|
||||
|
||||
void p3disc::sendHeartbeat(std::string to)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3disc::sendHeartbeat()";
|
||||
out << " to : " << to;
|
||||
{
|
||||
std::string out = "p3disc::sendHeartbeat() to : " + to;
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
rslog(RSL_WARNING, pqidisczone, out.str());
|
||||
rslog(RSL_WARNING, pqidisczone, out);
|
||||
}
|
||||
|
||||
|
||||
@ -1168,6 +1166,7 @@ void p3disc::getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCoun
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UNUSED_CODE
|
||||
int p3disc::idServers()
|
||||
{
|
||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||
@ -1176,56 +1175,36 @@ int p3disc::idServers()
|
||||
std::map<std::string, autoserver>::iterator sit;
|
||||
int cts = time(NULL);
|
||||
|
||||
std::ostringstream out;
|
||||
out << "::::AutoDiscovery Neighbours::::" << std::endl;
|
||||
std::string out = "::::AutoDiscovery Neighbours::::\n";
|
||||
for(nit = neighbours.begin(); nit != neighbours.end(); nit++)
|
||||
{
|
||||
out << "Neighbour: " << (nit->second).id;
|
||||
out << std::endl;
|
||||
out << "-> LocalAddr: ";
|
||||
out << rs_inet_ntoa(nit->second.localAddr.sin_addr);
|
||||
out << ":" << ntohs(nit->second.localAddr.sin_port) << std::endl;
|
||||
out << "-> RemoteAddr: ";
|
||||
out << rs_inet_ntoa(nit->second.remoteAddr.sin_addr);
|
||||
out << ":" << ntohs(nit->second.remoteAddr.sin_port) << std::endl;
|
||||
out << " Last Contact: ";
|
||||
out << cts - (nit->second.ts) << " sec ago";
|
||||
out << std::endl;
|
||||
out += "Neighbour: " + (nit->second).id + "\n";
|
||||
rs_sprintf_append(out, "-> LocalAddr: %s:%u\n", rs_inet_ntoa(nit->second.localAddr.sin_addr).c_str(), ntohs(nit->second.localAddr.sin_port));
|
||||
rs_sprintf_append(out, "-> RemoteAddr: %s:%u\n", rs_inet_ntoa(nit->second.remoteAddr.sin_addr).c_str(), ntohs(nit->second.remoteAddr.sin_port));
|
||||
rs_sprintf_append(out, " Last Contact: %ld sec ago\n", cts - (nit->second.ts));
|
||||
|
||||
out << " -->DiscFlags: 0x" << std::hex << nit->second.discFlags;
|
||||
out << std::dec << std::endl;
|
||||
rs_sprintf_append(out, " -->DiscFlags: 0x%x\n", nit->second.discFlags);
|
||||
|
||||
for(sit = (nit->second.neighbour_of).begin();
|
||||
sit != (nit->second.neighbour_of).end(); sit++)
|
||||
{
|
||||
out << "\tConnected via: " << (sit->first);
|
||||
out << std::endl;
|
||||
out << "\t\tLocalAddr: ";
|
||||
out << rs_inet_ntoa(sit->second.localAddr.sin_addr);
|
||||
out <<":"<< ntohs(sit->second.localAddr.sin_port);
|
||||
out << std::endl;
|
||||
out << "\t\tRemoteAddr: ";
|
||||
out << rs_inet_ntoa(sit->second.remoteAddr.sin_addr);
|
||||
out <<":"<< ntohs(sit->second.remoteAddr.sin_port);
|
||||
out += "\tConnected via: " + (sit->first) + "\n";
|
||||
rs_sprintf_append(out, "\t\tLocalAddr: %s:%u\n", rs_inet_ntoa(sit->second.localAddr.sin_addr).c_str(), ntohs(sit->second.localAddr.sin_port));
|
||||
rs_sprintf_append(out, "\t\tRemoteAddr: %s:%u\n", rs_inet_ntoa(sit->second.remoteAddr.sin_addr).c_str(), ntohs(sit->second.remoteAddr.sin_port));
|
||||
|
||||
out << std::endl;
|
||||
out << "\t\tLast Contact:";
|
||||
out << cts - (sit->second.ts) << " sec ago";
|
||||
out << std::endl;
|
||||
out << "\t\tDiscFlags: 0x" << std::hex << (sit->second.discFlags);
|
||||
out << std::dec << std::endl;
|
||||
rs_sprintf_append(out, "\t\tLast Contact: %ld sec ago\n", cts - (sit->second.ts));
|
||||
rs_sprintf_append(out, "\t\tDiscFlags: 0x%x\n", sit->second.discFlags);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "p3disc::idServers()" << std::endl;
|
||||
std::cerr << out.str();
|
||||
std::cerr << std::endl;
|
||||
std::cerr << out;
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// tdelta -> trange.
|
||||
// -inf...<0 0 (invalid)
|
||||
@ -1287,9 +1266,7 @@ bool p3disc::saveList(bool& cleanup, std::list<RsItem*>& /*lst*/)
|
||||
{
|
||||
RsTlvKeyValue kv;
|
||||
kv.key = mapIt->first;
|
||||
std::ostringstream time_string;
|
||||
time_string << mapIt->second;
|
||||
kv.value = time_string.str();
|
||||
rs_sprintf(kv.value, "%ld", mapIt->second);
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "p3disc::saveList() saving : " << mapIt->first << " ; " << mapIt->second << std::endl ;
|
||||
|
@ -140,7 +140,7 @@ int addDiscoveryData(const std::string& fromId, const std::string& aboutId,
|
||||
const struct sockaddr_in& laddr, const struct sockaddr_in& raddr,
|
||||
uint32_t flags, time_t ts,bool& new_info);
|
||||
|
||||
int idServers();
|
||||
//int idServers();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "util/rsrandom.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
|
||||
/****
|
||||
@ -653,7 +651,6 @@ int p3Dsdv::addTestService()
|
||||
|
||||
int rndhash1[SHA_DIGEST_LENGTH / 4];
|
||||
int rndhash2[SHA_DIGEST_LENGTH / 4];
|
||||
std::ostringstream rh, sh;
|
||||
std::string realHash;
|
||||
std::string seedHash;
|
||||
|
||||
@ -664,35 +661,30 @@ int p3Dsdv::addTestService()
|
||||
rndhash2[i] = RSRandom::random_u32();
|
||||
}
|
||||
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
{
|
||||
rh << std::setw(2) << std::setfill('0') << std::hex << (uint32_t) ((uint8_t *) rndhash1)[i];
|
||||
sh << std::setw(2) << std::setfill('0') << std::hex << (uint32_t) ((uint8_t *) rndhash2)[i];
|
||||
}
|
||||
|
||||
realHash = rh.str();
|
||||
seedHash = sh.str();
|
||||
|
||||
uint8_t sha_hash[SHA_DIGEST_LENGTH];
|
||||
memset(sha_hash,0,SHA_DIGEST_LENGTH*sizeof(uint8_t)) ;
|
||||
SHA_CTX *sha_ctx = new SHA_CTX;
|
||||
SHA1_Init(sha_ctx);
|
||||
|
||||
SHA1_Update(sha_ctx, realHash.c_str(), realHash.length());
|
||||
SHA1_Update(sha_ctx, seedHash.c_str(), seedHash.length());
|
||||
SHA1_Final(sha_hash, sha_ctx);
|
||||
delete sha_ctx;
|
||||
|
||||
std::ostringstream keystr;
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
{
|
||||
keystr << std::setw(2) << std::setfill('0') << std::hex << (uint32_t) (sha_hash)[i];
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
{
|
||||
rs_sprintf_append(realHash, "%02x", (uint32_t) ((uint8_t *) rndhash1)[i]);
|
||||
rs_sprintf_append(seedHash, "%02x", (uint32_t) ((uint8_t *) rndhash2)[i]);
|
||||
}
|
||||
|
||||
|
||||
uint8_t sha_hash[SHA_DIGEST_LENGTH];
|
||||
memset(sha_hash,0,SHA_DIGEST_LENGTH*sizeof(uint8_t)) ;
|
||||
SHA_CTX *sha_ctx = new SHA_CTX;
|
||||
SHA1_Init(sha_ctx);
|
||||
|
||||
SHA1_Update(sha_ctx, realHash.c_str(), realHash.length());
|
||||
SHA1_Update(sha_ctx, seedHash.c_str(), seedHash.length());
|
||||
SHA1_Final(sha_hash, sha_ctx);
|
||||
delete sha_ctx;
|
||||
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
{
|
||||
rs_sprintf_append(testId.mHash, "%02x", (uint32_t) (sha_hash)[i]);
|
||||
}
|
||||
|
||||
|
||||
testId.mIdType = RSDSDV_IDTYPE_TEST;
|
||||
testId.mAnonChunk = seedHash;
|
||||
testId.mHash = keystr.str();
|
||||
|
||||
addDsdvId(&testId, realHash);
|
||||
return 1;
|
||||
|
@ -141,34 +141,6 @@ int p3GameLauncher::status()
|
||||
/**** Interface to GUI Game Launcher ****/
|
||||
|
||||
|
||||
std::string generateRandomGameId()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << std::hex;
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
out << std::setw(8) << std::setfill('0');
|
||||
uint32_t rint = random();
|
||||
out << rint;
|
||||
}
|
||||
#else
|
||||
srand(time(NULL));
|
||||
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
out << std::setw(4) << std::setfill('0');
|
||||
uint16_t rint = rand(); /* only gives 16 bits */
|
||||
out << rint;
|
||||
}
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
/**** GUI Interface ****/
|
||||
|
||||
|
||||
@ -218,7 +190,7 @@ std::string p3GameLauncher::newGame(uint16_t srvId, std::wstring name)
|
||||
#endif
|
||||
|
||||
/* generate GameId (random string) */
|
||||
std::string gameId = generateRandomGameId();
|
||||
std::string gameId = generateRandomServiceId();
|
||||
|
||||
gameStatus newGame;
|
||||
newGame.gameId = gameId;
|
||||
@ -747,9 +719,7 @@ bool p3GameLauncher::getGameList(std::list<RsGameInfo> &gameList)
|
||||
info.gameId = git->first;
|
||||
info.serverId = git->second.serverId;
|
||||
|
||||
std::ostringstream out;
|
||||
out << "GameType: " << git->second.serviceId;
|
||||
info.gameType = out.str();
|
||||
rs_sprintf(info.gameType, "GameType: %lu", git->second.serviceId);
|
||||
|
||||
info.serverName = "ServerName";
|
||||
info.numPlayers = git->second.numPlayers;
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
@ -156,9 +155,9 @@ void p3MsgService::processMsg(RsMsgItem *mi)
|
||||
librs::util::ConvertUtf16ToUtf8(mi->message, message);
|
||||
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(), title, message);
|
||||
|
||||
std::ostringstream out;
|
||||
out << mi->msgId;
|
||||
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out.str(), "", "");
|
||||
std::string out;
|
||||
rs_sprintf(out, "%lu", mi->msgId);
|
||||
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -843,9 +842,7 @@ bool p3MsgService::getMsgParentId(const std::string &msgId, std::string &msgP
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
out << mit->second->msgParentId;
|
||||
msgParentId = out.str();
|
||||
rs_sprintf(msgParentId, "%lu", mit->second->msgParentId);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -967,9 +964,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
||||
processMsg(msg);
|
||||
|
||||
// return new message id
|
||||
std::ostringstream out;
|
||||
out << msg->msgId;
|
||||
info.msgId = out.str();
|
||||
rs_sprintf(info.msgId, "%lu", msg->msgId);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1011,9 +1006,7 @@ bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParen
|
||||
imsg[msg->msgId] = msg;
|
||||
|
||||
// return new message id
|
||||
std::ostringstream out;
|
||||
out << msg->msgId;
|
||||
info.msgId = out.str();
|
||||
rs_sprintf(info.msgId, "%lu", msg->msgId);
|
||||
}
|
||||
|
||||
setMsgParentId(msg->msgId, atoi(msgParentId.c_str()));
|
||||
@ -1164,10 +1157,7 @@ bool p3MsgService::getMessageTag(const std::string &msgId, MsgTagInfo& info)
|
||||
std::map<uint32_t, RsMsgTags*>::iterator mit;
|
||||
|
||||
if(mMsgTags.end() != (mit = mMsgTags.find(mid))) {
|
||||
std::ostringstream out;
|
||||
out << mit->second->msgId;
|
||||
|
||||
info.msgId = out.str();
|
||||
rs_sprintf(info.msgId, "%lu", mit->second->msgId);
|
||||
info.tagIds = mit->second->tagIds;
|
||||
|
||||
return true;
|
||||
@ -1390,9 +1380,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
|
||||
mi.srcId = msg->PeerId();
|
||||
{
|
||||
//msg->msgId;
|
||||
std::ostringstream out;
|
||||
out << msg->msgId;
|
||||
mi.msgId = out.str();
|
||||
rs_sprintf(mi.msgId, "%lu", msg->msgId);
|
||||
}
|
||||
|
||||
std::list<std::string>::iterator pit;
|
||||
@ -1488,9 +1476,7 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
||||
mis.srcId = msg->PeerId();
|
||||
{
|
||||
//msg->msgId;
|
||||
std::ostringstream out;
|
||||
out << msg->msgId;
|
||||
mis.msgId = out.str();
|
||||
rs_sprintf(mis.msgId, "%lu", msg->msgId);
|
||||
}
|
||||
|
||||
mis.title = msg->subject;
|
||||
|
@ -30,8 +30,6 @@
|
||||
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
std::string generateRandomShowId();
|
||||
|
||||
/****
|
||||
@ -306,10 +304,9 @@ void p3PhotoService::publishPhotos()
|
||||
/* determine filename */
|
||||
|
||||
std::string path = CacheSource::getCacheDir();
|
||||
std::ostringstream out;
|
||||
out << "photo-index-" << time(NULL) << ".pdx";
|
||||
|
||||
std::string tmpname = out.str();
|
||||
std::string tmpname;
|
||||
rs_sprintf(tmpname, "photo-index-%ld.pdx", time(NULL));
|
||||
std::string fname = path + "/" + tmpname;
|
||||
|
||||
#ifdef PHOTO_DEBUG
|
||||
@ -778,33 +775,30 @@ RsPhotoShowItem *p3PhotoService::locked_getShow(std::string id, std::string show
|
||||
|
||||
std::string generateRandomShowId()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << std::hex;
|
||||
|
||||
std::string out;
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
out << std::setw(8) << std::setfill('0');
|
||||
uint32_t rint = random();
|
||||
out << rint;
|
||||
}
|
||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
uint32_t rint = random();
|
||||
rs_sprintf_append(out, "%08x", rint);
|
||||
}
|
||||
#else
|
||||
srand(time(NULL));
|
||||
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
out << std::setw(4) << std::setfill('0');
|
||||
uint16_t rint = rand(); /* only gives 16 bits */
|
||||
out << rint;
|
||||
}
|
||||
srand(time(NULL));
|
||||
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
uint16_t rint = rand(); /* only gives 16 bits */
|
||||
rs_sprintf_append(out, "%04x", rint);
|
||||
}
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
return out.str();
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3PhotoService::createDummyData()
|
||||
{
|
||||
|
@ -24,8 +24,8 @@
|
||||
*/
|
||||
|
||||
#include "pqi/pqi.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "services/p3service.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
/*****
|
||||
@ -226,29 +226,27 @@ RsRawItem *p3Service::send()
|
||||
|
||||
std::string generateRandomServiceId()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << std::hex;
|
||||
std::string out;
|
||||
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
/* 4 bytes per random number: 4 x 4 = 16 bytes */
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
out << std::setw(8) << std::setfill('0');
|
||||
uint32_t rint = random();
|
||||
out << rint;
|
||||
rs_sprintf_append(out, "%08x", rint);
|
||||
}
|
||||
#else
|
||||
srand(time(NULL));
|
||||
/* 2 bytes per random number: 8 x 2 = 16 bytes */
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
out << std::setw(4) << std::setfill('0');
|
||||
uint16_t rint = rand(); /* only gives 16 bits */
|
||||
out << rint;
|
||||
rs_sprintf_append(out, "%04x", rint);
|
||||
}
|
||||
#endif
|
||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
return out.str();
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
//#include "retroshare/rspeers.h"
|
||||
#include "services/p3tunnel.h"
|
||||
#include "pqi/pqissltunnel.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/authssl.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
@ -86,11 +85,9 @@ int p3tunnel::handleIncoming()
|
||||
|
||||
{
|
||||
#ifdef P3TUNNEL_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3tunnel::handleIncoming()";
|
||||
out << " Received Message!" << std::endl;
|
||||
item -> print(out);
|
||||
std::cerr << out.str();
|
||||
std::string out = "p3tunnel::handleIncoming() Received Message!\n";
|
||||
item -> print_string(out);
|
||||
std::cerr << out;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -125,10 +122,9 @@ void p3tunnel::sendTunnelDataPrivate(std::string to, std::string sourcePeerId, s
|
||||
// Then send message.
|
||||
{
|
||||
#ifdef P3TUNNEL_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3tunnel::sendTunnelDataPrivate() Constructing a RsTunnelItem Message!" << std::endl;
|
||||
out << "Sending to: " << to;
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::string out = "p3tunnel::sendTunnelDataPrivate() Constructing a RsTunnelItem Message!\n";
|
||||
out += "Sending to: " + to;
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user